Quantcast
Channel: Akka Libraries - Discussion Forum for Akka technologies
Viewing all articles
Browse latest Browse all 1365

How to handle null state in return of event handlers for EventSourcedBehavior

$
0
0

I’m handling events with newEventHandlerBuilder(), and notice that if I return “null” for a state, the event will be handled by multiple handlers, for example, with this code

eventEventHandlerBuilder
.forAnyState()
.onEvent(MemberDeleted.class, memberDeleted → {
logger.info(String.format(“forAnyState, onEvent: %s”, memberDeleted));
return null;
})
.onAnyEvent(event → {
logger.warning(String.format(“forAnyState, onAnyEvent: %s”, event));
return null;
});

I will see both the onEvent and onAnyEvent being called for a MemberDeleted event. But if i change the return type to a class (I added a NullMember class) I will only see the onEvent method called.

It’s not supported to return a null, if there is no real state to care about?

thanks in advance

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 1365

Trending Articles