Question

When building simple restful web application we have a web server handling the requests coming from users. If this server is transforming request into messages and posts them in the queue. When processed by the micro-services how is the response generated back from fragments(micro-service messages) and how is the right user identified? Is it through session id or other id that marks the messages in the queue to which request they belong?

Was it helpful?

Solution

This is a common problem when you use queuing for a synchronous interaction (request-response interaction). You'll need a queue for the request and a callback mechanism for the response, which can be a second queue or, more likely in your case, an http callback to the user (assuming the user can take http requests). In any case, to associate the response generated by the micro-service to the original request, you need a correlation identifier. The correlation identifier pattern is described in the EIP book by Hohpe and Wolf.

OTHER TIPS

The solution that finally did the job was to save all responses in a key/value structure (in this case another microservice). When the response is needed, it gets called by its ID, some payload added to it and then shipped away. In this case any service, when necessary, has the ability to respond.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top