Practical examples of how correlation id is used in messaging?
Asked Answered
B

3

17

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?

Boothman answered 25/11, 2013 at 4:27 Comment(3)
Have you seen rabbitmq.com/tutorials/tutorial-six-java.html? It has pretty nice explanation about correlation_id.Dice
Here Correlation and Conversations you can see the pattern details. HTHBianco
Thanks for the replies. Now I am get the gist of a correlation id, what about real life examples where the correlation id has been used?Boothman
G
18

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.

Gillmore answered 21/7, 2015 at 21:11 Comment(0)
S
5

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.

Spile answered 23/1, 2014 at 8:1 Comment(1)
can you give more concrete example of what to pass on correlationId? ThanksAcarpous
G
0

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

Ginkgo answered 11/12, 2018 at 16:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.