2

I have the following routes:

<camelContext xmlns="http://camel.apache.org/schema/spring">
    <threadPoolProfile id="defaultProfile"
        defaultProfile="true" poolSize="100" maxPoolSize="200" />

    <route>
        <from uri="amq:example.MyQueue" />
        <setHeader headerName="myRoutingSlipHeader">
            <constant>amq:one#amq:two#amq:three#amq:four</constant>
        </setHeader>
        <log message="Makan" />
        <setExchangePattern pattern="InOut" />
        <routingSlip uriDelimiter="#">
            <header>myRoutingSlipHeader</header>
        </routingSlip>
        <setExchangePattern pattern="InOnly" />
        <log message="End: ${body}" />
    </route>

    <route>
        <from uri="amq:one" />
        <to uri="bean:helloBean?method=stepOne" />
    </route>

    <route>
        <from uri="amq:two" />
        <to uri="bean:helloBean?method=stepTwo" />
    </route>

    <route>
        <from uri="amq:three" />
        <to uri="bean:helloBean?method=stepThree" />
    </route>

    <route>
        <from uri="amq:four" />
        <to uri="bean:helloBean?method=stepFour" />
    </route>

    </camelContext>

<bean id="amq" class="org.apache.activemq.camel.component.ActiveMQComponent"
    p:brokerURL="tcp://localhost:61616" p:transacted="true"
    p:cacheLevelName="CACHE_CONSUMER" p:concurrentConsumers="20"
    p:maxConcurrentConsumers="500" p:idleConsumerLimit="10"
     />

Given that example.MyQueue is preloaded with 1000 messages, and each hello bean's step* methods takes 250ms, when I do camel:run, the performance is still bad. It prints "End: ..." each 1 secs in sequence not parallel. What would be the problem here?

In the following much simple case, I see a strange behavior. When there is no JMS producer putting messages into the queue, the printings happen in sequence. But when there is, the printings happen in parallel. What's the explanation?

<threadPoolProfile id="defaultProfile"
        defaultProfile="true" poolSize="100" maxPoolSize="200" />

<route>
  <from uri="amq:example.MyQueue" />
  <delay>
    <constant>1000</constant>
  </delay>
  <log message="End: ${body}" />
</route>

<bean id="amq" class="org.apache.activemq.camel.component.ActiveMQComponent"
    p:brokerURL="tcp://localhost:61616" p:transacted="true"
    p:cacheLevelName="CACHE_CONSUMER" p:concurrentConsumers="20"
    p:maxConcurrentConsumers="500" p:idleConsumerLimit="10"
     />

3 Answers 3

1

Try replacing

   <from uri="amq:example.MyQueue" />

with

   <from uri="amq:example.MyQueue?concurrentConsumers=200&amp;maxConcurrentConsumers=500" />
0

The routing slip runs in sequence, and yo do request/reply over JMS (eg the MEP is InOut) so processing one message would take

  • call amq:one = 250 millis (request/reply)
  • call amq:two = 250 millis (request/reply)
  • call amq:three = 250 millis (request/reply)
  • call amq:four = 250 millis (request/reply)

A total of 1 sec per message.

The AMQ route in < from > could process messages in parallel though. But each message would still take 1 second to process.

1
  • I know it. The problem is how to make it parallel?
    – sancho21
    Oct 4, 2013 at 7:56
0

I guess routingSlip pattern is synchronized. you need something asynchronized component to handle this. Please check this:http://camel.apache.org/async.html

Just one question, why you need set the ExchangePattern?

1
  • Without ExchangePattern, result from the bean invocations won't be reflected in the last log.
    – sancho21
    Oct 7, 2013 at 3:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.