Introducing RabbitBus

On June 1, 2012, in Uncategorized, by derekgreer

What Is It?

RabbitBus is a .Net client API for use with RabbitMQ.  RabbitBus was designed to make working with RabbitMQ easy by providing a fluent-interface which places a focus on discoverability and by providing commonly needed constructs not provided through the official RabbitMQ .Net client API.

 

How Do I Use It?

The RabbitBus library was designed to allow for the centralization of all RabbitMQ configuration at application startup, separating the concerns of routing, serialization, and error handling from the central concerns of publishing and consuming messages.

RabbitBus works with object-based messages.  For example, if you have an application from which you would like to publish status update messages, you might model your message using the following class:

[Serializable]
public class StatusUpdate
{
  public StatusUpdate(string status)
  {
    Status = status;
  }

  public string Status { get; set; }
}

After configuring how messages are to be handled, you’ll then use an instance of a Bus type to publish or subscribe to each message.

Configuration of the Bus is handled through a BusBuilder.  The BusBuilder type provides an API for specifying how serialization, publication, consumption, and other concerns will be handled by the Bus.

If you’re already familiar with RabbitMQ concepts then you should find working with RabbitBus to be fairly easy.  The following demonstrates some of the basic usage scenarios:

Message Publication

To configure a producer application to publish messages of type StatusUpdate to a direct exchange named “status-update-exchange” on localhost, you would then use the following configuration:

 
Bus bus = new BusBuilder()
  .Configure(ctx => ctx.Publish<StatusUpdate>()
                         .WithExchange("status-update-exchange"))
  .Build();
bus.Connect();

To publish a StatusUpdate message, you would then make the following invocation:

bus.Publish(new StatusUpdate("OK"));

Message Subscription

To configure a consumer application to subscribe to StatusUpdate messages on localhost, you would use the following configuration:

Bus bus = new BusBuilder()
  .Configure(ctx => ctx.Consume<StatusUpdate>()
                         .WithExchange("status-update-exchange")
                         .WithQueue("status-update-queue"))
  .Build();

To subscribe to StatusUpdate messages, you would then make the following invocation:

bus.Subscribe<StatusUpdate>(messageContext => { /* handle message */ });

 

What Other Features Are Provided?

RabbitBus provides the following features:

  • support of all AMQP 0.9.1 exchange types (i.e. direct, fanout, topic, and headers)
  • remote procedure calls (RPC)
  • deadletter queue support
  • convention based auto-subscription
  • RabbitMQ push and pull API support
  • extensible serialization (Binary serialization by default, Json serialization provided by RabbitBus.Serialization.Json)
  • customizable error handling
  • RabbitMQ server restart recovery
  • configurable offline queuing support
  • logging

 

Where Can I Learn More?

You can find more information about how to use RabbitBus on the RabbitBus Wiki.  Additionally, RabbitBus was developed using Test-Driven Development and care was taken in the implementation of its executable specification suite to maximize demonstration of the API’s intended use.

 

Where Do I Get It?

RabbitBus is available as a NuGet package and the source is available on Github.

Tagged with:  
  • Very nice,Thanks a lot! From the wiki, I woud say that all my wishes were fulfilled. I’ll have a closer look now…