Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Correlation Id

The pattern of a Correlation Id as well as Causation Id which will also be


discussed has already been defined in Enterprise Integration Patterns [1]. As
they are quite simple patterns which are intrinsically connected to other things
in the text it is worth spending a few pages describing them as opposed to having
them in an external source.
Correlation Id and Causation Id are identifiers which are put onto Messages
that allows the relationship including causative path between the Messages to
be seen.
Every message has a Correlation Id associated to it.
FooOccurred {
correlationId : "cdb4e9ec-85e4-49e9-b5e3-f49613fda34f"
.
.
.
}
When something is responding to a message creating some new messages it
should copy the Correlation Id of the message it is responding to onto the new
messages.
As they are copying the Id if I had a few services working on an order there
could be a message set similar to :
OrderAccepted { correlationId : “7d03f116-c42a-4dd7-9943-b8acf820d5b4” . . .
} OrderPaid { correlationId : “7d03f116-c42a-4dd7-9943-b8acf820d5b4” . . . }
OrderPicked { correlationId : “7d03f116-c42a-4dd7-9943-b8acf820d5b4” . . . }
OrderShipped { correlationId : “7d03f116-c42a-4dd7-9943-b8acf820d5b4” . . . }
If someone wanted to subscribe to all of the messages associated with just this
one order this could be done as a subscription to Correlation Id.
In essence it is creating a topic that can be subscribed to about the things
associated to this one thing.
[1] Hohpe, G., & Woolf, B. (2004). Enterprise integration patterns: Designing,
building, and deploying messaging solutions. Addison-Wesley Professional.

You might also like