EventFlow icon indicating copy to clipboard operation
EventFlow copied to clipboard

Automatically add saga id to event metadata + create default SagaLocator

Open mbican opened this issue 6 years ago • 2 comments

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:

  1. from PublishAsync pass sagaId and saga type name into ICommandBus.PublishAsync()
  2. overload ICommandBus.PublishAsync() so it takes an extra argument eventMetadata
  3. pass event metadata to IAggregateStore.UpdateAsync()
  4. pass event metadata to AggregateRoot.CommitAsync()
  5. actually add eventMetadata into _uncommittedEvents
  6. 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

mbican avatar Mar 16 '19 08:03 mbican

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?

ProH4Ck avatar Aug 30 '19 10:08 ProH4Ck

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

Brandon2255p avatar Jul 10 '20 06:07 Brandon2255p

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

github-actions[bot] avatar Apr 08 '23 13:04 github-actions[bot]

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

github-actions[bot] avatar Apr 16 '23 09:04 github-actions[bot]