Reputation: 33
I have 2 jmsliteners setup like this in spring boot:
@EnableJms
@JmsListener(id= "A1", destination = "dest1", containerFactory = "factory1")
@JmsListener(id= "A2", destination = "dest2", containerFactory = "factory1")
public void onMessage(String request) {
//some processing
}
@Bean(name = "factory1")
public JmsListenerContainerFactory jmsListenerContainerFactory(ConnectionFactory cachingConnectionFactory){
DefaultJmsListenerContainerFactory jmsListenerContainerFactory = new DefaultJmsListenerContainerFactory();
jmsListenerContainerFactory.setConnectionFactory(cachingConnectionFactory);
jmsListenerContainerFactory.setConcurrency("2-10");
jmsListenerContainerFactory.setSessionTransacted(true);
jmsListenerContainerFactory.setSessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE);
return jmsListenerContainerFactory;
}
Since 2 jmslisteners have different id but share same containerFactory, does these 2 jmslisteners share a same thread pool?
I.E, if I have 100 messages at dest1 and 1 messages at dest2, is it possible that all thread available are going to be taken up by listener a1 , and listener a2 wont be able to run till most of messages at a1 are consumed?
Ideally these 2 shall run in parallel and I do not want to create some async future tasks in my processing.
Upvotes: 2
Views: 1004
Reputation: 174554
They are independent; by default they each use a separate SimpleAsyncTaskExecutor
.
You can configure the factory with a TaskExecutor
and the containers will use the same one, but, if it's a pooled executor, it must have enough threads to support the total max concurrency of all listeners.
Upvotes: 5