Using External JMS Providers

The JMS binding can be configured to use an external JMS provider. The most common way to enable this is by binding connection factories and queues from the JMS provider in a JNDI context which is then configured in Fabric3.

Note that the ActiveMQ extension must not be installed if using an external JMS provider.

To setup an external JMS provider using JNDI, perform the following steps:

  1. Create a jndi directory under the runtime extensions directory.
  2. Place the JAR libraries required to connect to the JMS provider in the jndi directory.
  3. If required, bind JMS provider connection factories and JMS destinations in the JNDI context that will be connected to. Some providers such as Websphere MQ provide administration tools to do this. Some providers such as WebLogic do not require this step.

Once these preliminary steps are complete, a JNDI context must be configured in a composite and deployed. The composite may be included in the same application that requires JMS or deployed in a separate contribution. To configure the JNDI context, use the jndi element as shown below:

<f3:jndi>
   <context name="JndiContext">
      <property name="java.naming.factory.initial" value="org.tempuri.SomeInitialContextFactory"/>
      <property name="java.naming.provider.url" value="protocol://some.url"/>
   </context>
</f3:jndi>

The above example will register a JNDI context, JndiContext with the runtime using the specified initial context factory and url to connect to the JNDI provider (note the property element is optional and properties may vary depending on the JDNI provider). It is also possible to specify multiple JNDI contexts within a single jndi element.

Once a JNDI context is configured, the JMS binding may reference connection factories and destinations by name. The following uses the JNDI context configured in the previous example:

<channel name="TestChannel">
   <binding.jms >
      <connectionFactory jndiName="TheConnectionFactory"/>
      <destination jndiName="TheTopic"/>
   </binding.jms>
</channel

Note that in the above example the JNDI context was never specified by name. Fabric3 will perform a search against all registered contexts until it finds the correct factory and destination. This approach provides flexibility by allowing JNDI configuration to change without requiring a change to application artifacts.

Configuring WebLogic JMS

WebLogic JMS can be used as an external JMS provider by following the above JNDI configuration steps and placing wljmsClient.jar and wlthint3client.jar in the runtime jndi directory. Next, a JNDI context must be configured as follows:

<f3:jndi>
   <context name="WLS">
      <property name="java.naming.factory.initial" value="weblogic.jndi.WLInitialContextFactory"/>
      <property name="java.naming.provider.url" value="t3://localhost:7001"/>
   </context>
</f3:jndi>

After this is done, connection factories and destinations bound into the WLS clustered JNDI tree can be accessed by name from a binding.jms configuration.

Note that bound WLS connection factories must be non-XA. WebLogic does not support XA transactions with external JMS clients.