Pass payload in non deserialised form to event listener


Is it possible to pass the payload of events in a non deserialised format (string/bytes) in an event handler method? I don’t want to deserialize the object as I don’t need them in object form but just want to transfer the payload as is to an external service.


I am not an Axon developer, so please take my statement with a grain of salt. As far as I know this is not possible. The readEvents method of the event store allows only access to the already upcasted and deserialized objects. The readEventData method on the other hand (which might allow this) is not public.

That said, I see still some possible solutions:

  1. Use an event handler as is and “reserialize” the event payload with the configured Serializer. This is (apart from the upcasting) the same and might be, depending on your use case, probably be a good idea anyway so that you have a little bit more control of what is transported to your external service.
  2. You could also access the raw data in an upcaster or in a customized upcaster chain. However, you how almost no control over who calls it, as he upcasters are configured per storage engine and not per event processor.
  3. Access the data directly via SQL or JPA. Of course you lose all advantages of Axon’s retry/tracking mechanisms.

Best regards


Edit: Point 3 works (of course) only in case of an a non-axon-server scenario allowing you direct access to the events in the database.

1 Like