Automatically add saga id to event metadata + create default SagaLocator
In documentation about sagas there is this thing about storing saga-id into event metadata. It looks intuitive but it doesn't work out of the box :-(. I would like to make it work. Here is how:
- from PublishAsync pass sagaId and saga type name into ICommandBus.PublishAsync()
- overload ICommandBus.PublishAsync() so it takes an extra argument eventMetadata
- pass event metadata to IAggregateStore.UpdateAsync()
- pass event metadata to AggregateRoot.CommitAsync()
- actually add eventMetadata into _uncommittedEvents
- then we could create a default implementation of SagaLocator which would find saga id and type name in event metadata
or the second option could be to put eventMetadata into command along with already included ISourceId
Hi, I think this could be very uesful. Following steps posted by @mbican I started to code an implementation here: https://github.com/ProH4Ck/EventFlow/tree/feature/saga-metadata At the moment It's a full WIP and it works only for commands published by the saga. What do you think?
I am also busy implementing this. We need it for tracing back to find where an event originated.
Since we use RabbitMQ to send our commands, we do not have access to the HttpContext. I have built a working CommandMetadataContext which is basically like the HttpContext but it allows us to read the metadata from the RabbitMQ message and insert it into the IoC for that async call.
That eliminates the aggregate.SetCommandContext(command); in Source/EventFlow/Commands/CommandHandler.cs
And the metadata falls in line with the normal IMetadataProvider implementation that is already available
thanks @ProH4Ck for adding the metadata to commands - that is very useful and was going to be the next step
Hello there!
We hope you are doing well. We noticed that this issue has not seen any activity in the past 90 days. We consider this issue to be stale and will be closing it within the next seven days.
If you still require assistance with this issue, please feel free to reopen it or create a new issue.
Thank you for your understanding and cooperation.
Best regards, EventFlow
Hello there!
This issue has been closed due to inactivity for seven days. If you believe this issue still needs attention, please feel free to open a new issue or comment on this one to request its reopening.
Thank you for your contribution to this repository.
Best regards, EventFlow