141
CHAPTER 5 | Designing and Developing Multi-Container and Microservice-Based .NET Applications
Each event type has a related channel to get events from RabbitMQ. You can
then have as many event
handlers per channel and event type as needed.
The Subscribe method accepts an IIntegrationEventHandler object, which is like a callback method in
the current microservice, plus its related IntegrationEvent object. The code then adds
that event
handler to the list of event handlers that each integration event type can have per client microservice.
If the client code has not already been subscribed to the event, the code creates a channel for the
event type so it can receive events in a push style from RabbitMQ when that event is published from
any other service.
As
mentioned above, the event bus implemented in eShopOnContainers has only an educational
purpose, since it only
handles the main scenarios, so it’s not rea
dy for production.
For production scenarios check the additional resources below,
specific for RabbitMQ, and the
Implementing event-based communication between microservices
section.
Dostları ilə paylaş: