Couple of questions about @EventHandler in Axon 2

From the @EventHandler documentation:

When using Spring and <axon:annotation-config/> is declared, any other parameters will

  • resolve to autowired beans, if exactly one autowire candidate is available in the application context. This allows
  • you to inject resources directly into @EventHandler annotated methods.

This is very convenient, is this also possible for @CommandHandler? The documentation seems to say no.

From the same documentation:

  • Parameters of type {@link org.joda.time.DateTime} will resolve to the timestamp of the EventMessage. This is the * time at which the Event was generated.
  • The way I understand this is that this should work without the @Timestamp annotation, but for me it only works with the annotation.

    I get this message without the annotation:

    On method public void com.bridgebig.user.query.UserEventHandler.handle(com.bridgebig.user.event.UserCreatedEvent,org.joda.time.DateTime), parameter 2 is invalid. It is not of any format supported by a providedParameterValueResolver.

    Hi Jeroen,

    the command handlers and event handlers use exactly the same parameter resolution logic. Probably the documentation is incomplete. For the DateTime, you have to add the @Timestamp parameter. And you can also use parameters that resolve to Spring beans.

    Hope this clarifies it.
    Cheers,

    Allard

    How about the @SagaEventHandler? I’m guessing there I cannot use parameters that resolve to Spring beans?

    In fact, yet you can!
    (if not, it’s a bug)