The-Inevitable-Event-Centric-Book icon indicating copy to clipboard operation
The-Inevitable-Event-Centric-Book copied to clipboard

Problem: Define CorrelationId/CausationId patterns for Events

Open ylorph opened this issue 4 years ago • 5 comments

Splitting #25 in multiple issues : Correlation & Causation as Concepts CorrelationId & CausationId as implementation and patterns

ylorph avatar Oct 31 '19 06:10 ylorph

One thing I have done is have a wrapper context for each event which stores the things that are about the event (like causation and correlation identifiers, and timestamps, and source etc.) that are not part of the event.

Only the payload of the event may be used by projections but the context is available for diagnostics and routing types of (non business) functionality.

MerrionComputing avatar Nov 01 '19 12:11 MerrionComputing

Often that's termed the Envelope; I dont have EIP to hand but I believe that's the source (mentioning as I love the term Context, but always refactor away from it as it's so ... contextual)

bartelink avatar Nov 02 '19 21:11 bartelink

Both right ;-)

https://www.enterpriseintegrationpatterns.com/patterns/messaging/EnvelopeWrapper.html

ylorph avatar Nov 03 '19 17:11 ylorph

I realised just after I posted that there's a degree of 'do as I say, not as I do' in this. In FsCodec's UnionEncoder based Codec, when packing an event into it's stored form, a context is in play, which one uses together with content from within the event to be able to generate the complete metadata and correlation+causation ids.

However the subtle difference here is that the context is ephemeral and is only used to capture the ingredients for the 'Envelope'. In SqlStreamStore, NewEventMessage vs EventMessage covers the difference between an event that has not yet been persisted (and hence does not have a Version or Position) and one that has. (I name those EventData and TimelineEvent in FsCodec)

bartelink avatar Nov 03 '19 17:11 bartelink

Makes me think of what biztalk (!) did with "promoted properties" , they were attributes in the messages that could be used anywhere in the processing pipeline of biztalk (routing, code, ports, ... )

ylorph avatar Nov 04 '19 08:11 ylorph