diff --git a/README.md b/README.md index 526a6a3..a8e7d65 100644 --- a/README.md +++ b/README.md @@ -47,12 +47,14 @@ The [AzureBusServer](src\ServiceStack.AzureServiceBus\AzureBusServer.cs) has the - `int` **RetryCount** - How many times a message should be retried before sending to the DLQ. - `string` **connectionString** - The connection string to the Azure Service Bus namespace - `IMessageFactory` **MessageFactory** - the MQ Message Factory used by this MQ Server +- `Action` **CreateQueueFilter** - A filter to customize the options Azure Queues are created/updated with. -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) +As an alternative to a connection string, you can pass an instance of `AzureBusMessageFactory` to the `AzureBusServer` constructor and 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). -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`. +Starting the MQ Server will create up to 2 threads for each handler, one to listen to the Message Inbox `{RequestDto}.inq` and another to listen on the Priority Queue located at `{RequestDto}.priorityq`. -> Queue names are limited to alphanumeric, period, hyphen and underscore in Azure Service Bus. As such, names from the ServiceStack utility [QueueNames](https://github.com/ServiceStack/ServiceStack/blob/master/src/ServiceStack.Interfaces/Messaging/QueueNames.cs) will differ from the actual queue name. +> Queue names are limited to alphanumeric, period, hyphen and underscore in Azure Service Bus. As such, the default prefixes from [QueueNames](https://github.com/ServiceStack/ServiceStack/blob/master/src/ServiceStack.Interfaces/Messaging/QueueNames.cs) and the queue name resolver get overriden by `AzureBusMessageFactory`. The deadletter queue name resolves to `RequestDto.inq/$deadletterqueue`. +> Finally, note that queue names are case-insensitive in Azure Service Bus. By default, only 1 thread is allocated to handle each message type, but like the other MQ Servers is easily configurable at registration: @@ -62,9 +64,23 @@ mqServer.RegisterHandler(m => { .. }, noOfThreads:4); > 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_). +### Filters + +To modify the options a queue gets created with, provide a `CreateQueueFilter` filter and modify the `QueueDescription`. + +For instance, to change the default TTL and have messages expire automatically after 2 minutes: +``` + container.Register(c => new AzureBusServer(ConnectionString) { + CreateQueueFilter = (description) => { + description.DefaultMessageTimeToLive = TimeSpan.FromMinutes(2); + } + }); +``` + +When the queue already exits, the filter can also be used to update the queue options in the same manner. + ## Upcoming Features -- [X] queue creation filter - [ ] queue whitelisting - [ ] request and response global filter - [ ] error handler \ No newline at end of file