Reputation: 582
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
Upvotes: 5
Views: 2488
Reputation: 14378
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;
Upvotes: 2