To ensure ms-2 invokes @EventHandler for events from other microservices, e.g. ms-1, event classes must have the same package hierarchy.
For example, if ms-1 publishes an event com.example.events.ProfileCreated
, you must ensure that in the ms-2
project the ProfileCreated
event is located just at com.example.events.ProfileCreated
too.
It does not matter if you manually copy events between projects or create a separate library dedicated specially for such events.