Description
What would you like to be added:
To allow for a way to name processed correlation keys.
What I propose is to add a new key
or keyName
or whatever property to the correlationDef
object, so that multiple events can address different correlation keys:
...
events:
- name: ProductCreated
kind: consumed
source: ...
type: ...
correlation:
- contextAttributeName: subject
correlationKey: product # the processed key will be stored as 'product'
- name: ProductSold
kind: consumed
source: ...
type: ...
correlation:
- contextAttributeName: subject
correlationKey: product # the processed key will be stored as 'product'
- name: OrderCreated
kind: consumed
source: ...
type: ...
correlation:
- contextAttributeName: subject
correlationKey: order # the processed key will be stored as 'order'
...
Why is this needed:
Consider the following definition:
...
events:
- name: MyEvent1
kind: consumed
source: ...
type: ...
correlation:
- contextAttributeName: subject
- name: MyEvent2
kind: consumed
source: ...
type: ...
correlation:
- contextAttributeName: subject
- name: MyOtherEventThatHasNothingToDoWithTheTwoPrevious
kind: consumed
source: ...
type: ...
correlation:
- contextAttributeName: subject
...
Image we have a sequential flow such as the following:
- Consume MyEvent1 with subject 'foo'
- Consume MyEvent2 with subject 'foo'
- Consume MyOtherEventThatHasNothingToDoWithTheTwoPrevious with subject 'bar'
What would happen on Synapse is:
- Check for a match for a correlation mapping with the defined correlations for MyEvent1 (i.e. subject)
- No correlation mapping exist, so the event is consumed, and the mapping is set to 'subject: foo'
- Check for a match for a correlation mapping with the defined correlations for MyEvent2 (i.e. subject)
- Match exists, and is set to 'foo', so the event is correlated and therefore consumed
- Check for a match for a correlation mapping with the defined correlations for MyOtherEventThatHasNothingToDoWithTheTwoPrevious(i.e. subject)
- Match exists, but the value is not set to 'foo', so the event is consumed, and the mapping is set to 'subject: bar' ===> BOOOOOOOOM
I could very easily find a dirty work around that problem, but like I said, it would be dirty. This is, IMO, up to the workflow designer to decide how a newly created correlation key should be named.
Note: not setting the contextAttributeValue
(and that should be better explained in the spec) basically says that first event to come is gonna set the correlation key based on the defined context attribute (i.e. subject).
Metadata
Metadata
Assignees
Type
Projects
Status