0
votes

I am writing a standard JEE 5 application and need to consume JMS messages from MQ server. Application server is JBOSS EAP 5.1. As this is a standard JEE application, an MDB would be good fit as message listener. MQ admin has provided a .bindings file as MQ configuration. After searching web, I am not able to find a way to use .bidings file with MDBs. I have already tried using standard activation spec. That works fine. But for that, JMS properties need to be in JBOSS or EE specific configuration files. Can someone please tell a way to use .bindings file with MDB?

2

2 Answers

1
votes

A .bindings file comes from the File System JNDI Context. This is the file that is written when the FileSystemContext is used to store objects in JNDI. It shouldn't really be moved around.

JBOSS will have it's own JNDI provider and that won't be able to read this file. What you need is the information from the MQ sys admin of the queuemanager that you need to connect to.. i.e. the information the entered into JNDI. Presumably using JMSAdmnin or MQExplorer. Things like hostname, port, channel, any security config etc. etc.

Within JBOSS you'll need to deploy the MQ Resource Adapter (a) this downloadable via http://www-01.ibm.com/support/docview.wss?uid=swg21633761 (b) config info can be found at http://www-01.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q031820_.htm

0
votes

Using a .bindings file as created by the IBM MQ tools on JBoss 5.1 is relatively straight-forward.

Presumably, you already have a .bindings file as created by your MQ admins.

On the JBOss side, you will be using the:

com.sun.jndi.fscontext.RefFSContextFactory

Naming context factory to read and load the .bindings file into JBoss JNDI. In order to do this, you will need extra jars that are not provided as part of the IBM MQ JCA rar file. On a Unix system, these are found in the IBM MQ distribution under the:

/opt/mqm/java/lib/

directory. You will need:

fscontext.jar
mqcontext.jar
providerutil.jar

place these in your ${JBOSS_PROFILE)/lib directory.

Then, in you ${JBOSS_PROFILE)/deploy/messaging directory, create a file named wmq-bindings-ds.xml:

<?xml version="1.0" encoding="UTF-8"?>
<connection-factories>

  <!-- Load the bindings file for the naming context -->
  <mbean code="org.jboss.naming.ExternalContext" name="jboss.jndi:service=ExternalContext,jndiName=BindingsNamingContext">
    <attribute name="JndiName">java:/BindingsNamingContext</attribute>
    <attribute name="Properties">
      java.naming.factory.initial=com.sun.jndi.fscontext.RefFSContextFactory
      java.naming.provider.url=file:///${jboss.server.data.dir}/mq
    </attribute>
    <attribute name="InitialContext">javax.naming.InitialContext</attribute>
  </mbean> 

  <!-- The WSMQ JMS provider loader -->
  <mbean code="org.jboss.jms.jndi.JMSProviderLoader" name="jboss.mq:service=JMSProviderLoader,name=BindingsWSMQJMSProvider">
    <attribute name="ProviderName">BindingsWSMQJMSProvider</attribute>
    <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
    <attribute name="QueueFactoryRef">java:/BindingsNamingContext/mqConnectionFactory</attribute>
    <attribute name="TopicFactoryRef">java:/BindingsNamingContext/mqConnectionFactory</attribute>
  </mbean>

</connection-factories>

Note that I have a directory in my ${jboss.server.data.dir} named 'mq'. The .bindings file is there. Your naming context will be loaded in JNDI under:

java:/BindingsNamingContext

Note:

java:/BindingsNamingContext/mqConnectionFactory java:/BindingsNamingContext/mqConnectionFactory

The 'java:/BindingsNamingContext' matches the provider, the 'mqConnectionFactory' matches what is in my .bindings file.