- Azure Service Bus Command Line Tool
- Index
- How to Use it
- API Mode
- [GET] /topics
- [POST] /topics
- [GET] /topics/{topic_name}
- [DELETE] /topics/{topic_name}
- [PUT] /topics/{topic_name}/send
- [PUT] /topics/{topic_name}/sendbulk
- [PUT] /topics/{topic_name}/sendbulktemplate
- [GET] /topics/{topic_name}/subscriptions
- [POST] /topics/{topic_name}/subscriptions
- [GET] /topics/{topic_name}/{subscription_name}
- [DELETE] /topics/{topic_name}/{subscription_name}
- [GET] /topics/{topic_name}/{subscription_name}/deadletters
- [GET] /topics/{topic_name}/{subscription_name}/messages
- [GET] /topics/{topic_name}/{subscription_name}/rules
- [POST] /topics/{topic_name}/{subscription_name}/rules
- [GET] /topics/{topic_name}/{subscription_name}/rules/{rule_name}
- [DELETE] /topics/{topic_name}/{subscription_name}/rules/{rule_name}
- [GET] /queues
- [POST] /queues
- [GET] /queues/{queue_name}
- [DELETE] /queues/{queue_name}
- [PUT] /queues/{queue_name}/send
- [PUT] /topics/{queue_name}/sendbulk
- [PUT] /topics/{queue_name}/sendbulktemplate
- [GET] /queues/{queue_name}/deadletters
- [GET] /queues/{queue_name}/messages
- Topics
- Queues
This is a command line tool to help test service bus messages.
You will be able to do C U RD operations to topics/subscriptions and queues, you will also be able to send messages and subscribe to a specific queue/subscription
Once you have it compiled you can run it with the needed options
you can also run the following command to display the help
servicebus.exe --help
The ServiceBus Client contains an API mode that gives the same functionality but using a REST api To start the client in API mode run the following command.
servicebus.exe api
Returns all the topics in the namespace
Creates a Topic in the namespace
Example Payload:
{
"name": "example",
"options": {
"autoDeleteOnIdle": "24h",
"enableBatchedOperation": true,
"enableDuplicateDetection": "30m",
"enableExpress": false,
"maxSizeInMegabytes": 10,
"defaultMessageTimeToLive": "1d",
"supportOrdering": true,
"enablePartitioning": true
}
}
Returns the details of a specific topic in the namespace
Deletes a specific topic from the namespace, this will also delete any subscriptions and messages in the same topic
Sends a message to the specific topic
Example Payload:
{
"label": "example",
"correlationId": "test",
"contentType": "application/json",
"data": {
"key": "value"
},
"userProperties": {
"name": "test message"
}
}
Sends bulk messages to the specific topic
Example Payload:
{
"messages": [
{
"label": "example",
"correlationId": "test",
"contentType": "application/json",
"data": {
"key": "value1"
},
"userProperties": {
"name": "test message1"
}
},
{
"label": "example",
"correlationId": "test",
"contentType": "application/json",
"data": {
"key": "value2"
},
"userProperties": {
"name": "test message2"
}
}
]
}
Sends a templated bulk messages to the specific topic, it can set a wait time between batches
You can define in how many batches you want to send the amount of message and a wait time between each batches.
Attention: if the volume of messages is big, the messages will be split in batches automatically, this also happens if the batch is too small for the maximum allowed size of a payload
Example Payload:
{
"totalMessages": 50, // Number of total messages to send, if not defined it will be set to 1
"batchOf": 5, // send the total message in how many batches, if not defined it will be set to 1
"waitBetweenBatchesInMilli": 500, // wait between any batches, if not defined it will be 0
"template": { // Message template
"label": "example",
"correlationId": "test",
"contentType": "application/json",
"data": {
"key": "value2"
},
"userProperties": {
"name": "test message2"
}
}
}
Returns all the subscriptions in the specific topic
Creates a subscription in the specific topic
Example Payload:
{
"name": "wiretap",
"topicName": "example",
"maxDeliveryCount": 5,
"forward": {
"to": "otherTopic",
"in": "Topic"
},
"forwardDeadLetter": {
"to": "otherQueue",
"in": "Queue"
},
"rules": [
{
"name": "example_rule",
"sqlFilter": "2=2",
"sqlAction": "SET A='one'"
}
],
"options":{
"autoDeleteOnIdle": "24h",
"defaultMessageTimeToLive": "1d",
"lockDuration": "30s",
"enableBatchedOperation": true,
"deadLetteringOnMessageExpiration": false,
"requireSession": false
}
}
Returns a subscription detail from a specific topic
Deletes a subscription from a specific topic
Gets the dead letters from a subscription in a topic
Query Attributes
qty, integer: amount of messages to collect, defaults to all with a maximum of 100 messages
peek, bool: sets the collection mode to peek, messages will remain in the subscription, defaults to false
Gets the dead letters from a subscription in a topic
Query Attributes
qty, integer: amount of messages to collect, defaults to all with a maximum of 100 messages
peek, bool: sets the collection mode to peek, messages will remain in the subscription, defaults to false
Gets all the rules in a subscription
Creates a rule in a subscription
Example Payload:
{
"name": "example_rule",
"sqlFilter": "2=2",
"sqlAction": "SET A='one'"
}
Gets the details of a specific rule in a subscription
Deletes a specific rule in a subscription
Returns all the queues in the namespace
Creates a queue in the namespace
Example Payload:
{
"name": "example",
"maxDeliveryCount": 5,
"forward": {
"to": "otherTopic",
"in": "Topic"
},
"forwardDeadLetter": {
"to": "otherQueue",
"in": "Queue"
},
"options": {
"autoDeleteOnIdle": "24h",
"enableDuplicateDetection": "30m",
"maxSizeInMegabytes": 10,
"defaultMessageTimeToLive": "1d",
"lockDuration": "30s",
"supportOrdering": true,
"enablePartitioning": true,
"requireSession": false,
"deadLetteringOnMessageExpiration": false
}
}
Returns the details of a specific queue in the namespace
Deletes a specific queue from the namespace, this will also delete any subscriptions and messages in the same topic
Sends a message to the specific queue
Example Payload:
{
"label": "example",
"correlationId": "test",
"contentType": "application/json",
"data": {
"key": "value"
},
"userProperties": {
"name": "test message"
}
}
Sends bulk messages to the specific queue
Example Payload:
{
"messages": [
{
"label": "example",
"correlationId": "test",
"contentType": "application/json",
"data": {
"key": "value1"
},
"userProperties": {
"name": "test message1"
}
},
{
"label": "example",
"correlationId": "test",
"contentType": "application/json",
"data": {
"key": "value2"
},
"userProperties": {
"name": "test message2"
}
}
]
}
Sends a templated bulk messages to the specific queue, it can set a wait time between batches
You can define in how many batches you want to send the amount of message and a wait time between each batches.
Attention: if the volume of messages is big, the messages will be split in batches automatically, this also happens if the batch is too small for the maximum allowed size of a payload
Example Payload:
{
"totalMessages": 50, // Number of total messages to send, if not defined it will be set to 1
"batchOf": 5, // send the total message in how many batches, if not defined it will be set to 1
"waitBetweenBatchesInMilli": 500, // wait between any batches, if not defined it will be 0
"template": { // Message template
"label": "example",
"correlationId": "test",
"contentType": "application/json",
"data": {
"key": "value2"
},
"userProperties": {
"name": "test message2"
}
}
}
Gets the dead letters from a queue
Query Attributes
qty, integer: amount of messages to collect, defaults to all with a maximum of 100 messages
peek, bool: sets the collection mode to peek, messages will remain in the subscription, defaults to false
Gets the dead letters from a queue
Query Attributes
qty, integer: amount of messages to collect, defaults to all with a maximum of 100 messages
peek, bool: sets the collection mode to peek, messages will remain in the subscription, defaults to false
This will list all topics in a namespace
servicebus.exe topic list
This will create a topic in a namespace
servicebus.exe topic create --name="topic_name"
This will delete a topic and all subscriptions in a namespace
servicebus.exe topic delete --name="topic_name"
servicebus.exe topic list-subscriptions --topic="example.topic"
This will create a subscription to a specific topic in a namespace
servicebus.exe topic create-subscription --name="topic_name" --subscription="name_of_subscription"
Possible flags:
--forward-to
this will create a message forwarding rule in the subscription, the format is topic|queue
:[target_name]
Examples:
servicebus.exe topic create-subscription --name="new.topic" --subscription="fwd-example" --forward-to="topic:example.topic"
in this case it will forward all messages arriving to the topic new.topic to the topic example.topic
--forward-deadletter-to
this will create a dead letter forwarding rule in the subscription, the format is topic|queue
:[target_name]
Examples:
servicebus.exe topic create-subscription --name="new.topic" --subscription="fwd-example" --forward-deadletter-to="topic:example.topic"
in this case it will forward all dead letters in the topic new.topic to the topic example.topic
--with-rule
this will create a sql filter/action rule in the subscription, the format is rule_name:sql_filter_expression:sql_action_expression
Examples:
servicebus.exe topic create-subscription --name="new.topic" --subscription="rule-example" --with-rule="example_rule:1=1"
in this example it will create a sql filter 1=1 rule named example_rule
servicebus.exe topic create-subscription --name="new.topic" --subscription="rule-example" --with-rule="example_rule:1=1:SET sys.label='example.com'"
in this example it will create a sql filter 1=1 and a action SET sys.label='example.com' named example_rule
This will delete a topic subscription for a topic in a namespace
servicebus.exe topic delete-subscription --name="topic.name" --subscription="subscription.name"
servicebus.exe topic subscribe --topic="topic.name" --wiretap --peek
Possible flags:
--topic
Name of the topic you want to subscribe, it can be repeated to get multiple subscribers
--subscription
Name of the subscriptio you want to subscribe, if you use the --wiretap this flag will not be taken into account
--wiretap
this will create a wiretap subscription in that topic as a catch all
--peek
this will not delete the messages from the subscription
Examples:
Single Subscriber creating a wiretap
servicebus.exe topic subscribe --topic="example.topic" --wiretap
Multiple Subscriber creating a wiretap
servicebus.exe topic subscribe --topic="example.topic1" --topic="example.topic2" --wiretap
servicebus.exe topic send --topic="topic.name"
Possible flags:
--topic
Name of the topic where to send the message
--file
File path with the MessageRequest entity to send, use this instead on inline --body flag
--body
Message body in json (please escape the json correctly as this is validated)
--label
Message Label
--property
Add a User property to the message, this flag can be repeated to add more than one property. format: the format will be [key]:[value]
Examples:
servicebus.exe topic send --topic="example.topic" --body='{\"example\":\"document\"}' --label="ExampleLabel"
This will list all topics in a namespace
servicebus.exe topic list
This will create a Queue in a Namespace
servicebus.exe queue create --name="queue.name"
Possible flags:
--forward-to
this will create a message forwarding rule in the queue, the format is topic|queue
:[target_name]
Examples:
servicebus.exe queue create --name="new.queue" --forward-to="topic:example.topic"
in this case it will forward all messages arriving to the queue new.queue to the topic example.topic
--forward-deadletter-to
this will create a dead letter forwarding rule in the queue, the format is topic|queue
:[target_name]
Examples:
servicebus.exe topic create-subscription --name="new.queue" --forward-deadletter-to="topic:example.topic"
in this case it will forward all dead letters in the queue new.queue to the topic example.topic
This will delete a topic and all subscriptions in a namespace
servicebus.exe queue delete --name="queue.name"
servicebus.exe queue subscribe --queue="queue.name" --wiretap --peek
Possible flags:
--topic
Name of the topic you want to subscribe, it can be repeated to get multiple subscribers
--subscription
Name of the subscriptio you want to subscribe, if you use the --wiretap this flag will not be taken into account
--wiretap
this will create a wiretap subscription in that topic as a catch all
--peek
this will not delete the messages from the subscription
Examples:
Single Subscriber creating a wiretap
servicebus.exe queue subscribe --queue="example.queue" --wiretap
Multiple Subscriber creating a wiretap
servicebus.exe queue subscribe --queue="example.queue" --queue="example.queue" --wiretap
servicebus.exe queue send --queue="queue.name"
Possible flags:
--queue
Name of the queue where to send the message
--file
File path with the MessageRequest entity to send, use this instead on inline --body flag
--body
Message body in json (please escape the json correctly as this is validated)
--label
Message Label
--property
Add a User property to the message, this flag can be repeated to add more than one property. format: the format will be [key]:[value]
Examples:
servicebus.exe queue send --queue="example.queue" --body='{\"example\":\"document\"}' --label=ExampleLabel