Handling Event From External Services

Hi,

Its still the question on event handling on a distributed system.

For an application configured to use amqp, when an event is generated, axon uses the absolute path of the event class as the type of the event. In a different service, this path will probably not exist, so handling this event will virtually be impossible.

Is it possible to change the event type when sending the event over ampq?

Hi Harvey,

I believe that with that stance, you’re using the DefaultAMQPMessageConverter, which indeed, expects a header called ‘axon-message-type’ which resembles the payload type stored in the domain-event-entry table.

You are however free to implement your own AMQPMessageConverter which does things entirely different.

You’d still have to introduce some form of mapping of course, but how you do that, is up to you.

You could for example have some form of ‘common’ module containing all you’re events, which can be included by every service receiving events.

Or you could implement your own schema based solution here.

So short answer to your question: yes it is possible, but requires you to create your own AMQPMessageConverter.

Hope this helps!

Cheers,

Steven

To elaborate Steven’s response:
the DefaultAMQPMessageConverter takes the event type from the serializer, which, in turn, uses the fully qualified class name by default. XStream can use aliases (both on the class level and on the package level), so you can define which types you want to use per class/package.

In the end, it’s the serialized form that defines the contract between components. Not the classes. It’s the serializer’s responsibility to transform one into another.

Hope this helps.
Cheers,

Allard