JMS Remote Consumer and <pooled-connection-factory>
lukasz.antoniak Dec 7, 2012 12:12 PMHello Community!
I have been playing with remote JMS producer and consumer for a while. The producer code can be easily developed and allows storing details of remote queue location in standalone or domain configuration files (see https://community.jboss.org/message/722711). Annotations of my initial Message-Driven Bean look as follows.
@MessageDriven(
name="ConsumerMdb",
activationConfig = {
@ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
@ActivationConfigProperty(propertyName="destination", propertyValue="queue/RemoteQueue1"),
@ActivationConfigProperty(propertyName="user", propertyValue="jmsuser"),
@ActivationConfigProperty(propertyName="password", propertyValue="jmspassword"),
@ActivationConfigProperty(propertyName="connectorClassName", propertyValue = "org.hornetq.core.remoting.impl.netty.NettyConnectorFactory"),
@ActivationConfigProperty(propertyName="connectionParameters", propertyValue = "host=192.168.117.159;port=5445")
})
Furthermore, MDB configuration can be moved to ejb-jar.xml (see https://issues.jboss.org/browse/AS7-3816) and there lookup system properties.
The bottom line question: why it is not advised to bind JMS consumers to pooled-connection-factory? This was clearly stated by Justin Bertram here: https://community.jboss.org/message/722711. What are the consequences? With such setup, I am able to use one connection factory for inbound and outbound traffic (http://rpokhodzhai.blogspot.com/2012/07/jboss-7-remote-jms-topic-mdb-consumer.html).
@ResourceAdapter("ConnectionFactory1")
@MessageDriven(
name="ConsumerMdb",
activationConfig = {
@ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
@ActivationConfigProperty(propertyName="destination", propertyValue="queue/RemoteQueue1")
})
"ConnectionFactory1" is the same connection factory used by producer and consumer components.
<connector name="remote-jms">
<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
<param key="host" value="192.168.117.159" />
<param key="port" value="15445" />
</connector>
<pooled-connection-factory name="ConnectionFactory1">
<user>jmsuser</user>
<password>jmspassword</password>
<connectors>
<connector-ref connector-name="remote-jms" />
</connectors>
<entries>
<entry name="java:/ConnectionFactory1" />
</entries>
</pooled-connection-factory>
Regards,
Lukasz