PooledStreamingEventProcessor: Token is not updated if no matching event handler is present
See original GitHub issueBasic information
- Axon Framework version: 4.5.1
- JDK version: 11
- Complete executable reproducer if available (e.g. GitHub Repo): https://github.com/OLibutzki/axon-token-issue
Steps to reproduce
I’m afraid we stumbled upon an issue with the PooledStreamingEventProcessor
. I created a reproducer at https://github.com/OLibutzki/axon-token-issue.
In my example I have two events: Event1
and Event2
.
There are 4 event handling components. Each component is assign to a seperate event processor by using @ProcessingGroup
. For simplicity the number of initial segment is set 1 for each event processor.
PooledStreamingEvent1Handler
handles Event1
and is backed by a PooledStreamingEventProcessor
.
PooledStreamingEvent2Handler
handles Event2
and is backed by a PooledStreamingEventProcessor
.
TrackingEvent1Handler
handles Event1
and is backed by a TrackingEventProcessor
.
TrackingEvent2Handler
handles Event2
and is backed by a TrackingEventProcessor
.
In my test case I publish Event1
and expect the token to be updated to index 1 within one second. There is a test for each ProcessingGroup.
Unfortunately, the test fails for the PooledStreamingEventProcessor
if there is no event handler which handles the published event. When Event1
is published the token of PooledStreamingEvent2Handler
remains null
as PooledStreamingEvent2Handler
does not have an event handler for Event1
.
This is a difference compared to the TrackingEventProcessor
which updates the token regardless of having a matching event handling component.
First of all I assumed that it might be related to the initial token being null, but I added another test which published Event2
and then Event1
. The token of PooledStreamingEvent2Handler
remains at Index 1 in this case, althogh I expect it to be at index 2.
The consequences are annoying because the events are processed again and again as the token is not updated in the expected way.
Expected behaviour
The token is updated regardless of the existence of a event handling component for the published event.
Actual behaviour
The token is not updated if the published event is not handled by the any event handler of the event processor.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Spotted what caused the problem The
eventFilter
invoked on line 515 of theCoordinator
removes the event and filters it out of the event stream because there’s no handler interested. The fact the token isn’t updated, however, deviates from the desired outcome. We’ll take a look at resolving this for 4.5.2.In the meantime, you can add the (albeit ugly) workaround of:
Object
, as this will effectively catch every event for which something more specific hasn’t been definedWe’ll be sure to update this issue accordingly when the PR adjusting this behavior has been provided. And, as always, thanks for showing this insight, @OLibutzki!
It looks like that the
ProcessingEntry
is not put into theprocessingQueue
. Therefore thelastConsumedToken
is not updated.