[jboss-user] [JNDI and Naming] - Using JNDI to connect to Websphere MQ, without hardcoded info

zecas zecas do-not-reply at jboss.com
Wed Aug 3 18:36:46 EDT 2011

zecas zecas [http://community.jboss.org/people/zecas] created the discussion

"Using JNDI to connect to Websphere MQ, without hardcoded info"

To view the discussion, visit: http://community.jboss.org/message/619269#619269


I'm struggling with JBoss to properly use a JNDI connection to completly make a connection to Websphere MQ Series, to feed an MDB.

I need some help, I'm trying to "sell" the idea of JBoss for this specific client I'm working for, and I would like to pass this difficulty, but I need some help from the community.

JBoss 5.1.0 GA
Java JDK 1.6.0
WebSphere MQ 7.0.1 (on remote machine,

I've copied the "wmq.jmsra.rar" file into c:\...\jboss-5.1.0.GA\server\default\deploy folder. In that same location, I've created the file "wmq.jmsra-ds.xml", for the queue settings.

File "wmq.jmsra-ds.xml" contents:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <mbean code="org.jboss.resource.deployment.AdminObject" name="jboss.jca:service=WASDestination,name=TestQ">
    <!--<mbean code="org.jboss.resource.deployment.AdminObject" name="jca.wmq:name=TestQ">-->
        <depends optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='wmq.jmsra.rar'</depends>
        <attribute name="JNDIName">queue/TestQ</attribute>
        <attribute name="Type">javax.jms.Queue</attribute>
        <attribute name="Properties">
        <config-property name="channel" type="java.lang.String">SYSTEM.DEF.SVRCONN</config-property>
        <config-property name="hostName" type="java.lang.String"></config-property>
        <config-property name="port" type="java.lang.String">1414</config-property>
        <config-property name="queueManager" type="java.lang.String">QM_gestaosw_dds02</config-property>
        <config-property name="transportType" type="java.lang.String">CLIENT</config-property>

In WebSphere MQ server, I have the queue manager instance named "QM_server01" and I've created a queue "TestQ" with default values applied. It was a fresh MQ install, I've just entered "IBM MQ Explorer" and created the "TestQ" queue.

Now from my project, I have the following Message Driven Bean:

        activationConfig = {
                @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
                @ActivationConfigProperty(propertyName="destination", propertyValue="queue/TestQ"),
                @ActivationConfigProperty(propertyName="useJNDI", propertyValue="true"),
                @ActivationConfigProperty(propertyName="hostName", propertyValue=""),
                @ActivationConfigProperty(propertyName="port", propertyValue="1414"),
                @ActivationConfigProperty(propertyName="queueManager", propertyValue="QM_server01")
public class TestMQ implements MessageListener {
    public void onMessage(Message message) {

Now this works fine. If I insert a message in the Websphere MQ, my MDB will pick it up with no problem.

My real problem is that, although I have defined the "mbean" in my "wmq.jmsra-ds.xml" JBoss deploy file, I cannot find a way to use it to get the MQ info.

Looking at my MDB code, I have the IP, PORT, QueManager name all hardcoded. And also I have a reference to "@ResourceAdapter" JBoss specific annotation.

I was hoping to configure this info in some server specific file, like the "wmq.jmsra-ds.xml", and eventually in the "jboss.xml" or some binding file that I could provide in my EJB jar file (which is part of an EAR).

I need to make the project work on JBoss and WebSphere Application Servers, and also (and specially) to not relly on remote MQ location hardcoded in my MDB's.

My project will go through several environments until reaching the final production environment, and I don't want to make builds for each of them.

So any way of just pointing to the JNDI and JBoss pick it up? Do I need to provide a jboss-specific xml binding file in my project?

It this a limitation of JBoss 5.1.0 GA? If so, will JBoss 6 provide the solution I'm looking for?

Again, I'm hopping the community to help me solve this situation. As I have it now, I will have a hard time moving on with the project in JBoss.


Reply to this message by going to Community

Start a new discussion in JNDI and Naming at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110803/b4e9e602/attachment.html 

More information about the jboss-user mailing list