Thursday, August 21, 2008

Spring jmsTemplate threading issue

I recently encounter a problem while working on some Servicemix bug and it turned out that Servicemix jms provider is using spring-jms jmsTemplate and when there are multiple threads trying to do send receive (receiveSelected() to be precise) some of the messages are dropped.

While doing further investigation I found that multiple threads are using the same instance of spring-jms jmsTemplate that is created by the jms provider and this was causing some threading issue so thing to remember is to make the calls to jmsTemplate.receiveSelected() (atleast this one) synchronized.

UPDATE: I was too quick to diagnose the problem as jmsTemplate issue. With more drill down I was able to reproduce the problem with pure jmsTemplate and ActiveMQ combination and looks like a ActiveMQ issue than spring-jms. My friend Gary is getting it fixed in ActiveMQ currently.

Monday, August 11, 2008

Changes to Apache CXF JMS transport to allow jmsDestination name

Recently Apache CXF JMS transport is modified in order to allow use of jmsDestinationName and jmsReplyDestinationName. Till now CXF JMS only allowed using jndi destination names to lookup queue/destination and was not able to use jms destination names to create queues/topics.

Here is the diff of the schema change to specify the jmsDestinationName and jmsReplyDestinationName.

Example jms:address looks like this:

<jms:address jndiconnectionfactoryname="ConnectionFactory"
jmsdestinationname="dynamicQueues/routertest.SOAPService6Q.text"
jmsreplydestinationname="dynamicQueues/SoapService6.reply.queue">
<jms:jmsnamingproperty name="java.naming.factory.initial"
value="org.apache.activemq.jndi.ActiveMQInitialContextFactory"/>
<jms:jmsnamingproperty name="java.naming.provider.url"
value="tcp://localhost:61500"/>
</jms:address>


This will allow CXF consumer and services to use the real queue names (where JMS provider will allow the creation of the queues) as opposed to use jndi lookup.

handy tip on how to increase jetty HttpClient threadpool size in ServiceMix 3.2.2

I was recently working on some jetty related issue in Servicemix 3.2 and got Servicemix people to update servicemix-http component to have configurable jetty httpClient thread pool size. Before I forget it I wanted to make a note of it so adding this entry.

In Servicemix 3.2.2 and onwards jetty HttpClient threadpool can be configured using following entry in component.properties file.
servicemix-http.jettyClientThreadPoolSize=33

Also, you can configure Servicemix to use Jetty httpClient per httpProvider (by default a single client is shared among all httpProviderEndpoints) by adding

servicemix-http.jettyHttpClientPerProvider=true

Also from ServiceMix 3.2.2 onwards Jetty HttpClient uses nio channel selector implementation of jetty. (previously it was using socket connector which was blocking I/O and was causing thread locking in thread pool in some stress conditions)

Friday, August 1, 2008

टेस्टिंग मराठी ब्लोंग एंट्री.

अरे वा मराठी एंट्री पण चालते आहे बर्यापैकी पण माझे मराठी कच्चे आहे।