ServiceBusAdministrationAsyncClient Class
- java.
lang. Object - com.
azure. messaging. servicebus. administration. ServiceBusAdministrationAsyncClient
- com.
public final class ServiceBusAdministrationAsyncClient
An asynchronous client for managing a Service Bus namespace. Instantiated via ServiceBusAdministrationClientBuilder.
Sample: Create the async client
The follow code sample demonstrates the creation of the async administration client. The credential used in the following sample is DefaultAzureCredential
for authentication. It is appropriate for most scenarios, including local development and production environments. Additionally, we recommend using managed identity for authentication in production environments. You can find more information on different ways of authenticating and their corresponding credential types in the Azure Identity documentation.
// DefaultAzureCredential creates a credential based on the environment it is executed in.
TokenCredential credential = new DefaultAzureCredentialBuilder().build();
// 'fullyQualifiedNamespace' will look similar to "{your-namespace}.servicebus.windows.net"
ServiceBusAdministrationAsyncClient client = new ServiceBusAdministrationClientBuilder()
.credential(fullyQualifiedNamespace, new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
Sample: Create a queue
The following sample creates a queue with default values. Default values are listed in CreateQueueOptions().
// `.subscribe()` is a non-blocking call. It'll move onto the next
// instruction after setting up the `consumer` and `errorConsumer` callbacks.
client.createQueue("my-new-queue").subscribe(queue -> {
System.out.printf("Queue created. Name: %s. Lock Duration: %s.%n",
queue.getName(), queue.getLockDuration());
}, error -> {
System.err.println("Error creating queue: " + error);
});
Sample: Edit an existing subscription
The following code sample demonstrates updating an existing subscription. Users should fetch the subscription's properties, modify the properties, and then pass the object to update method.
// To update the subscription we have to:
// 1. Get the subscription info from the service.
// 2. Update the SubscriptionProperties we want to change.
// 3. Call the updateSubscription() with the updated object.
// `.subscribe()` is a non-blocking call. It'll move onto the next
// instruction after setting up the `consumer` and `errorConsumer` callbacks.
client.getSubscription("my-topic", "my-subscription")
.flatMap(subscription -> {
System.out.println("Original delivery count: " + subscription.getMaxDeliveryCount());
// Updating it to a new value.
subscription.setMaxDeliveryCount(5);
// Persisting the updates to the subscription object.
return client.updateSubscription(subscription);
})
.subscribe(subscription -> {
System.out.printf("Subscription updated. Name: %s. Delivery count: %s.%n",
subscription.getSubscriptionName(), subscription.getMaxDeliveryCount());
}, error -> {
System.err.println("Error updating subscription: " + error);
});
Sample: List all queues
The code sample below lists all the queues in the Service Bus namespace.
// `.subscribe()` is a non-blocking call. It'll move onto the next
// instruction after setting up the `consumer` and `errorConsumer` callbacks.
client.listQueues().subscribe(queue -> {
System.out.printf("Queue [%s]. Lock Duration: %s.%n",
queue.getName(), queue.getLockDuration());
}, error -> {
System.err.println("Error fetching queues: " + error);
});
Sample: Delete queue
The code sample below demonstrates deleting an existing queue.
// `.subscribe()` is a non-blocking call. It'll move onto the next
// instruction after setting up the `consumer`, `errorConsumer`, `completeConsumer` callbacks.
asyncClient.deleteQueue("my-existing-queue").subscribe(unused -> {
}, error -> {
System.err.println("Error deleting queue: " + error);
}, () -> {
System.out.println("Deleted queue.");
});
Method Summary
Methods inherited from java.lang.Object
Method Details
createQueue
public Mono
Creates a queue with the given name.
Parameters:
Returns:
createQueue
public Mono
Creates a queue with the CreateQueueOptions and given queue name.
Parameters:
Returns:
createQueueWithResponse
public Mono
Creates a queue and returns the created queue in addition to the HTTP response.
Parameters:
Returns:
createRule
public Mono
Creates a rule under the given topic and subscription
Parameters:
Returns:
createRule
public Mono
Creates a rule with the CreateRuleOptions.
Parameters:
Returns:
createRuleWithResponse
public Mono
Creates a rule and returns the created rule in addition to the HTTP response.
Parameters:
Returns:
createSubscription
public Mono
Creates a subscription with the given topic and subscription names.
Parameters:
Returns:
createSubscription
public Mono
Creates a subscription with the CreateSubscriptionOptions.
Parameters:
Returns:
createSubscription
public Mono
Creates a subscription with a default rule using CreateSubscriptionOptions and CreateRuleOptions.
Parameters:
Returns:
createSubscriptionWithResponse
public Mono
Creates a subscription and returns the created subscription in addition to the HTTP response.
Parameters:
Returns:
createSubscriptionWithResponse
public Mono
Creates a subscription with default rule and returns the created subscription in addition to the HTTP response.
Parameters:
Returns:
createTopic
public Mono
Creates a topic with the given name.
Parameters:
Returns:
createTopic
public Mono
Creates a topic with the CreateTopicOptions.
Parameters:
Returns:
createTopicWithResponse
public Mono
Creates a topic and returns the created topic in addition to the HTTP response.
Parameters:
Returns:
deleteQueue
public Mono
Deletes a queue the matching queueName
.
Parameters:
Returns:
deleteQueueWithResponse
public Mono
Deletes a queue the matching queueName
and returns the HTTP response.
Parameters:
Returns:
deleteRule
public Mono
Deletes a rule the matching ruleName
.
Parameters:
Returns:
deleteRuleWithResponse
public Mono
Deletes a rule the matching ruleName
and returns the HTTP response.
Parameters:
Returns:
deleteSubscription
public Mono
Deletes a subscription the matching subscriptionName
.
Parameters:
Returns:
deleteSubscriptionWithResponse
public Mono
Deletes a subscription the matching subscriptionName
and returns the HTTP response.
Parameters:
Returns:
deleteTopic
public Mono
Deletes a topic the matching topicName
.
Parameters:
Returns:
deleteTopicWithResponse
public Mono
Deletes a topic the matching topicName
and returns the HTTP response.
Parameters:
Returns:
getNamespaceProperties
public Mono
Gets information about the Service Bus namespace.
Returns:
getNamespacePropertiesWithResponse
public Mono
Gets information about the Service Bus namespace along with its HTTP response.
Returns:
getQueue
public Mono
Gets information about the queue.
Parameters:
Returns:
getQueueExists
public Mono
Gets whether or not a queue with queueName
exists in the Service Bus namespace.
Parameters:
Returns:
getQueueExistsWithResponse
public Mono
Gets whether or not a queue with queueName
exists in the Service Bus namespace.
Parameters:
Returns:
getQueueRuntimeProperties
public Mono
Gets runtime properties about the queue.
Parameters:
Returns:
getQueueRuntimePropertiesWithResponse
public Mono
Gets runtime properties about the queue along with its HTTP response.
Parameters:
Returns:
getQueueWithResponse
public Mono
Gets information about the queue along with its HTTP response.
Parameters:
Returns:
getRule
public Mono
Gets a rule from the service namespace. Only following data types are deserialized in Filters and Action parameters - string, int, long, boolean, double, and OffsetDateTime. Other data types would return its string value.
Parameters:
Returns:
getRuleWithResponse
public Mono
Gets a rule from the service namespace. Only following data types are deserialized in Filters and Action parameters - string, int, long, bool, double, and OffsetDateTime. Other data types would return its string value.
Parameters:
Returns:
getSubscription
public Mono
Gets information about the queue.
Parameters:
Returns:
getSubscriptionExists
public Mono
Gets whether or not a subscription within a topic exists.
Parameters:
Returns:
getSubscriptionExistsWithResponse
public Mono
Gets whether or not a subscription within a topic exists.
Parameters:
Returns:
getSubscriptionRuntimeProperties
public Mono
Gets runtime properties about the subscription.
Parameters:
Returns:
getSubscriptionRuntimePropertiesWithResponse
public Mono
Gets runtime properties about the subscription.
Parameters:
Returns:
getSubscriptionWithResponse
public Mono
Gets information about the subscription along with its HTTP response.
Parameters:
Returns:
getTopic
public Mono
Gets information about the topic.
Parameters:
Returns:
getTopicExists
public Mono
Gets whether or not a topic with topicName
exists in the Service Bus namespace.
Parameters:
Returns:
getTopicExistsWithResponse
public Mono
Gets whether or not a topic with topicName
exists in the Service Bus namespace.
Parameters:
Returns:
getTopicRuntimeProperties
public Mono
Gets runtime properties about the topic.
Parameters:
Returns:
getTopicRuntimePropertiesWithResponse
public Mono
Gets runtime properties about the topic with its HTTP response.
Parameters:
Returns:
getTopicWithResponse
public Mono
Gets information about the topic along with its HTTP response.
Parameters:
Returns:
listQueues
public PagedFlux
Fetches all the queues in the Service Bus namespace.
Returns:
listRules
public PagedFlux
Fetches all the rules for a topic and subscription.
Parameters:
Returns:
listSubscriptions
public PagedFlux
Fetches all the subscriptions for a topic.
Parameters:
Returns:
topicName
.listTopics
public PagedFlux
Fetches all the topics in the Service Bus namespace.
Returns:
updateQueue
public Mono
Updates a queue with the given QueueProperties. The QueueProperties must be fully populated as all of the properties are replaced. If a property is not set the service default value is used. The suggested flow is:
- getQueue(String queueName)
- Update the required elements.
- Pass the updated description into this method.
There are a subset of properties that can be updated. More information can be found in the links below. They are:
- setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive)
- setLockDuration(Duration lockDuration)
- setDuplicateDetectionHistoryTimeWindow(Duration duplicateDetectionHistoryTimeWindow)
- setMaxDeliveryCount(Integer maxDeliveryCount)
Parameters:
Returns:
updateQueueWithResponse
public Mono
Updates a queue with the given QueueProperties. The QueueProperties must be fully populated as all of the properties are replaced. If a property is not set the service default value is used. The suggested flow is:
- getQueue(String queueName)
- Update the required elements.
- Pass the updated description into this method.
There are a subset of properties that can be updated. More information can be found in the links below. They are:
- setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive)
- setLockDuration(Duration lockDuration)
- setDuplicateDetectionHistoryTimeWindow(Duration duplicateDetectionHistoryTimeWindow)
- setMaxDeliveryCount(Integer maxDeliveryCount)
Parameters:
Returns:
updateRule
public Mono
Updates a rule with the given RuleProperties. The RuleProperties must be fully populated as all the properties are replaced. If a property is not set the service default value is used. The suggested flow is:
- getRule(String topicName, String subscriptionName, String ruleName)
- Update the required elements.
- Pass the updated description into this method.
Parameters:
Returns:
updateRuleWithResponse
public Mono
Updates a rule with the given RuleProperties. The RuleProperties must be fully populated as all the properties are replaced. If a property is not set the service default value is used. The suggested flow is:
- getRule(String topicName, String subscriptionName, String ruleName)
- Update the required elements.
- Pass the updated description into this method.
Parameters:
Returns:
updateSubscription
public Mono
Updates a subscription with the given SubscriptionProperties. The SubscriptionProperties must be fully populated as all of the properties are replaced. If a property is not set the service default value is used. The suggested flow is:
- getSubscription(String topicName, String subscriptionName)
- Update the required elements.
- Pass the updated description into this method.
There are a subset of properties that can be updated. More information can be found in the links below. They are:
- setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive)
- setLockDuration(Duration lockDuration)
- setMaxDeliveryCount(int maxDeliveryCount)
Parameters:
Returns:
updateSubscriptionWithResponse
public Mono
Updates a subscription with the given SubscriptionProperties. The SubscriptionProperties must be fully populated as all of the properties are replaced. If a property is not set the service default value is used. The suggested flow is:
- getSubscription(String topicName, String subscriptionName)
- Update the required elements.
- Pass the updated description into this method.
There are a subset of properties that can be updated. More information can be found in the links below. They are:
- setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive)
- setLockDuration(Duration lockDuration)
- setMaxDeliveryCount(int maxDeliveryCount)
Parameters:
Returns:
updateTopic
public Mono
Updates a topic with the given TopicProperties. The TopicProperties must be fully populated as all of the properties are replaced. If a property is not set the service default value is used. The suggested flow is:
- getTopic(String topicName)
- Update the required elements.
- Pass the updated description into this method.
There are a subset of properties that can be updated. More information can be found in the links below. They are:
- setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive)
- setDuplicateDetectionHistoryTimeWindow(Duration duplicateDetectionHistoryTimeWindow)
Parameters:
Returns:
updateTopicWithResponse
public Mono
Updates a topic with the given TopicProperties. The TopicProperties must be fully populated as all of the properties are replaced. If a property is not set the service default value is used. The suggested flow is:
- getTopic(String topicName)
- Update the required elements.
- Pass the updated description into this method.
There are a subset of properties that can be updated. More information can be found in the links below. They are:
- setDefaultMessageTimeToLive(Duration defaultMessageTimeToLive)
- setDuplicateDetectionHistoryTimeWindow(Duration duplicateDetectionHistoryTimeWindow)
Parameters:
Returns:
Applies to
Azure SDK for Java