-
Notifications
You must be signed in to change notification settings - Fork 10
Controlling Queue Names
The default behaviour of AzureNetQ, when generating names for queues, is to use message type name and append it with subscription Id. For example the PartyInvitation
message type from namespace AzureNetQ.Tests.Integration
will use a name AzureNetQ.Tests.Integration.PartyInvitation-AzureNetQ.Tests
In this context, the term queue is used to refer to Service Bus Topics & Subscriptions. See the section Casing in point: Topics and topics, Subscriptions and subscriptions for more details.
Please note that the following feature is not yet implemented in AzureNetQ
To control the name of the queue, annotate the message class with Queue
attribute:
[Queue("TestMessagesQueue")]
public class TestMessage
{
public string Text { get; set; }
}
// ...
bus.Subscribe<TestMessage>(msg => Console.WriteLine(msg.Text));
Here we tell AzureNetQ to use TestMessagesQueue as a queue name.
Using QueueAttribute allows for messages to be consumed from any queue. This can be used to consume messages which are published by frameworks other than AzureNetQ as long as one condition is met - the message has to have a property called type
set. The value of type
property is used during message de-serialization to determine type of the message. As long as this property is set to something meaningful, the messages may be consumed. Decoding type name is done in ITypeNameSerializer.Deserialize
method.
Setting queue name to empty string will use default naming behaviour. The maximum length of queue name is 260 characters (this is enforced by Service Bus). The name can be a sequence of letters, digits, hyphen, underscore or period.
It is important to note that AzureNetQ will always use Service Bus Topics/Subscriptions for Publish/Subscribe. The queue name you specify via this attribute will be used as the Topic name. Subscription names can already be controlled via the fluent configuration eg:
bus.Subscribe<TestMessage>(msg => Console.WriteLine(msg.Text), x => x.WithSubscription("my.subscription"));
If you wish to use AzureNetQ with an existing Service Bus Queue, you should use Send Receive instead
- Quick Start
- Introduction
- Casing in point: Topics and topics, Subscriptions and subscriptions
- Installing AzureNetQ
- Connecting to Service Bus
- Logging
- Publish
- Subscribe
- Request Response
- Send Receive
- Topic Based Routing
- Controlling Queue names
- Polymorphic Publish and Subscribe
- Scheduling Events with Future Publish
- Auto Subscriber
- Non Generic Publish & Subscription Extension Methods
- Replacing AzureNetQ Components
- Using a DI Container