@SagaEventHandler methods in saga class

Hi.
I have saga class (BinaryOperation) with two similar methods, something like this:

`

@SagaEventHandler(associationProperty=“name”, keyName=“arg1stName”)
public void onSetArg1stValue(SetValueEvent event)
{
arg1stValue = event.getValue();
bus.dispatch(GenericCommandMessage.asCommandMessage(new SetValueCommad(resultName, calc(arg1stValue, arg2ndValue))));
}

@SagaEventHandler(associationProperty=“name”, keyName=“arg2ndName”)
public void onSetArg2ndValue(SetValueEvent event)
{
arg2ndValue = event.getValue();
bus.dispatch(GenericCommandMessage.asCommandMessage(new SetValueCommad(resultName, calc(arg1stValue, arg2ndValue))));
}

`

And this is not working, because (in my opinion) MethodMessageHandlers of this methods are equals (not in Object.equals() but in Comparable.compare() terms) and TreeSet in SagaMethodMessageHandlerInspector cant hold both of them. Is this glitch, or I cant use two event-handler-methods with same Event-types in one saga-class (with SimpleSagaManager)?

Hi,

at this moment, it is not possible to have more than one handler method accepting the same Event type. I assume you get an exception at startup?
And when mentioning SimpleSagaManager, I assume you meant AnnotatedSagaManager?

Cheers,

Allard

Sorry. AnnotatedSagaManager of course. I have no exceptons on startup and no exceptions on runtime. 2nd method is ignored.

Hi,

I’ve just checked the code. It should be possible to have multiple handlers for the same payload type. The code says so explicitly. However, further down, only the first matching handler is really used. The others are ignored.
Hence, what you’re trying to do (2 handlers for the same payload, with different association properties) should be possible.

I have created AXON-209 to track this issue. I won’t be able to fix this in 2.0.9, as it requires some intricate changes in the SPI’s. I’m planning it for 2.1.

Cheers,

Allard

Thank you.