I have an Apache Camel route and processor consuming from an ActiveMQ broker.
Route code -
@Component
public class MyRoute extends RouteBuilder {
private String mySubscription;
private MyProcessor myProcessor;
public MyRoute(@Value("${my.topic}") String mySubscription, MyProcessor myProcessor) {
this.mySubscription = mySubscription;
this.myProcessor = myProcessor;
}
@Override
public void configure() {
from(mySubscription)
.unmarshal().json(JsonLibrary.Jackson, MyDTO.class)
.bean(myProcessor, "process(${body})")
.end();
}
}
Processor code -
@Slf4j
@Component
@AllArgsConstructor
public class MyProcessor {
public void process(MyDTO dto) {
//code that calls HTTP URLs
}
}
Config is like below -
spring:
application:
name: my_listener
//Bean prefixes
pooledConnectionFactory:
maxConnections: 10
connectionFactory:
brokerURL: ${brokerURL}
redeliveryPolicy:
backOffMultiplier: 2.0
useExponentialBackOff: true
redeliveryDelay: 60000
maximumRedeliveries: 5
component:
forceSendOriginalMessage: true
concurrentConsumers: 15
//A bunch of HTTP URLs
brokerURL: <brokerURL>
On running listener locally and pointing VisualVM to the local ActiveMQ broker, I can see 15 threads with name containing the subscription name under VisualVM Threads tab. If I sent 4 messages, I see 4 different threads going to running state. I don't see any threads identifiable as the processor class object although there is one bean under processors in the MBeans tab. Calling getTotalExchanges() on that bean displays 4 = no of messages sent.
Does concurrentConsumers setting (15 here) only create 15 threads for consumption? Does processing through the processor class still happen sequentially? Or does each subscription thread invoke the processor object in its own thread making the processor logic multithreaded?