Reputation: 13
I use concurrentConsumers=20
property for JMS endpoint in my route, but I have got different number of consumers.
My route is:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<bean id="artemisConnectionFactory" class="org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory">
<argument index="0" value="tcp://localhost:61616"/>
<argument index="1" value="karaf"/>
<argument index="2" value="karaf"/>
</bean>
<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="artemisConnectionFactory"/>
</bean>
<camelContext id="test-jms-context" xmlns="http://camel.apache.org/schema/blueprint">
<route id="messages-consumer-route" autoStartup="true">
<from uri="jms:queue:concurrent1?concurrentConsumers=20"/>
<log loggingLevel="INFO" message="start"/>
<delay>
<constant>10000</constant>
</delay>
<log loggingLevel="INFO" message="finish"/>
</route>
</camelContext>
</blueprint>
But on route/context/bundle restart I have got a random number of consuming threads: from 1 to 20 (concurrent consumers value).
I've tested on Camel 3.4.5 and 3.21.0.SNAPSHOT with both ActiveMQ Artemis 2.19.0 and 2.28.0.
Why number of threads not matches exactly to concurrentConsumers
property?
Upvotes: 1
Views: 267
Reputation: 35122
I imagine that Camel will only create as many consumers as absolutely necessary to consume the messages. This will almost certainly be impacted by the flow control on the consumers. I recommend specifying consumerWindowSize=0
on your connection URL, e.g.:
tcp://localhost:61616?consumerWindowSize=0
This will ensure that one consumer doesn't prefetch a lot of messages and starve other consumers. That would increase the chances that more consumers are created.
Upvotes: 0