Revisiting Simple.ServiceBus (Windows Server Service Bus Pub/Sub)

In earlier posts named “Fun with Windows Service Bus and AutoFac” parts 12 the demo project was named “Simple.ServieBus” @ github.

Since then, the demo code was refactored and some new features added and new scenarios supported.

In this post we´re going to revisit the project and see what has been done and check out the new features. This posted could have been named “Fun with Windows Service Bus and AutoFac – Part #3” but is not much about AutoFac. We´ll start with the changes;

Changes

  • The project now uses IObservable<T> and thus IObserver<T> for what earlier was IHandler<T>.
  • All actions are Async
  • The default is now one SubscriptionClient per Subscription
  • Ease of Start/Stop Subscription clients , ex TopShelf usage
  • Simplified IoC integration with IResolver.
  • Added IServiceBusManager as starting point for managing underlying topics/subscriptions/queues.

If you read the earlier posts it could be fun to check out the code changes. Let’s look how the IServiceBus has changed, then at examples on usage; (gist)

The Examples

The solution contains a sample folder with the Simple.Servicebus.Demo.Pub project that sends messages and a client project Simple.ServiceBus.Demo.Sub that subscribes to messages.

In the pub solution we now see that the setup of the container is just an extension to register a module. Then we resolve the service bus. This could have used the non IoC ServiceBus factory.

The sub solution might be more interesting. This application uses TopShelf to be hosted as a Windows Service. This example uses another AutoFac extension to register all observers in the project. To configure subscription we then use the new SubscriptionConfigurationService, this uses a similar configuration as before, but this time the container is accesed by the the IResolver abstraction. The naming of the subscription controls the naming of the underlying SubscriptionClient, this so subscriptions is bound to the same client on resuming on start/stop.

Summary

To take it further its still a lot more to do, especially if you would like to cover more scenarios of this article about performance improvements using Service Bus.

You find to code @ github

You also find the project on NuGet.

Enjoy!

Leave a Reply

Close Menu