Class ServiceBusAdministrationAsyncClient

java.lang.Object
com.azure.messaging.servicebus.administration.ServiceBusAdministrationAsyncClient

public final class ServiceBusAdministrationAsyncClient extends Object
An asynchronous client for managing a Service Bus namespace. Instantiated via ServiceBusAdministrationClientBuilder.

Create a queue

 // `.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);
     });
 

Edit an existing subscription

 // 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);
         });
 

List all queues

 // `.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);
     });
 
See Also: