Microservice and Containerization Patterns > Event Processing Patterns > Event-Driven Messaging
Event-Driven Messaging (Erl, Naserpour)
How can microservices be automatically notified of runtime events triggered by other microservices?
Problem
Solution
Application
An event management program is introduced, allowing microservices to set themselves up as subscribers to events associated with a target microservice that assumes the role of publisher. There may be different types of events that each microservice makes available. Other microservices can choose which they would like to be subscribed to.
When such an event occurs, the publisher microservice automatically sends the event details to the event management program, which then broadcasts an event notification to all of its subscribers.
Microservice A requests that it be set up as a subscriber to the event it is interested in by interacting with an event manager. Once the event occurs, Microservice B forwards the details to the event manager which, in turn, notifies Microservice A (and all other subscribers) via a one-way, asynchronous data transfer. Note that in this case, Microservice A also receives the event information earlier because the event details can be transmitted as soon as they’re available.
This pattern can be applied by implementing the event management program as an isolated microservice, as explained in the complete pattern description.