Search code examples
javaazurequeueservicebus

Java Azure ServiceBusService listQueues() capped at 100 queues?


I'm using the Azure SDK in Eclipse, and I'm attempting to retrieve a list of all the queues associated with a service bus. I'm able to properly connect to the service bus, but when I call listQueues it only returns the first 100 queues (there's about 130)

ListQueuesOptions options = new ListQueuesOptions();

    options.setTop(200);
    options.setSkip(0);

    System.out.println(options.getTop());

    ListQueuesResult queuesResult = serviceBusContract.listQueues(options);
    List<QueueInfo> list = queuesResult.getItems();

    for (QueueInfo info : list)
    {
        System.out.println("Queue name: " + info.getPath());
    }

It does seem like ListQueuesOptions is supposed to modify the way queues are retrieved, and it does. Setting top to 20 and skip to 0 gives the first 20, setting top to 40 and skip to 20 the second 20, and so on. But if I run the above code I still only print 100 queues. Is it limited at 100 for some reason?

I am aware that I can probably just keep calling listQueues in iterations of 100 and count to see if I've hit 100, and then run it again, but this is a really strange issue so I thought I'd ask since the documentation isn't very clear on this.

Thanks!


Solution

  • The maximum you can set for top is 100. You need ask for batched of 100 each time. Use skip to get the next batch.