I want to send messages to remote queue ? what steps should i do i cant find any documentation about that ? anyone can help ?? ?
5
votes
2 Answers
6
votes
Add another "JMSProvider" in your ${JBOSS_CONF}/deploy/messaging/jms-ds.xml. I use the provider name "RemoteJMSProvider" in this example:
<!-- Remote JMS Server-->
<mbean code="org.jboss.jms.jndi.JMSProviderLoader"
name="jboss.mq:service=JMSProviderLoader,name=RemoteJMSProvider,server=your_remote_host">
<attribute name="ProviderName">RemoteJMSProvider</attribute>
<attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
<!-- The connection factory -->
<attribute name="FactoryRef">XAConnectionFactory</attribute>
<!-- The queue connection factory -->
<attribute name="QueueFactoryRef">XAConnectionFactory</attribute>
<!-- The topic factory -->
<attribute name="TopicFactoryRef">XAConnectionFactory</attribute>
<!-- Connect to JNDI on the host "the-remote-host-name" port 1099-->
<attribute name="Properties">
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jnp.interfaces
java.naming.provider.url=your_remote_host:1099
</attribute>
Next, add a "Remote Connection Factory":
<tx-connection-factory>
<jndi-name>RemoteJMSConnectionFactory</jndi-name>
<xa-transaction/>
<rar-name>jms-ra.rar</rar-name>
<connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>
<config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Queue</config-property>
<config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/RemoteJMSProvider</config-property>
<max-pool-size>20</max-pool-size>
<security-domain-and-application>JmsXARealm</security-domain-and-application>
<depends>jboss.messaging:service=ServerPeer</depends>
Now, anytime you create a connection factory reference to "RemoteJMSFactory", any queue you reference will be looked-up on the remote server:
ConnectionFactory factory =(ConnectionFactory)JNDIContext.lookup("java:/RemoteJMSConnectionFactory");
queue = (Destination) JNDIContext.lookup("queue/myqueue");
connection = factory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer sender = session.createProducer(queue);
sender.send(jmsMessage);
See also: http://community.jboss.org/wiki/HowDoIConfigureAnMDBToTalkToARemoteQueue