Question

Can anyone give me examples of how in production a correlation id can be used?

I have read it is used in request/response type messages but I don't understand where I would use it?

One example (which maybe wrong) I can think off is in a publish subscribe scenario where I could have 5 subscribers and if I get 5 replies with the same correlation id then I could say all my subscribers have received it. Not sure if this would the be correct usage of it.

Or if I send a simple message, the I can use the correlation to guarantee that the client received it.

Any other examples?

Était-ce utile?

La solution

A web application that is providing HTTP API for outsiders for performing a processing task and you want to give the results for the caller as a response to the HTTP request they made.

A request comes in, message describing the task is pushed to queue by the frontend server. After that the frontend server blocks to wait for response message with the same correlation id. A pool of worker machines are listening on queue and one of them picks up the task, performs it and returns the result as message. Once a message with right correlation id comes in, frontend server continues to return the response to the caller.

Autres conseils

In the context of CQRS and EventSourcing a command message correlation id will most likely get stored togehter with the corresponding events from the domain. This information can later be used to form an audit trail.

Streaming engines like Apache Flink use correlation ids, much like you said, to guarantee exactness of processing.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top