castore
castore copied to clipboard
ConnectedEventStore's onEventPushed isnt trigged for group events
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:
- Create EventStore "ProductEventStore"
- Create
bus
instance of MessageBus implementation ofNotificationMessageBus<ProductEventStore>
- Create
connected
instance ofProductEventStore
, ie `new ConnectedEventStore(ProductEventStore, bus); - make a call to
EventStore.pushGroupEvent(...)
- 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, ...);