castore icon indicating copy to clipboard operation
castore copied to clipboard

ConnectedEventStore's onEventPushed isnt trigged for group events

Open kthompson opened this issue 7 months ago • 2 comments

Describe the bug When using a ConnectedEventStore that is connected to a message bus, the message bus does not receive events that are created via the EventStore.pushEventGroup method.

This seems to occur because onEventPushed is never called because when the GroupEvent is created, the eventStore that is attached to it is the inner EventStore rather than the ConnectedEventStore.

I think overriding the groupEvent method in ConnectedEventStore to assign the connectedEventStore after the GroupEvent is created would resolve this.

To Reproduce Steps to reproduce the behavior:

  1. Create EventStore "ProductEventStore"
  2. Create bus instance of MessageBus implementation of NotificationMessageBus<ProductEventStore>
  3. Create connected instance of ProductEventStore, ie `new ConnectedEventStore(ProductEventStore, bus);
  4. make a call to EventStore.pushGroupEvent(...)
  5. No events come into the bus

Expected behavior We should see all of the events that were pushed come into the bus. They get committed to the EventStore but are not seen on the bus.

Additional context You can work around the issue by assigning the connected bus for each group event created. ie:

const event1 = connected.groupEvent({ ... });
event1.eventStore = connected;

// ...

EventStore.pushEventGroup(event1, event2, ...);

kthompson avatar Jul 10 '24 20:07 kthompson