-
1. Re: Pool of JMS objects
leosbitto Mar 24, 2010 3:24 PM (in response to leosbitto)Please check the attached file src.zip - that is my first attempt to provide proper pooling of the JMS objects. I have not tested it properly yet. It should work with any JMS 1.1 compliant provider, with one additional requirement: its implementation of javax.jms.Destination must implement reasonable equals(). HornetQ should be fine for this.
If you would like to use Spring, here is an example:
<bean id="connectionFactoryFromJNDI" class="some.package.ConnectionFactoryFromJNDI"><constructor-arg type="java.lang.String"><value>/ConnectionFactory</value></constructor-arg><constructor-arg type="java.util.Hashtable"><props><prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop><prop key="java.naming.factory.url.pkgs">org.jboss.naming:org.jnp.interfaces</prop><prop key="java.naming.provider.url">jnp://localhost:1099</prop></props></constructor-arg></bean><bean id="sharedConnectionFactory" class="some.package.SharedConnectionFactory" destroy-method="close"><constructor-arg type="javax.jms.ConnectionFactory" ref="connectionFactoryFromJNDI" /></bean><bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"><constructor-arg type="javax.jms.ConnectionFactory" ref="sharedConnectionFactory" /></bean>Obviously you do not need to use JmsTemplate, you can use the pure JMS interface only, starting with the provided ConnectionFactory implementation.
-
src.zip 7.4 KB
-
-
2. Re: Pool of JMS objects
leosbitto Mar 25, 2010 3:08 PM (in response to leosbitto)Because the behaviour of equals() on javax.jms.Destination is not defined in the JMS specification, I changed my code to avoid using it - I use Queue#getQueueName() and Topic#getTopicName() instead. Check the attached file src2.zip.
-
src2.zip 8.0 KB
-
-
3. Re: Pool of JMS objects
leosbitto Apr 12, 2010 6:21 PM (in response to leosbitto)Closing of MessageConsumers with MessageListeners left something to be desired, so here is another version: src3.zip
Any comments?
-
src3.zip 7.9 KB
-