Mirko
Mirko

Reputation: 1552

Camel will not process messages parallel for one consumer

In our setup we're using camel, jms, spring and hibernate and we have a lot of the same kind of messages. So they needs to be processed by one Processor, wich is created by Spring. But I can see, that the Processor runs only on once.

enter image description here

I inspected the threaddump and the logs too, so I can say now, it's a fact, that the software doesn't scale the right way.

So what I'm doing wrong? Thanks in advance.

public class MyRouteBuilder extends SpringRouteBuilder {

@Autowired
ApplicationContext context;

@Override
public void configure() throws Exception {
    final String endpointUri ="...."
    final RouteDefinition rd = this.from(endpointUri);
    final ThreadsDefinition td = rd.threads();
    td.process(this.context.getBean(MyProcessor.class));
}


@Component
public class MyProcessor implements Processor {
private final Logger log = LogManager.getLogger(this.getClass());

@Autowired
ApplicationContext context;

@PostConstruct
public void init() {
    // Do something
}

@Override
public void process(Exchange exchange) throws Exception {
    //Process the message and doing some stuff with the database
}

}

<camel:camelContext>
    <camel:package>tld.mycompany</camel:package>
    <camel:threadPool id="camelsThreadPool" poolSize="8"
        rejectedPolicy="CallerRuns" maxPoolSize="32" maxQueueSize="50000"
        threadName="CamelsThreadPool"></camel:threadPool>
</camel:camelContext>

Upvotes: 2

Views: 626

Answers (1)

Mirko
Mirko

Reputation: 1552

Thank you Claus - that was it.

Solution is to use the append the "?asyncConsumer=true" to the endpoint url.

Upvotes: 1

Related Questions