problem with MessageAwareListener
jbride Mar 17, 2009 12:36 PMHi,
I'm using JBESB_4_5_GA and have had success configuring JMSGatewayListener to consume JMS messages from queues hosted by a QPid C++ broker. I am encountering a problem however when attempting to configure a MessageAwareListener to consume JMS messages from queues hosted by the same QPid C++ broker. The following is a configuration snippet where the 'alerts_eval_object' endpoint is later flagged as a gateway and 'alerts_eval_object_esbAware' endpoint is later flagged as esb aware :
<jms-provider name="QPID_JMS" connection-factory="qpidConnectionFactory"> <property name="jndi-prefixes" value="connectionfactory.,destination." /> <property name="java.naming.factory.initial" value="org.apache.qpid.jndi.PropertiesFileInitialContextFactory" /> <property name="java.naming.provider.url" value="/alert_eval_amqp.properties" /> <jms-bus busid="alerts_eval_object"> <jms-message-filter dest-type="QUEUE" dest-name="alerts_eval_object" persistent="false" /> </jms-bus> <jms-bus busid="alerts_eval_object_esbAware"> <jms-message-filter dest-type="QUEUE" dest-name="alerts_eval_object_esbAware" persistent="true" /> </jms-bus> </jms-provider>
Part of the problem seems to stem from the following code in ListenerUtil.java :
159 String jndiURL = tree.getAttribute(JMSEpr.JNDI_URL_TAG); 160 if (jndiURL==null) jndiURL = Configuration.getJndiServerURL() ; 161 environment.setProperty(Context.PROVIDER_URL, jndiURL); 162 String jndiContextFactory = tree.getAttribute(JMSEpr.JNDI_CONTEXT_FACTORY_TAG); 163 if (jndiContextFactory==null) jndiContextFactory = Configuration.getJndiServerContextFactory() ; 164 environment.setProperty(Context.INITIAL_CONTEXT_FACTORY, jndiContextFactory); 165 String jndiPkgPrefix = tree.getAttribute(JMSEpr.JNDI_PKG_PREFIX_TAG); 166 if (jndiPkgPrefix==null ) jndiPkgPrefix = Configuration.getJndiServerPkgPrefix() ; 167 environment.setProperty(Context.URL_PKG_PREFIXES, jndiPkgPrefix);
In line #159 .... jndiURI will return null .... and subsequently will replace (in line #161) the previously correct value for java.naming.provider.url ( in my case : /alert_eval_amqp.properties) . Similar behavior occurs when setting the JNDI context factory.
The end result is that with the configuration above, the ESB begins to consume messages from the gateway EPR (because JMSGatewayListener.java works well). However, the ESB loops in an effort to lookup QPID connection factories and destinations that are not to be found in the local JNDI when attempting to initialize the MessageAwareListener .
I can take a crack at posting a patch to this if someone can confirm this is a bug and there isn't already a different work around .
thank you !
jeffrey bride