3
votes

I'm refering this sample for working with Azure Service Bus https://github.com/Microsoft/azure-spring-boot/tree/master/azure-spring-boot-samples/azure-servicebus-spring-boot-sample

I'm able to get the sample working without any issues.

1- As an extension to it, I now have multiple Queues created in with in same service bus namespace. And I would like to read and post messages to each of the queues. With the azure-servicebus-spring-boot-starter project how can I specifiy multiple queues to work with.

2- I would like to listen to a queue say every 10 second. For the same in the sprint boot application I enabled scheduling. In the components method that get scheduled every 10 second, as of now I'm registering message handler .

queueClient.registerMessageHandler(new MessageHandler(),options);

Can registering again & again have issues? If so how to code for the same.

thanks

1
That is why I hate microsoft products, they are very low quality and no support at all. You see that question is here for almost 1.5 year, no one is taking care of it. I have the same problem and after loosing my precious weekend trying to solve with new versions of libraries such as azure-messaging-servicebus, nothing is solved. Worst that azure-messaging-servicebus library is beta version now and does not have a formal release of that crap. What made me to spend time trying to work on it, and then realise that it never worked before. I hate who does this sort of work.rod.poli.diniz

1 Answers

0
votes

when you have multiple queues, you will not be able to use the auto configuration properties to grab the queue client instead you will have to create your @Configuration class and then create a client per queue name; for example.,

@Bean
public QueueClient queueName1(@Value("connection-string") String connectionString, @Value("queueName1") String queueName) { 
       ...
       return new QueueClient(new ConnectionStringBuilder(connectionString, queueName),
            ReceiveMode.PEEKLOCK);
       ...
 }

@Bean
public QueueClient queueName2(@Value("connection-string") String connectionString, @Value("queueName2") String queueName) { 
       ...
       return new QueueClient(new ConnectionStringBuilder(connectionString, queueName),
            ReceiveMode.PEEKLOCK);
       ...
 }

and then in your service code, refer the with

   @Qualifier("queueName1") QueueClient queueClient1;
   @Qualifier("queueName2") QueueClient queueClient2;