I'm using Camel with Activemq to implement a simple queue where I can enqueue 
some requests (a simple xml) to be consumed  latter. To consume I use the InOut 
ExchangePattern and PoolEnrich.

My issue is the lack of performance during the dequeue process. When I POST 
some requests it  has very nice results (see below) but when I do GET the 
performance is very low.

Any ideias of what could be the problem? Is this Activemq problem, or is it 
related to the InOut pattern?

My Software versions:
Apache Camel 2.8.2
Activemq 5.5.1

My Camel-context.xml (simplified):
...
<broker useJmx="true" persistent="true" 
xmlns="http://activemq.apache.org/schema/core";>
    <persistenceAdapter>
        <kahaDB directory="/camel/data/mom" checkpointInterval="5000" 
journalMaxFileLength="256mb" enableJournalDiskSyncs="false" 
ignoreMissingJournalfiles="true"/>
    </persistenceAdapter>
    <transportConnectors>
        <transportConnector uri="tcp://localhost:61616"/>
    </transportConnectors>
</broker>
    
<bean id="activemq" 
class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="brokerURL" value="tcp://localhost:61616"/>
</bean>
 
<endpoint id="my-queue-endpoint" 
uri="activemq:queue:my-queue?concurrentConsumers=2&amp;transacted=false"/>

MyQueue.java (simplified):

Public void configure(){
        ...
        
        // Enqueue
        .when(and(header("CamelHttpUri ").regex(".*/my-queue.*"), 
header("CamelHttpMethod").isEqualTo("POST")))
                .inOnly("my-queue-endpoint")

        // Dequeue
        .when(and(header("CamelHttpUri").regex(".*/my-queue.*"), 
header("CamelHttpMethod").isEqualTo("GET")))
                .setExchangePattern(ExchangePattern.InOut)    // .inOut() is 
deprecated in 2.8.2 Camel version
                 .pollEnrich("my-queue-endpoint", 5000, new 
AggregationStrategy() {
                        public Exchange aggregate(Exchange oldExchange, 
Exchange newExchange) {
                                return newExchange;
                        }})
        ...
}

My results using Apache Benchmark:
10 000 requests, 1 concurrency level and Keep-alive active

POST:
[root@server camel]# ab -n 10000 -c 1 -k -p simple_file.xml -T 
"application/xml" http://localhost:8080/my-queue
...
Requests per second:    1281.49 [#/sec] (mean)
Time per request:       0.780 [ms] (mean)

GET: 
[root@server camel]# ab -n 10000 -c 1 -k -T "application/xml" 
http://localhost:8080/my-queue
...
Requests per second:    26.90 [#/sec] (mean)
Time per request:       37.173 [ms] (mean)

Best regards,
Carlos Figueiredo

Reply via email to