You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by boday <bo...@vektrel.com> on 2009/11/30 19:40:59 UTC

performance issues with JMS transacted route...

I have the following JMS transacted route...  

from("activemq:start?maxConcurrentConsumers=50&transacted=true")
.process(new ValidateMessage())
.process(new SaveToDatabase())
.to("activemq:finishedQueue"); 

I assumed there would be a bit of overhead with using transactions, but my
route goes from ~250 message/second to ~50 messages/second when I add the
"?transacted=true" to it (no other changes).  

I've seen similar performance hits when I added xpath (content based
routing, etc) to my route (so I worked around it).  My processor
"SaveToDatabase" does connect to a database (spring JDBC stored procedure
call), but is not transactional itself.  

Overall, my goal is to simply make my route guarantee messaging (server
crashes, restarts, etc) and maintain its high throughput.  Any other ideas?

Has anyone else seen this type of drop in throughput with transacted
messages?  I'm hoping it has something to do with the Tx manager
configuration or something.  I'm using the default tx.xml file that shipped
with Servicemix 3.3.1/Camel 2.0...

note: this is a followup to another thread
(http://old.nabble.com/guaranteed-message-processing-question...-to26202573.html#a26270332)

thanks...

-----
Ben - Senior Consultant

-- 
View this message in context: http://old.nabble.com/performance-issues-with-JMS-transacted-route...-tp26579725p26579725.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: performance issues with JMS transacted route...

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Dec 3, 2009 at 1:27 AM, boday <bo...@vektrel.com> wrote:
>
> Claus, I tried the following...
>
> -disabled the message groups
> -setup the Spring JmsTransactionManager as follows...
>
> ...
> ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy();
> prefetchPolicy.setQueuePrefetch(50);   //tried 0, 10, 1000, 5000
>
> ActiveMQConnectionFactory connFactory = new ActiveMQConnectionFactory();
> connFactory.setBrokerURL(brokerURL);
> connFactory.setPrefetchPolicy(prefetchPolicy);
>
> PooledConnectionFactory pcf = new PooledConnectionFactory(connFactory);
> pcf.setMaxConnections(50);
>
> JmsTransactionManager jmsTransactionManager = new JmsTransactionManager();
> jmsTransactionManager.setConnectionFactory(pcf);
>
> JmsComponent component = ActiveMQComponent.jmsComponentTransacted(pcf,
> jmsTransactionManager);
> component.getConfiguration().setConcurrentConsumers(50);
> this.getContext().addComponent("activemq", component);
> ...
>
> But, I'm still see the same result.  It appears to be throttling down my
> HTTP endpoint (maybe including it in the transaction scope??) as I'm only
> able to receive ~10 msg/second now (vs. ~250 w/o a transacted route) into my
> inbound queue.  They are being processed from the queue as fast as they are
> coming in...just coming in too slow.
>
> Any other thoughts on this?
>

I dont know why your http endpoint is throttled down.

You can test just that JMS -> DB route you shown in the first mail and
just use a camel client to send messages to the JMS queue as fast as
you can.
Then you can turn on/off transaction to see if there is a speed degrade.



> thanks again...
>
> -----
> Ben - Senior Consultant
>
> --
> View this message in context: http://old.nabble.com/performance-issues-with-JMS-transacted-route...-tp26579725p26618905.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: performance issues with JMS transacted route...

Posted by boday <bo...@vektrel.com>.
Claus, I tried the following...

-disabled the message groups
-setup the Spring JmsTransactionManager as follows...

...
ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy();
prefetchPolicy.setQueuePrefetch(50);   //tried 0, 10, 1000, 5000

ActiveMQConnectionFactory connFactory = new ActiveMQConnectionFactory();
connFactory.setBrokerURL(brokerURL);
connFactory.setPrefetchPolicy(prefetchPolicy);

PooledConnectionFactory pcf = new PooledConnectionFactory(connFactory);
pcf.setMaxConnections(50);

JmsTransactionManager jmsTransactionManager = new JmsTransactionManager();
jmsTransactionManager.setConnectionFactory(pcf);

JmsComponent component = ActiveMQComponent.jmsComponentTransacted(pcf,
jmsTransactionManager);
component.getConfiguration().setConcurrentConsumers(50);
this.getContext().addComponent("activemq", component);
...

But, I'm still see the same result.  It appears to be throttling down my
HTTP endpoint (maybe including it in the transaction scope??) as I'm only
able to receive ~10 msg/second now (vs. ~250 w/o a transacted route) into my
inbound queue.  They are being processed from the queue as fast as they are
coming in...just coming in too slow.  

Any other thoughts on this?

thanks again...

-----
Ben - Senior Consultant

-- 
View this message in context: http://old.nabble.com/performance-issues-with-JMS-transacted-route...-tp26579725p26618905.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: performance issues with JMS transacted route...

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I wonder that JMSXGroupID does affect performance.

> amq.setAcknowledgementModeName("AUTO_ACKNOWLEDGE");
That one should be TRANSACTED

And there should be a setter for transacted on the AMQ as well.
AMQComponent ... setTransacted(true);

Use Spring JmsTransactionManager


btw Camel in Action, chapter 9 will cover transaction, which I am
currently working on.
Chapter 9 will be in MEAP in about 2 weeks.



On Tue, Dec 1, 2009 at 6:14 PM, boday <bo...@vektrel.com> wrote:
>
> thanks Claus, that is exactly what I wanted to hear...
>
> here is my setup...any advice would be appreciated...
>
> JDK 1.6, ServiceMix 3.3.1, Camel 2.0 (patched the
> /hotdeploy/servicemix-camel.zip)
> AMQ 5.2 (persistent, small 1k messages, 250+ msg/second, no XA Tx)
> Jenks AMQ pool 2.1, Spring 2.5.6
>
> http://old.nabble.com/file/p26594255/tx.xml tx.xml
> http://old.nabble.com/file/p26594255/activemq.xml activemq.xml
> http://old.nabble.com/file/p26594255/servicemix.xml servicemix.xml
>
> // setup the ActiveMQ component
> ActiveMQConnectionFactory queueConnectionFactory = new
> ActiveMQConnectionFactory("tcp://localhost:61616");
> PooledConnectionFactory pcf = new
> PooledConnectionFactory(queueConnectionFactory);
> pcf.setMaxConnections(50);
>
> ActiveMQComponent amq =
> ActiveMQComponent.activeMQComponent("tcp://localhost:61616");
> amq.setConnectionFactory(pcf);
> amq.setMaxMessagesPerTask(-1);
> amq.setMaxConcurrentConsumers(50);
> amq.setCacheLevelName("CACHE_CONSUMER");
> amq.setAcknowledgementModeName("AUTO_ACKNOWLEDGE");
> getContext().addComponent("activemq", amq);
>
> My route does the following...
>
> @Produce(uri = "activemq:inbound")
> ProducerTemplate inboundProducer;
>
> @Consume(uri = "jetty:http://0.0.0.0:9001/inboundMessage/")
> @InOnly
> public void onMessage(String message)
> {
>    String addressID = getAttributeValueFromXML(message,"addr");
>
>    //set the JMSXGroupID appropriately to enable AMQ MessageGroups
> (guaranteed ordering)
>    inboundProducer.sendBodyAndHeader(message, "JMSXGroupID", addressID);
> }
>
> from("activemq:inbound?transacted=true&maxConcurrentConsumers=50")
> .process(new ValidateMessage())
> .process(new SaveToDatabase())
> .to("activemq:topic:outbound");
>
> Questions...
>
> how do I set the prefetch buffer?
> what Tx manager should I be using and how do I set it up?
> should I be using newer versions of any components?
>
> thanks again...
>
>
>
>
> -----
> Ben - Senior Consultant
>
> --
> View this message in context: http://old.nabble.com/performance-issues-with-JMS-transacted-route...-tp26579725p26594255.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: performance issues with JMS transacted route...

Posted by boday <bo...@vektrel.com>.
thanks Claus, that is exactly what I wanted to hear...

here is my setup...any advice would be appreciated...

JDK 1.6, ServiceMix 3.3.1, Camel 2.0 (patched the
/hotdeploy/servicemix-camel.zip)
AMQ 5.2 (persistent, small 1k messages, 250+ msg/second, no XA Tx)
Jenks AMQ pool 2.1, Spring 2.5.6

http://old.nabble.com/file/p26594255/tx.xml tx.xml 
http://old.nabble.com/file/p26594255/activemq.xml activemq.xml 
http://old.nabble.com/file/p26594255/servicemix.xml servicemix.xml 

// setup the ActiveMQ component
ActiveMQConnectionFactory queueConnectionFactory = new
ActiveMQConnectionFactory("tcp://localhost:61616");
PooledConnectionFactory pcf = new
PooledConnectionFactory(queueConnectionFactory);
pcf.setMaxConnections(50);

ActiveMQComponent amq =
ActiveMQComponent.activeMQComponent("tcp://localhost:61616");
amq.setConnectionFactory(pcf);
amq.setMaxMessagesPerTask(-1);
amq.setMaxConcurrentConsumers(50);
amq.setCacheLevelName("CACHE_CONSUMER");
amq.setAcknowledgementModeName("AUTO_ACKNOWLEDGE");
getContext().addComponent("activemq", amq);

My route does the following...

@Produce(uri = "activemq:inbound")
ProducerTemplate inboundProducer;

@Consume(uri = "jetty:http://0.0.0.0:9001/inboundMessage/")
@InOnly
public void onMessage(String message)
{
    String addressID = getAttributeValueFromXML(message,"addr");

    //set the JMSXGroupID appropriately to enable AMQ MessageGroups
(guaranteed ordering)
    inboundProducer.sendBodyAndHeader(message, "JMSXGroupID", addressID);
}

from("activemq:inbound?transacted=true&maxConcurrentConsumers=50")
.process(new ValidateMessage())
.process(new SaveToDatabase())
.to("activemq:topic:outbound"); 

Questions...

how do I set the prefetch buffer?
what Tx manager should I be using and how do I set it up?
should I be using newer versions of any components?

thanks again...




-----
Ben - Senior Consultant

-- 
View this message in context: http://old.nabble.com/performance-issues-with-JMS-transacted-route...-tp26579725p26594255.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: performance issues with JMS transacted route...

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Also which version of spring are you using? spring-jms is not really
performing well until late 2.5.x versions.

There is a bit snippet about caching and spring issues at
http://camel.apache.org/jms.html

And if using AMQ it has a ton of tuning parameters.
prefretch buffer need to be adjusted to fit your max 50 threads
settings etc. So it should be like 50 x 1000 or something.

Anyway you shouldnt see a drop in performance when turning transaction
on/off - unless using XA which is dead slow.


On Tue, Dec 1, 2009 at 11:39 AM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> You need to post more details about your JMS and TX setup.
> Which TX manager are you using? Do you use XA or not.
> And the JMS broker I assume its AMQ but if not what is it?
>
> BTW: The xpath thingy should be faster in 2.1 as we have removed a
> hotspot which let it perform much better under concurrent load.
>
>
> On Mon, Nov 30, 2009 at 7:40 PM, boday <bo...@vektrel.com> wrote:
>>
>> I have the following JMS transacted route...
>>
>> from("activemq:start?maxConcurrentConsumers=50&transacted=true")
>> .process(new ValidateMessage())
>> .process(new SaveToDatabase())
>> .to("activemq:finishedQueue");
>>
>> I assumed there would be a bit of overhead with using transactions, but my
>> route goes from ~250 message/second to ~50 messages/second when I add the
>> "?transacted=true" to it (no other changes).
>>
>> I've seen similar performance hits when I added xpath (content based
>> routing, etc) to my route (so I worked around it).  My processor
>> "SaveToDatabase" does connect to a database (spring JDBC stored procedure
>> call), but is not transactional itself.
>>
>> Overall, my goal is to simply make my route guarantee messaging (server
>> crashes, restarts, etc) and maintain its high throughput.  Any other ideas?
>>
>> Has anyone else seen this type of drop in throughput with transacted
>> messages?  I'm hoping it has something to do with the Tx manager
>> configuration or something.  I'm using the default tx.xml file that shipped
>> with Servicemix 3.3.1/Camel 2.0...
>>
>> note: this is a followup to another thread
>> (http://old.nabble.com/guaranteed-message-processing-question...-to26202573.html#a26270332)
>>
>> thanks...
>>
>> -----
>> Ben - Senior Consultant
>>
>> --
>> View this message in context: http://old.nabble.com/performance-issues-with-JMS-transacted-route...-tp26579725p26579725.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: performance issues with JMS transacted route...

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You need to post more details about your JMS and TX setup.
Which TX manager are you using? Do you use XA or not.
And the JMS broker I assume its AMQ but if not what is it?

BTW: The xpath thingy should be faster in 2.1 as we have removed a
hotspot which let it perform much better under concurrent load.


On Mon, Nov 30, 2009 at 7:40 PM, boday <bo...@vektrel.com> wrote:
>
> I have the following JMS transacted route...
>
> from("activemq:start?maxConcurrentConsumers=50&transacted=true")
> .process(new ValidateMessage())
> .process(new SaveToDatabase())
> .to("activemq:finishedQueue");
>
> I assumed there would be a bit of overhead with using transactions, but my
> route goes from ~250 message/second to ~50 messages/second when I add the
> "?transacted=true" to it (no other changes).
>
> I've seen similar performance hits when I added xpath (content based
> routing, etc) to my route (so I worked around it).  My processor
> "SaveToDatabase" does connect to a database (spring JDBC stored procedure
> call), but is not transactional itself.
>
> Overall, my goal is to simply make my route guarantee messaging (server
> crashes, restarts, etc) and maintain its high throughput.  Any other ideas?
>
> Has anyone else seen this type of drop in throughput with transacted
> messages?  I'm hoping it has something to do with the Tx manager
> configuration or something.  I'm using the default tx.xml file that shipped
> with Servicemix 3.3.1/Camel 2.0...
>
> note: this is a followup to another thread
> (http://old.nabble.com/guaranteed-message-processing-question...-to26202573.html#a26270332)
>
> thanks...
>
> -----
> Ben - Senior Consultant
>
> --
> View this message in context: http://old.nabble.com/performance-issues-with-JMS-transacted-route...-tp26579725p26579725.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus