139
CHAPTER 5 | Designing and Developing Multi-Container and Microservice-Based .NET Applications
Figure 6-21. RabbitMQ implementation of an event bus
RabbitMQ functions as an intermediary between message publisher and
subscribers, to handle
distribution. In
the code, the EventBusRabbitMQ class implements the generic IEventBus interface.
This implementation is based on Dependency Injection so that you can swap from this dev/test
version to a production version.
public
class
EventBusRabbitMQ : IEventBus, IDisposable
{
// Implementation using RabbitMQ API
//...
}
The RabbitMQ implementation of a sample dev/test event bus is boilerplate code. It has to handle the
connection to the RabbitMQ server and provide code for publishing a message event to the queues. It
also has to implement a dictionary of collections of integration event
handlers for each event type;
these event types can have a different instantiation and different subscriptions for each receiver
microservice, as shown in Figure 6-21.
Dostları ilə paylaş: