Queue naming convention

A proper naming convention is one of the key requirements for building a robust integration framework in the cloud. With standardized naming, developers and architects can easily locate resources and services, thus decreasing duplicate resource creation. This also helps the enterprise to better manage the consumption of resources and limit billing patterns in the cloud.

Microsoft has come up with a standard naming convention, the details of which you can find at the Microsoft documentation site. As this section is dedicated to Service Bus and Service Bus-related artifacts such as queues and topics, let's take some time to learn about the naming conventions of the Service Bus namespace and Service Bus queue:

  • The Service Bus namespace name must be between 6 and 50 characters long and can only contain letters, numbers, and hyphens.
  • For queues, the standard naming convention dictates that the name should follow the enterprise pattern with between 3 and 63 characters, which will again be restricted to alphanumeric characters along with the hyphen character.

To keep building a foundation for understanding DevOps exercises through ARM, the following is the ARM definition for creating a Service Bus queue. The Service Bus namespace resource is a parent resource, and therefore the queue definition has a dependsOn section with the name of the Service Bus namespace, along with the queue name:

{
"type": "Microsoft.ServiceBus/namespaces/queues",
"name": "[concat(parameters('azureservicebusnamepaceName'), '/',parameters('azureservicebusOrderProcessingqueue'))]",
"apiVersion": "2017-04-01",
"location": "[resourceGroup().location]",
"scale": null,
"properties": {
"lockDuration": "PT30S",
"maxSizeInMegabytes": 16384,
"requiresDuplicateDetection": false,
"requiresSession": false,
"defaultMessageTimeToLive": "P14D",
"deadLetteringOnMessageExpiration": false,
"enableBatchedOperations": true,
"duplicateDetectionHistoryTimeWindow": "PT10M",
"maxDeliveryCount": 10,
"status": "Active",
"autoDeleteOnIdle": "P10675199DT2H48M5.4775807S",
"enablePartitioning": true,
"enableExpress": false
},
"dependsOn": [
"[resourceId('Microsoft.ServiceBus/namespaces', parameters('azureservicebusnamepaceName'))]"
]
}

To create Service Bus queues programmatically, you can use the Service Bus SDK and create a management client, which can then perform read/write operations on Service Bus namespace resources such as queues or topics. The following code is the console code written in C# using the Microsoft Service Bus SDK to create Service Bus queues:

        public async Task<object> CreateSbQueues(string queuename)
{
var client = new ManagementClient(sbconnection);
bool queueExists = await client.QueueExistsAsync(queuename).ConfigureAwait(false);
if (!queueExists)
{
QueueDescription queueName = new QueueDescription(queuename);
queueName.MaxSizeInMB = 1024;
queueName.DefaultMessageTimeToLive = new TimeSpan(2, 0, 0, 0);
var result = await client.CreateQueueAsync(queueName).ConfigureAwait(false);
return result;
}
else
{
return "Queue already exsits!!";
}
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.170.206