Hi,
I found the problem and the solution! :-)
The problem is the broker connection. In my test, with standard JMS API, I use
only one connection opened before my sending-loop and closed after.
If a create a connection for every message using JMS API, the execution
consumes more or less the same time of my Camel based test.
So I set my broker (activemq) in DEBUG mode and I saw a connection opened and
closed for every single message sent by Camel.
The solution, obviously is to cache or pool the connections and you can do this
with ActiveMQ PooledConnectionFactory:
CamelContext context = new DefaultCamelContext();
ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("failover://(tcp://localhost:61616)");
context.addComponent("activemq", JmsComponent.jmsComponentAutoAcknowledge(new
PooledConnectionFactory(connectionFactory)));
And now I can send my 50.000 messages 20 times faster than before! :-)
Thanks for your support.
Ciao,
Lorenzo
> Hi,
>
> Interesting, need a faster Producer, eh!!!... Usually not a good idea since
> it creates pileups on the broker queues (which should ideally be clean).
> Especially since in JMS a fast producer/slow consumer is not usually a good
> recipe for enterprise messaging.
>
> Having put forth my obligatory cautions, you could speed things up in the
> following way.
> 1> Create a pooled dispatcher/producer i.e "activemq" should use pooled
> connection factories that do not incur the cost of recycling connections,
> sessions etc. Spring tends to recycle connections, sessions etc and Camel can
> inherit these qualities. Pooling and setting JMS cache levels can be a way to
> overcome that.
> 2> Create multiple instances of such pooled dispatchers/producers and
> load balance messages using round robin
> 3> Give enough threads directly to the load balancer so that it is not
> the route bottleneck.
> 4> Ensure that the source Uri is a "direct:..." so you are using an in
> memory dispatch to the route from your client application. Of course, all of
> this assumes that you client application is extremely fast and that the Camel
> route is slow on the pickup.
> 5> If this still does not cut it, create multiple such routes involving
> steps 1 thru 4.
>
> Scary and just in time for Halloween :)...
>
> An example of what I have stated is given below. I believe it works...
>
> ===============================================
> from(sourceUri)
> .routeId("CBR-Route")
> .threads(25).maxPoolSize(50).threadName("MyAMQDispatchPool").keepAliveTime(25).timeUnit(TimeUnit.SECONDS).rejectedPolicy(ThreadPoolRejectedPolicy.DiscardOldest)
>
> .loadBalance()
> .roundRobin()
> .to(dispatcherUri, dispatcher2Uri, dispatcher3Uri);
>
> ===============================================
>
> Cheers,
>
> Ashwin...
> ---------------------------------------------------------
> Ashwin Karpe
> Apache Camel Committer & Sr Principal Consultant
> FUSESource (a Progress Software Corporation subsidiary)
> http://fusesource.com
>
> Blog:http://opensourceknowledge.blogspot.com
> ---------------------------------------------------------
>
>
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/How-to-speed-up-JMS-production-tp4936275p4937750.html
> To unsubscribe from How to speed up JMS production?, click here.
--
View this message in context:
http://camel.465427.n5.nabble.com/How-to-speed-up-JMS-production-tp4936275p4939313.html
Sent from the Camel - Users mailing list archive at Nabble.com.