Skip to content

Commit 013053a

Browse files
committed
update Readme
1 parent 078d597 commit 013053a

File tree

1 file changed

+63
-1
lines changed

1 file changed

+63
-1
lines changed

README.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,65 @@
11
# ServiceStack.AzureServiceBus
22

3-
Azure Service Bus MQ Server option for ServiceStack
3+
[![Build status](https://ci.appveyor.com/api/projects/status/2c1ackhg6rloriok/branch/master?svg=true)](https://ci.appveyor.com/project/onlyann/servicestack-azureservicebus/branch/master)
4+
5+
6+
This adds Azure Service Bus [MQ Server option](http://docs.servicestack.net/messaging) for the excellent [ServiceStack](https://github.com/serviceStack/serviceStack) framework.
7+
8+
As it relies on [WindowsAzure.ServiceBus](https://www.nuget.org/packages/WindowsAzure.ServiceBus/) Nuget package, it requires .Net Framework 4.5 Full Profile.
9+
10+
This is inspired from the [Rabbit MQ implementation](http://docs.servicestack.net/rabbit-mq) and supports similar features (most of them are out-of-the-box ServiceStack features irrespective of the MQ Server option):
11+
- Messages with no responses are sent to `.outq` queue
12+
- Messages with responses are sent to the response `.inq` queue
13+
- Responses from messages with ReplyTo are published to that address
14+
- Messages with exceptions are re-tried then published to the respective [dead-letter queue](https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-dead-letter-queues)
15+
- OneWay HTTP requests are published to MQ then executed
16+
- OneWay MQ and HTTP Service Clients are Substitutable
17+
18+
## Adding Azure Service Bus MQ support to ServiceStack
19+
20+
[Create a Service Bus namespace](https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-create-namespace-portal) in Azure and obtain the connection string from the Shared Access policies.
21+
22+
Register Azure Service Bus MQ Server in your ServiceStack AppHost:
23+
24+
```
25+
public override void Configure(Container container)
26+
{
27+
// ...
28+
29+
// register the Azure MQ Server
30+
container.Register<IMessageService>(c => new AzureBusServer("Endpoint=sb://YOUR_SB_NAMESPACE.servicebus.windows.net/;SharedAccessKeyName=YOUR_ACCESS_KEY;SharedAccessKey=****"));
31+
32+
var mqServer = container.Resolve<IMessageService>();
33+
34+
mqServer.RegisterHandler<Hello>(ExecuteMessage);
35+
mqServer.Start();
36+
}
37+
```
38+
39+
## Azure Service Bus MQ Features
40+
41+
The [AzureBusServer](src\ServiceStack.AzureServiceBus\AzureBusServer.cs) has the configuration options:
42+
- `int` **RetryCount** - How many times a message should be retried before sending to the DLQ.
43+
- `string` **connectionString** - The connection string to the Azure Service Bus namespace
44+
- `IMessageFactory` **MessageFactory** - the MQ Message Factory used by this MQ Server
45+
46+
As an alternative to the connection string, you can pass an instance of `AzureBusMessageFactory` to the `AzureBusServer` constructor allowing you to provide your own [NamespaceManager](https://docs.microsoft.com/en-us/dotnet/api/microsoft.servicebus.namespacemanager?redirectedfrom=MSDN&view=azureservicebus-4.1.1#microsoft_servicebus_namespacemanager) and [MessagingFactory](https://docs.microsoft.com/en-us/dotnet/api/microsoft.servicebus.messaging.messagingfactory?view=azureservicebus-4.1.1)
47+
48+
Starting the MQ Server will create up to 2 threads for each handler, one to listen to the Message Inbox `mq-{RequestDto}.inq` and another to listen on the Priority Queue located at `mq-{RequestDto}.priorityq`.
49+
50+
> Queue names are limited to alphanumeric, period, hyphen and underscore in Azure Service Bus. As such, names from the ServiceStack utility [QueueNames<T>](https://github.com/ServiceStack/ServiceStack/blob/master/src/ServiceStack.Interfaces/Messaging/QueueNames.cs) will differ from the actual queue name.
51+
52+
By default, only 1 thread is allocated to handle each message type, but like the other MQ Servers is easily configurable at registration:
53+
54+
```
55+
mqServer.RegisterHandler<Hello>(m => { .. }, noOfThreads:4);
56+
```
57+
58+
> Behind the scenes, it delegates the work to Azure Service Bus [event-driven message pump](https://docs.microsoft.com/en-us/dotnet/api/microsoft.servicebus.messaging.messagereceiver.onmessage?view=azureservicebus-4.1.1#Microsoft_ServiceBus_Messaging_MessageReceiver_OnMessage_System_Action_Microsoft_ServiceBus_Messaging_BrokeredMessage__Microsoft_ServiceBus_Messaging_OnMessageOptions_).
59+
60+
## Upcoming Features
61+
62+
- [ ] queue creation filter
63+
- [ ] queue whitelisting
64+
- [ ] request and response global filter
65+
- [ ] error handler

0 commit comments

Comments
 (0)