AppFabric queue support for NServiceBus
September 21, 2011 Leave a comment
Last week at the //BUILD conference, Microsoft announced the public availability of the AppFabric Queues, Topics and Subscriptions. A release that I have been looking forward to for quite some time now, as especially the queues are a very valuable addition to the NServiceBus toolset.
These new queues have several advantages over azure storage queues:
- Maximum message size is up to 256K in contrast to 8K
- Throughput is a lot higher as these queues are not throttled on number of messages/second
- Supports TCP for lower latency
- You can enable exactly once delivery semantics
- For the time being they are free!
For a complete comparison between appfabric queues and azure storage queues, this blog post seems to be a very comprehensive and complete overview: http://preps2.wordpress.com/2011/09/17/comparison-of-windows-azure-storage-queues-and-service-bus-queues/
How to configure NServiceBus to use AppFabric queues
As always, we try to make it as simple as possible. If you manually want to initialize the bus using the Configure class, you can just call the following extension method.
If you use the generic role entrypoint, you can enable appfabric queue support by specifying the following profile in the service configuration file
Besides one of these enablers you also need to specify a configuration for both your service namespace and your issuer key. These can be specified in the AppFabricQueueConfig section and are required as they cannot be defaulted by nservicebus because there is no local development equivalent to default to.
<Setting name="AppFabricQueueConfig.IssuerKey" value="yourkey" /> <Setting name="AppFabricQueueConfig.ServiceNamespace" value="yournamespace" />
That’s it, your good to go.. this is all you need to do to make it work.
If you want to further control the behavior of the queue there are a couple more settings:
- AppFabricQueueConfig.IssuerName – specifies the name of the issuer, defaults to owner
- AppFabricQueueConfig.LockDuration – specifies the duration of the message lock in milliseconds, defaults to 30 seconds
- AppFabricQueueConfig.MaxSizeInMegabytes – specifies the size, defaults to 1024 (1GB), allowed values are 1, 2, 3, 4, 5 GB
- AppFabricQueueConfig.RequiresDuplicateDetection – specifies whether exactly once delivery is enabled, defaults to false
- AppFabricQueueConfig.RequiresSession – specifies whether sessions are required, defaults to false (not sure if sessions makes sense in any NServiceBus use case either)
- AppFabricQueueConfig.DefaultMessageTimeToLive – specifies the time that a message can stay on the queue, defaults to int64.MaxValue which is roughly 10.000 days
- AppFabricQueueConfig.EnableDeadLetteringOnMessageExpiration – specifies whether messages should be moved to a dead letter queue upon expiration
- AppFabricQueueConfig.DuplicateDetectionHistoryTimeWindow – specifies the amount of time in milliseconds that the queue should perform duplicate detection, defaults to 1 minute
- AppFabricQueueConfig.MaxDeliveryCount – specifies the number of times a message can be delivered before being put on the dead letter queue, defaults to 5
- AppFabricQueueConfig.EnableBatchedOperations – specifies whether batching is enabled, defaults to no (this may change)
- AppFabricQueueConfig.QueuePerInstance – specifies whether NServiceBus should create a queue per instance instead of a queue per role, defaults to false
Now it’s up to you
If you want to give NServiceBus on AppFabric queues a try, you can start by running either the fullduplex or pubsub sample and experiment from there.
Any feedback is welcome of course!