We've been hard at work on the next major version of NServiceBus for a long time, and we're really excited to show it to you for the first time today! With major improvements in performance, top-to-bottom async support, and an even cleaner API, this version takes NServiceBus to a whole new level. And as of today, NServiceBus 6.0 is now available for public beta.

If that's all you needed to hear and you want to get going right away, open Visual Studio's Package Manager Console and get started:

PM> Install-Package NServiceBus -Pre

If you'd like to know more about what the new version can do for you, read on.

Async/await

The async and await keywords make it easier for you to write asynchronous code more effectively, which in turn makes processes that are heavily IO-bound more efficient. NServiceBus has to spend a lot of time waiting for IO from queues and databases, so it makes sense that the biggest change in NServiceBus 6.0 is that the framework has been rewritten to be fully async. Message handlers will now return async Task, and you can await asynchronous operations within your handler logic.

If you're new to async/await, you can get up to speed quickly by checking out our async/await webinar series.

Clearer and more focused API

In addition to async/await, we've changed some APIs to make working with NServiceBus easier.

First, we've changed how message handlers work, making it easier to do the right thing and harder to make mistakes. Instead of injecting an instance of IBus into your handlers, which allows for all possible messaging operations, message handlers will instead have a special context parameter containing only the operations that are valid within that context. This will make it very hard to call Unsubscribe() from within a message handler (almost always a bad idea).

Second, we've made sagas a lot easier to develop. Through small changes to the API, we've been able to eliminate all of the common mistakes people typically make when authoring a saga. Have you ever been burned by forgetting to add the [Unique] attribute to your saga data? Well, that won't happen anymore.

A full rundown of the changes are available in the NServiceBus 5 to 6 upgrade guide.

Azure

The Azure transports (Azure Storage Queues and Azure Service Bus), along with Azure Storage Persistence, contain the most upgrades in this release, as Microsoft has lately been shipping most new features for Azure with async-only APIs. Everything has been completely rewritten for async, which has also opened up the use of new APIs. This provides a phenomenal improvement in performance.

Azure Storage Queues

Azure Storage, being one of the oldest and most mature Azure services, has not received many upgrades related to queues. However, the upgrade to an async API has significantly improved the performance of NServiceBus. We are now able to completely saturate a storage account (2000 messages per second) when excluding the overhead of message size and handler logic.

Check out the Azure Storage Queues upgrade guide for more information.

Azure Service Bus

In Azure Service Bus, NServiceBus can now be more efficient when sending multiple messages. Outgoing messages are sent as batches rather than individually, and the reduction in roundtrips to Azure servers results in better performance.

A big addition in Azure Service Bus gives you stronger message consistency guarantees with atomic send+receive within a single namespace. This means that the processing of a message and the sending of messages within the message handler are atomic; outgoing messages are not really sent unless the incoming message is processed successfully. The result is that you don't have to worry about ghost messages being sent when a message handler rolls back. This is game-changing for Azure developers, as you can now have the same level of consistency in messaging operations previously enjoyed only by on-premises developers.

Check out the Azure Service Bus upgrade guide for more information.

Azure Storage Persistence

Azure Storage Persistence has also received a big upgrade. In Azure persistence, where storing or retrieving data involves a round-trip to the Azure cloud, the move to async is a big benefit. Azure persistence has also received a major improvement in its saga persister. The new version will create indexing entries to prevent duplicate saga entities, and the elimination of a full table scan will provide a significant performance increase.

Check out the Azure Storage Persistence upgrade guide for more information.

MSMQ

A major pain point with the MSMQ transport has been scaling out. Other transports can use the competing consumers pattern, but scaling out MSMQ required the Distributor component. The Distributor routes all messages through a central point. As a result, it has inherent limitations and is difficult to cluster for high availability.

For NServiceBus 6.0, we've created a new method of scaling out MSMQ endpoints: sender-side distribution. In this scheme, all senders are aware of the available endpoint instances that can process a given message. They will alternate between configured instances without the need for a distributor component.

For more information on sender-side distribution, see our Scale Out with Competing Consumers and Sender-Side Distribution sample.

We've also done some major performance tuning on MSMQ. We think you'll be very happy with how much faster the MSMQ transport is in NServiceBus 6.0.

RabbitMQ

The RabbitMQ transport has received a massive overhaul, which will make it perform much better overall. It will be easier to tell what's going on from the RabbitMQ admin page, especially when running multiple endpoint instances in a competing consumer pattern. We've also revamped the connection management for higher reliability and introduced support for TLS-encrypted RabbitMQ servers (using AMQPS). This will allow you to securely connect to cloud-hosted RabbitMQ instances.

Check out the RabbitMQ upgrade guide for more information.

SQL Server Transport

The SQL Server Transport has also been redesigned to be more efficient. Because the ADO.NET API supports async/await, we can take full advantage of the benefits of asynchronous programming and the performance enhancements that it yields. We also made it easier to configure connection strings, especially when using a multi-schema topology.

Check out the SQL Server Transport upgrade guide for all the details.

Try it out!

We'd love for you to go get the new beta packages and take them for a spin. Just check the Include prerelease checkbox in the NuGet Package Manager, or include the -Pre flag when installing packages from the NuGet Package Manager Console.

While we've done some pretty thorough testing on the beta, please note that you shouldn't use it in production just yet.

We would love your feedback on the new version. Please let us know what you think in the comments below. We'll be writing a lot more about all the improvements in NServiceBus 6.0 as we get closer to a final release, so stay tuned!

Read more →