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

zecas zecas do-not-reply at jboss.com
Thu Oct 13 14:37:37 EDT 2011


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

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

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

--------------------------------------------------------------
Hi,

I have tried another solution that I believe will getting me closer to no dependencies on project code.

As I said, I'm posting my findings here.

Instead of connecting to MQ Series using the resource adapter wmq.jmsra.rar, as described in this document:
+Using WebSphere MQ Series with JBossAS Part IV - Integration using the IBM WebSphere JMS Resource Adapter  (RECOMMENDED WAY!!)+
http://community.jboss.org/docs/DOC-12535

I followed the document:
+Using WebSphere MQ Series with JBossAS Part III - Integration using an external context+
 http://community.jboss.org/docs/DOC-12534 http://community.jboss.org/docs/DOC-12534

I have copied the following libs:

Directory of C:\...\jboss-5.1.0.GA\server\default\lib 
30-03-2011  10:21           698.737 commonservices-2.3.jar 
30-03-2011  10:21           446.549 defaultconfig-2.3.jar 
30-03-2011  10:21         2.011.835 dhbcore-1.0.jar 
30-03-2011  10:21           356.293 headers-2.3.jar 
30-03-2011  10:21         1.904.071 jmqi-2.3.jar 
30-03-2011  10:21           438.016 mq-2.3.jar 
30-03-2011  10:21            17.657 mqcontext-2.3.jar 
30-03-2011  10:21         3.229.664 mqjms-1.1.jar 
30-03-2011  10:21            13.968 Nojndi-2.3.jar 
30-03-2011  10:21           103.980 pcf-1.4.2.jar 
30-03-2011  10:21           124.522 pcf-6.1-6.1.jar 
30-03-2011  10:21         7.758.362 postcard-2.3.jar 
30-03-2011  10:21           893.796 rmm-1.0.jar 
30-03-2011  10:21           101.628 soap-1.4.2.jar 
30-03-2011  10:21            31.996 tools.ras-1.4.2.jar


These dependencies were copied from my MQ Series java lib folder, the names are a bit different (with versions), maven style  :) .

I created a provider definition for Websphere MQ in +C:\...\jboss-5.1.0.GA\server\default\conf\jboss-service.xml+:

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

<!-- $Id: jboss-service.xml 88695 2009-05-12 03:32:03Z bstansberry at jboss.com (mailto:bstansberry at jboss.com) $ --> 

<!-- ===================================================================== --> 
<!--  JBoss Server Configuration                                           --> 
<!-- ===================================================================== --> 

<server> 

    <!-- 
    ... 
    --> 

<!-- WebSphere MQ context JNDI --> 
<mbean code="org.jboss.naming.ExternalContext" 
name="DefaultDomain:service=ExternalContext,jndiName=wsmq"> 
<attribute name="JndiName">wsmq</attribute> 
<attribute name="Properties"> 
java.naming.factory.initial=com.ibm.mq.jms.context.WMQInitialContextFactory 
java.naming.provider.url=192.168.1.30:1414/SYSTEM.DEF.SVRCONN 
java.naming.security.authentication=none 
</attribute> 
<attribute name="InitialContext">javax.naming.InitialContext</attribute> 
</mbean> 

</server>


Then I defined my connection factories on +C:\...\jboss-5.1.0.GA\server\default\deploy\wsmq-ds.xml+:

<?xml version="1.0" encoding="UTF-8"?>
<connection-factories>
<!-- ==================================================================== -->
<!-- WSMQ connection factories -->
<!-- ==================================================================== -->
<!-- The WSMQ JMS provider loader -->
<mbean code="org.jboss.jms.jndi.JMSProviderLoader"
name="jboss.mq:service=JMSProviderLoader,name=WSMQJMSProvider">
<attribute name="ProviderName">WSMQJMSProvider</attribute>
<attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
<attribute name="QueueFactoryRef">wsmq/QM_server01</attribute>
<attribute name="TopicFactoryRef">wsmq/QM_server01</attribute>
</mbean>
<!-- The WSMQ JMS connection factory -->
<no-tx-connection-factory>
<jndi-name>WSMQJms</jndi-name>
<rar-name>jms-ra.rar</rar-name>
<connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>
<config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property>
<config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/WSMQJMSProvider</config-property>
<max-pool-size>20</max-pool-size>
</no-tx-connection-factory>
</connection-factories>


Last but not least, my Message Driven Bean:

@MessageDriven( 
        activationConfig = { 
                @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"), 
                @ActivationConfigProperty(propertyName="destination", propertyValue="wsmq/TestQ"), 
                @ActivationConfigProperty(propertyName="providerAdapterJNDI", propertyValue="java:/WSMQJMSProvider") 
        })
public class TestMQ implements MessageListener {
 
    public void onMessage(Message message) {
        System.out.println(message.toString());
    }
 
}


At this time, any message that falls into TestQ on MQ Series will be delivered to my Message Driven Bean.

I'm yet to try to send a message to the queue, that should use the "no-tx-connection-factory" defined in the "wsmq-ds.xml" file (correct me if I'm wrong), but at least, I have a startup point without many dependencies to JBoss nor MQ Series on my project.

The only dependency I have now is:

@ActivationConfigProperty(propertyName="providerAdapterJNDI", propertyValue="java:/WSMQJMSProvider")


Since I want to blindly deploy the project on a Websphere Application Server (latter on), I don't believe that property will go unnoticed there without some obscure deployment error :).

So I was trying to inject the annotation in JBoss only, and using AOP whould seem a good feature ... inject on JBoss side.

For that, I tried deploying the aop on +C:\...\jboss-5.1.0.GA\server\default\deploy\wsmq-aop.xml+:

<?xml version="1.0" encoding="UTF-8"?>
<aop xmlns="urn:jboss:aop-beans:1.0">
    <domain name="TestQ" extends="Message Driven Bean" inheritBindings="true">
        <annotation expr="!class(@org.jboss.ejb3.annotation.DefaultActivationSpecs)">
            @org.jboss.ejb3.annotation.DefaultActivationSpecs ({@javax.ejb.ActivationConfigProperty(propertyName = providerAdapterJNDI, propertyValue = java:/WSMQJMSProvider)})
        </annotation>
    </domain>

</aop>


And after removing the refered annotation, I'm not able to deliver messages to my MDB.

So at this time, I need some opinions on this subject, any tip on what can I do to inject that annotation with JBoss AOP features (or something else on JBoss side). How am I supposed to inject that annotation?

(At the same time, I'm trying to create an alternative bridge between my local JBoss queues and remote MQ Series queues. That can give me some more knowledge about JBoss features and may help save the day, latter on ... in this project or on any future one)

Any help is welcomed.

Thanks
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/631664#631664]

Start a new discussion in JNDI and Naming at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20111013/6c2f5acd/attachment-0001.html 


More information about the jboss-user mailing list