In my last post you heard introductory details about the bbv.Common.EventBroker. Let us take this one step further. Imagine going from one process to multiple processes or even firing events over multiple machines. And all this with your existing event broker and with only a few lines of code. Too good to be true? I can assure you it is possible! Let’s dive into the distributed event broker.
The distributed event broker is not a product of its own but it is a powerful extension for the Event Broker which allows to fire events over process boundaries! It offers the following features:
- Fire events over process boundaries with 2 lines of code!
- Transparently integrates into your existing usage of the event broker
- Adapters for major .NET enterprise service buses (NServiceBus, MassTransit and RhinoESB)
- Heavily extensible to suit your business case
- Supports multiple serializers (BinarySerializer, XmlSerializer, DataContractSerializer …)
- Selection of topics which fire over process boundaries
- Customizable transport message
Curious how it works? Let’s get our hands dirty…
The actual setup of the event broker is as easy as the following lines:
// Use existing event broker or create special one for distributed events var eventBroker = new EventBroker(); // Use extension method AddDistributedExtension var extension = // new TechnologySpecificDistributedEventBrokerExtension eventBroker.AddDistributedExtension(extension);
The transport layer for the distributed event broker is pluggable. There is a technology specific event broker extension for each of the supported transport layers. The initialization of the transport layer is not covered by the distributed event broker and must be done by you. Help and documentation how to setup a transport layer can be found on the community sites of those.
IBus bus = // Get IBus instance var extension = new NServiceBusDistributedEventBrokerExtension("DistributedEventBroker", bus); eventBroker.AddDistributedExtension(extension);
Make sure that bbv.Common.DistributedEventBroker.NServiceBusAdapter.dll is scanned by NServiceBus when auto loading of message handlers is enabled.
IServiceBus serviceBus = // Get IServiceBus instance var extension = new MassTransitDistributedEventBrokerExtension ("DistributedEventBroker", serviceBus); eventBroker.AddDistributedExtension(extension);
Make sure the MassTransitEventFiredHandler is registered with transient life time in the underlying container. When supported, use assembly scanning functionality of container and include bbv.Common.DistributedEventBroker.MassTransitAdapter.dll in the search.
IServiceBus serviceBus = // Get IServiceBus instance var extension = new RhinoEsbDistributedEventBrokerExtension("DistributedEventBroker", serviceBus); eventBroker.AddDistributedExtension(extension);
Make sure the RhinoEsbEventFiredHandler is registered in the windsor container.
The next post will cover advanced stuff like scoping and identification, custom messages, serializers and selection strategies.
[…] communication foundation requests and responses and event driven data, which is fired over the distributed event broker. Some of the data is dynamically rendered on the client but needs to be translated into several […]