此内容没有您所选择的语言版本。
22.10. Configure a Generic JMS Resource Adapter for Use with a Third-party JMS Provider
JBoss EAP 6 can be configured to work with third-party JMS providers, however not all JMS providers produce a JMS JCA resource adapter for integration with Java application platforms. This procedure covers the steps required to configure the generic JMS resource adapter included in JBoss EAP 6 to connect to a JMS provider. In this procedure, Tibco EMS 6.3 is used as an example JMS provider, however other JMS providers may need a different configuration.
Important
Prerequisites
- JMS provider server is already configured and ready for use. Any binaries required for the provider's JMS implementation will be needed.
- You will also need to know the values of the following JMS provider properties to be able to lookup its JMS resources (connection factories, queues and topics).
- java.naming.factory.initial
- java.naming.provider.url
- java.naming.factory.url.pkgs
In the example XML used in this procedure, these parameters are written asPROVIDER_FACTORY_INITIAL,PROVIDER_URL, andPROVIDER_CONNECTION_FACTORYrespectively. Replace these placeholders with the JMS provider values for your environment.
Procedure 22.10. Configure a Generic JMS Resource Adapter for Use with a Third-party JMS Provider
Create a JBoss Module for the JMS provider
Create a JBoss module that contains all the libraries required to connect and communicate with the JMS provider. This module will be namedorg.jboss.genericjms.provider.- Create the following directory structure:
EAP_HOME/modules/system/layers/base/org/jboss/genericjms/provider/main - Copy the binaries required for the provider's JMS implementation to
EAP_HOME/modules/system/layers/base/org/jboss/genericjms/provider/main.Note
For Tibco EMS, the binaries required aretibjms.jarandtibcrypt.jarfrom the Tibco installation'slibdirectory. - Create a
module.xmlfile inEAP_HOME/modules/system/layers/base/org/jboss/genericjms/provider/mainas below, listing the JAR files from the previous steps as resources:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Configure a JNDI external context to the JMS provider
The JMS resources (connection factories and destinations) are looked up in the JMS provider. We will add an external context in the JBoss EAP 6 instance so that any local lookup for this resource will automatically look up the resource on the remote JMS provider.Note
In this procedure,EAP_HOME/standalone/configuration/standalone-full.xmlis used as the JBoss EAP 6 configuration file.InEAP_HOME/standalone/configuration/standalone-full.xml, under<subsystem xmlns="urn:jboss:domain:naming:1.4">, add:Copy to Clipboard Copied! Toggle word wrap Toggle overflow These three properties' values must be replaced by the correct value to connect to the remote JMS provider. Take care when replacing the placeholder text to keep the${}intact.Enable Lookup by String
There are some JMS provider (such as Tibco EMS) that do not support the JNDIlookup(Name)method. In these cases, add theorg.jboss.as.naming.lookup.by.stringproperty with a valuetrueto workaround this issue.Example 22.2. Enable Lookup by String with Tibco EMS
A complete definition for anexternal-contextto Tibco EMS would be as follows.Copy to Clipboard Copied! Toggle word wrap Toggle overflow With this external context, any JNDI lookup to a resource starting withjava:global/remoteJMS/will be done on the remote JMS provider (after removing this prefix). As an example, if a Message-Driven Bean perform a JNDI lookup forjava:global/remoteJMS/Queue1, the external context will connect to the remote JMS provider and perform a lookup for theQueue1resource.Configure the Generic JMS Resource Adapter
InEAP_HOME/standalone/configuration/standalone-full.xml, add the generic resource adapter configuration to<subsystem xmlns="urn:jboss:domain:resource-adapters:1.1">.Example 22.3. Tibco EMS Resource Adapter Configuration
A complete resource adapter definition for Tibco EMS would be as follows.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the default message-driven bean pool with the generic resource adapter.
InEAP_HOME/standalone/configuration/standalone-full.xml, in<subsystem xmlns="urn:jboss:domain:ejb3:1.5">, update the<mdb>configuration with:<mdb> <resource-adapter-ref resource-adapter-name="org.jboss.genericjms"/> <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/> </mdb>
<mdb> <resource-adapter-ref resource-adapter-name="org.jboss.genericjms"/> <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/> </mdb>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
The generic JMS resource adapter is now configured and ready for use. When creating a new Message-driven Bean, use code similar below to use the resource adapter.
Example 22.4. Use the Generic Resource Adapter
Warning
NullPointerException (NPE) error. The NPE error occurs because the generic JMS resource adapter attempts processing of parameters, when the Java EE specification states that they are not to be processed.
connection.createSession(true, Session.SESSION_TRANSACTED);
connection.createSession(true, Session.SESSION_TRANSACTED);
Example 22.5. Use the Pooled Connection
@Resource(lookup = "java:/jms/XAQCF") private ConnectionFactory cf;
@Resource(lookup = "java:/jms/XAQCF")
private ConnectionFactory cf;
Example 22.6. Perform a Lookup