How do I configure the JMS Resource Adapter to use a remote ConnectionFactory?
Please note that this procedure applies for JBoss MQ. For JBoss Messaging substitute "jboss.messaging" for "jboss.mq" and "XAConnectionFactory" for "UIL2XAConnectionFactory"
First deploy the provider for the remote machine:
<mbean code="org.jboss.jms.jndi.JMSProviderLoader" name="jboss.mq:service=JMSProviderLoader,name=RemoteMQProvider,server=Whatever"> <attribute name="ProviderName">WhateverJMSProvider</attribute> <attribute name="ProviderUrl">jnp://whatever:1099</attribute> <attribute name="ProviderAdapterClass"> org.jboss.jms.jndi.JBossMQProvider </attribute> <attribute name="QueueFactoryRef">UIL2XAConnectionFactory</attribute> <attribute name="TopicFactoryRef">UIL2XAConnectionFactory</attribute> </mbean>
Since 3.2.4 there is an improved ProviderAdapterClass that lets you
specify all jndi properties, e.g. HAJNDI
<mbean code="org.jboss.jms.jndi.JMSProviderLoader" name="jboss.mq:service=JMSProviderLoader,name=JMSProvider"> <attribute name="ProviderName">DefaultJMSProvider</attribute> <attribute name="ProviderAdapterClass"> org.jboss.jms.jndi.JNDIProviderAdapter </attribute> <!-- The queue connection factory --> <attribute name="QueueFactoryRef">java:/XAConnectionFactory</attribute> <!-- The topic factory --> <attribute name="TopicFactoryRef">java:/XAConnectionFactory</attribute> <!-- Uncomment to use HAJNDI to access JMS <attribute name="Properties"> java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces java.naming.provider.url=localhost:1100 </attribute> --> </mbean>
Second deploy the managed connection factory using this provider:
NOTE: The JMSProviderAdapterJNDI
<connection-factories> <tx-connection-factory> <jndi-name>WhateverJmsXA</jndi-name> <xa-transaction/> <rar-name>jms-ra.rar</rar-name> <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition> <adapter-display-name>JMS Adapter</adapter-display-name> <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property> <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/WhateverJMSProvider</config-property> <security-domain-and-application>WhateverJmsXARealm</security-domain-and-application> </tx-connection-factory> </connection-factories>
Finally configure the user/password in conf/login-config.xml
NOTE: The name in the managed connection factory reference is the jndi name.
<application-policy name = "WhateverJmsXARealm"> <authentication> <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required"> <module-option name = "principal">guest</module-option> <module-option name = "userName">guest</module-option> <module-option name = "password">guest</module-option> <module-option name = "managedConnectionFactoryName">jboss.jca:service=TxCM,name=WhateverJmsXA</module-option> </login-module> </authentication> </application-policy>
Comments