I am currently building a REST web service that needs to communicate with Kafka in a request/response pattern. (I know that Kafka is not really designed for that).
Steps 1 to 3 seems pretty easy but I'm struggling with step 4.
My idea was to propagate an ID in each message so that I could retrieve the response corresponding to the request.
However, I have a hard time figuring out how to set up the listener on the REST web service. How can the listener returns the message to the controller?
i think is better just create a topic for each user, then the user can send a message to another service, such message is like:
{
user:"myUserName"
data:"data of message"
}
then the service just need to push to the topic "user.myUserName" Then from the web client just need to be subscribed to "user.myUserName" (with a consumergroup configuration, this just for read only the newest messages )...
i think the best way is just implement websocket and then push/read by that way ;)
Bye and good day.