How do I configure an EJB3 MDB to talk to a Remote Queue?
1. Create and deploy a remote JMS provider on the machine that runs the MDB container
2. Configure the MDB to use the newly created JMS provider
1. Create a remote JMS provider
(this step is no different from the corresponding step described at HowDoIConfigureAnMDBToTalkToARemoteQueue)
The new remote provider is is similar to the local provider specified in $JBOSS_HOME/server/<profile>/deploy/jms/jms-ds.xml, with the exception of the JNDI name and JNDI configuration parameters. The remote provider must be deployed on the server instance running the MDB container, since the remote provider will be used by the MDB container to connect to the remote queue.
The configuration can be either appended to jms-ds.xml or to a completely new deployment descriptor. If you choose to use jms-ds.xml, you can either add the following <mbean> declaration under the <connection-factories> tag of jms-ds.xml:
... <mbean code="org.jboss.jms.jndi.JMSProviderLoader" name="jboss.mq:service=JMSProviderLoader,name=RemoteJMSProvider,server=remotehost"> <attribute name="ProviderName">RemoteJMSProvider</attribute> <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute> <!-- The connection factory --> <attribute name="FactoryRef">UIL2XAConnectionFactory</attribute> <!-- The queue connection factory --> <attribute name="QueueFactoryRef">UIL2XAConnectionFactory</attribute> <!-- The topic factory --> <attribute name="TopicFactoryRef">UIL2XAConnectionFactory</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=the-remote-host-name:1099 </attribute> </mbean> ...
Important:
You need to replace "the-remote-host-name" with the DNS name or the IP address of the machine that runs the JMS server.
For a HA configuration, use port 1100 instead of 1099.
2. Configure the MDB to use the newly created JMS provider
Add the newly deployed provider adapter JNDI name to your MDB configuration, using annotations:
@MessageDriven(activateConfig = { @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"), @ActivationConfigProperty(propertyName="destination", propertyValue="queue/testQueue"), @ActivationConfigProperty(propertyName="providerAdapterJNDI", propertyValue="java:/RemoteJMSProvider") }) public class MDB implements MessageListener { ... }
Comments