We use the Axon SpringAMQP event bus, we have multiple applications which use Axon that communicate with each other via the event bus.
Tt often happens that the Event classes, lie in different packages in each of the applications, this results in a failure to deserialise while subscribing to the event.
A suggestion in one the earlier posts was to use something like the below
I think the typical answer for this is to move these event definitions out to a common sub-project that the other projects depend on; thus they all use the events in the same package. This subproject removes the duplication of event definitions, and defines the common “vocabulary” by which all the projects/applications interact. (Of course there are problems to solve, particularly around versioning.)
I totally agree with Kyle.
However, using package aliases typically makes sense, since an application’s “base package” is often something in the sense of com.mycompany.mydepartment.myapp.somesubdomain. In the Event XML is often suffices to mention “mysubdomain.MyEvent”. You can create an alias for com.mycompany.mydepartment.myapp.somesubdomain => somesubdomain. It will make the serialized form of events smaller.
In Spring (4 for sure and perhaps it also works in 3), the easiest way to configure the XStreamSerializer is to use JavaConfig to define the serializer bean (using @Configuration and @Bean). XML configuration is rather limited when it comes to customization.