1 2 3 Previous Next 30 Replies Latest reply: May 30, 2012 9:31 AM by Justin Bertram RSS

Configure MQ Resource Adapter for MDB - JBoss 7.1

Paul DuBon Newbie

I'm using JBoss AS 7.1.0.CR1 and am having issues getting my resource adapter for Websphere MQ (wmq.jmsra.rar) working.  My server starts fine and I see in the output that my admin object and connection factory are being bound:

 

JBAS010401: Bound JCA ConnectionFactory

JBAS010401: Bound JCA AdminObject

 

 

FYI - When I define all the properties using annotations, the MDB works:

 

e.g.:

@MessageDriven(name = "RepositoryNotificationListener", activationConfig = {

        @ActivationConfigProperty(propertyName = "messagingType", propertyValue = "javax.jms.MessageListener"),

        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),

        @ActivationConfigProperty(propertyName = "destination", propertyValue = "NOTIFICATION.DATAGRAM"),

        @ActivationConfigProperty(propertyName = "queueManager", propertyValue = "QLD001A"),

        @ActivationConfigProperty(propertyName = "transportType", propertyValue = "CLIENT"),

        @ActivationConfigProperty(propertyName = "hostName", propertyValue = "HOST_NAME_REMOVED "),

        @ActivationConfigProperty(propertyName = "port", propertyValue = "60001"),

        @ActivationConfigProperty(propertyName = "channel", propertyValue = "A.CLIENT"),

        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")

         })

@ResourceAdapter("wmq.jmsra.rar")

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)

 

 

 

This is not my preferred approach however, as I'd like to keep the configuration on the application server as properties can change in different environments.

 

I'm fairly confident that the configuration is correct for the resource adapter now, as the resource adapter would not deploy properly otherwise.

I've tried using a generic version of the annotations, again moving most of the config to the application server:

 

@MessageDriven(name="RepositoryNotificationListener", , activationConfig = {

@ActivationConfigProperty(propertyName = "messagingType",propertyValue = "javax.jms.MessageListener"),

@ActivationConfigProperty(propertyName = "destinationType",propertyValue = "javax.jms.Queue"),

        @ActivationConfigProperty(propertyName = "destination", propertyValue = "java:jboss/jms/NOTIFICATION.DATAGRAM"),

        @ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "true")

         })

@ResourceAdapter("wmq.jmsra.rar")

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)

 

 

 

 

I'm also tried using Spring MDB, referencing the connection factory jndi as well as the admin object, but either way, I am not able to connect to the host and get the message off the queue.  I feel like there's some disconnect between the admin object and the connection factory.  Maybe I'm off base, but given that you can add multiple connection factories and the admin object is defined as a sibling to the connectionFactories, how does it know which to use?  (I though the Spring solution would solve my issue as it references both)

 

excerpt from my standalone-full.xml (some names have been changed to protect the innocent)

 

 

 

Has anyone been able to create a resource adapter for wmq and provide an associated mdb in Jboss 7.1?

  • 1. Re: Configure MQ Resource Adapter for MDB - JBoss 7.1
    Paul DuBon Newbie

    it looks like my excerpt was ommitted:

    <resource-adapters>

                    <resource-adapter>

                        <archive>

                            wmq.jmsra.rar

                        </archive>

                        <transaction-support>

                            NoTransaction

                        </transaction-support>

                      <connection-definitions>

                            <connection-definition class-name="com.ibm.mq.connector.outbound.ManagedQueueConnectionFactoryImpl" jndi-name="java:jboss/jms/MQCF" enabled="true" pool-name="java:jboss/jms/MQCF">

                                <config-property name="port">60001</config-property>

                                <config-property name="hostName">HOST_NAME_REMOVED </config-property>

                                <config-property name="channel">  A.CLIENT</config-property>

                                <config-property name="transportType">CLIENT</config-property>

                                <config-property name="queueManager">QLD001A   </config-property>                           

                        <validation>

                                    <background-validation>

                                        true

                                    </background-validation>

                                    <background-validation-millis>

                                        0

                                    </background-validation-millis>

                                </validation>

                            </connection-definition>

                        </connection-definitions>

                        <admin-objects>

                            <admin-object class-name="com.ibm.mq.connector.outbound.MQQueueProxy" jndi-name="java:jboss/jms/NOTIFICATION.DATAGRAM" enabled="true" use-java-context="false" pool-name="java:jboss/jms/NOTIFICATION.DATAGRAM">

                                <config-property name="baseQueueName">NOTIFICATION.DATAGRAM</config-property>

                                <config-property name="baseQueueManagerName">  QLD001A</config-property>

                            </admin-object>

                        </admin-objects>

                    </resource-adapter>

                </resource-adapters>

  • 2. Re: Configure MQ Resource Adapter for MDB - JBoss 7.1
    Paul DuBon Newbie

    Update:  I was able to get Spring JMS working by changing the Connectio Factory class to com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl

     

    I still however can not get a normal J2EE MDB to connect however, when I try to start the application with the MDB configured as follows:

     

    @MessageDriven(name="RepositoryNotificationListener", activationConfig = {
    @ActivationConfigProperty(propertyName = "messagingType",propertyValue = "javax.jms.MessageListener"),
    @ActivationConfigProperty(propertyName = "destinationType",propertyValue = "javax.jms.Queue"),
            @ActivationConfigProperty(propertyName = "destination", propertyValue = "java:jboss/jms/NOTIFICATION.DATAGRAM"),
            @ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "true")
             })
    @ResourceAdapter("wmq.jmsra.rar")
    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)

    public class MDBSample implements MessageListener{

    ...

    }

     

    I get this error:

    Caused by: com.ibm.msg.client.jms.DetailedIllegalStateException: JMSWMQ0018: Failed to connect to queue manager '' with connection mode 'Client' and host name 'localhost(1414)'. Check the queue manager is started and if running in client mode, check there is a listener running. Please see the linked exception for more information.

     

    So again, it appears that the admin object which I'm trying to reference in my MessageListener class via java:jboss/jms/NOTIFICATION.DATAGRAM isn't getting bound to my CF.

  • 3. Re: Configure MQ Resource Adapter for MDB - JBoss 7.1
    Stig Henriksen Newbie

    Any progress with this? I have the exact same problem....

  • 4. Re: Configure MQ Resource Adapter for MDB - JBoss 7.1
    Jesper Pedersen Master

    Compare your configuration with the information from the RAR info tool (http://docs.jboss.org/ironjacamar/userguide/1.1/en-US/html/tools.html#tools_rarinfo) using the IronJacamar 1.1.0.Alpha4+ distribution.

     

    Also recheck with the latest snapshot of master.

  • 5. Re: Configure MQ Resource Adapter for MDB - JBoss 7.1
    Paul DuBon Newbie

    Thank you Jesper.  I ran the rar-info tool and my configuration looks consistent with the sample that was generated.  There are a lot more config properites in the sample that what I had (shown in an above thread) and I assume I only need to specify properties that are essential for me to override and connect and typically when connecting from Websphere and other examples I've seen, the ones that I've defined are all that should be needed (host, channel, port, queue manager, queue and transport type).   

     

    Can you please clarify how JBoss knows which connection definition to bind the Message Listener to?  I really feel like that is my issue.  I maybe missing something in the MessageListener class.  Examples I've seen have the following annotation (which I'm also trying to use):

    @ResourceAdapter("wmq.jmsra.rar")

     

    as well as:

    @ActivationConfigProperty(propertyName = "destinationType",propertyValue = "javax.jms.Queue"),
    @ActivationConfigProperty(propertyName = "destination", propertyValue = "A_DESTINATION") - i'm trying to bind this to the admin object, but have also tried the remote wmq queue

     

    Is there anything else required ?

     

    When my application starts, the error displayed says to me it doesn't know how to bind to the connection definition because all of the values it is looking for are empty . So therefore it's not binding to what I have defined in the standalone.xml

    Caused by: com.ibm.msg.client.jms.DetailedIllegalStateException: JMSWMQ0018: Failed to connect to queue manager '' with connection mode 'Client' and host name 'localhost(1414)'. Check the queue manager is started and if running in client mode, check there is a listener running. Please see the linked exception for moreinformation.

     

     

  • 6. Re: Configure MQ Resource Adapter for MDB - JBoss 7.1
    jaikiran pai Master

    Just a FYI - We are looking into this.

  • 7. Re: Configure MQ Resource Adapter for MDB - JBoss 7.1
    Paul DuBon Newbie

    Great News!  Thank you

  • 8. Re: Configure MQ Resource Adapter for MDB - JBoss 7.1
    Stig Henriksen Newbie

    I've been looking a bit more into this, and one workaround is to subclass com.ibm.mq.connector.inbound.ActivationSpecImpl (saw it first in http://www.experts-exchange.com/Software/Server_Software/Application_Servers/Java/Jboss/Q_23886132.html):

     

    import com.ibm.mq.connector.inbound.ActivationSpecImpl

     

    public class ConfigureableActivationSpecImpl extends ActivationSpecImpl  {

         public ConfigureableActivationSpecImpl() {

              super();

              // Read ActivationSpec settings like hostName, port etc from some property file

              // Set properties using ActivationSpecImpl's setters

         }                   

    }    

     

    Package the class in a jar and add to wmq.jmsra.rar, and then modify wmq.jmsra.rar/META-INF/ra.xml:

     

    Replace

         <activationspec-class>com.ibm.mq.connector.inbound.ActivationSpecImpl</activationspec-class>

    with

         <activationspec-class>ConfigureableActivationSpecImpl</activationspec-class>

     

    A bit hackish, but this is actually the best solution I've found so far. I'm starting to think that there isn't a "clean" solution to this problem due how the wmq.jmsra.rar's ActivationSpecImpl works (must supply hostName, port etc, no 'connectionFactoryJndiName' or similar property) and the fact that a configureable ActivationSpec doesn't seem to be part of the EJB3 spec.

     

    EDIT: Come to think of it, there might be some some issues with the licence of the wmq.jmsra.rar-adapter for the above solution, anyone looking to do something like this should check that first.

     

    Message was edited by: Stig Henriksen

  • 9. Re: Configure MQ Resource Adapter for MDB - JBoss 7.1
    Jesper Pedersen Master

    Yes, I wouldn't mess with implementation without checking with IBM.

     

    The issue really boils down to that the ActivationSpec needs information from the ConnectionFactory that it hooks up to in the end; IBM can answer why an AdminObject is used in the middle. This "problem" can't really be solved unless the JCA container does some nasty hacks.

     

    So two solutions:

     

    1) Add configuration for all the needed properties on the ActivationSpec instance that are needed to make the connection

     

    2) Contact IBM and have them enhance the resource adapter using the following tricks internally in the implementation

     

    • Have the ManagedConnectionFactory's implement ResourceAdapterAssociation
    • In the setResourceAdapter() method register the ManagedConnectionFactory on the ResourceAdapter instance
    • Use property on ActivationSpec to uniquely identify the ManagedConnectionFactory
    • Once ActivationSpec.validate() is called by the container, copy over missing properties through the ResourceAdapter instance from the correct ManagedConnectionFactory instance

     

    I'm making a lot of assumptions since this is vendor specific code, so only access to the source code can give the real answer.

     

    At least I hope the above gives an insight to why you need to specify all the properties on the ActivationSpec...

  • 10. Re: Configure MQ Resource Adapter for MDB - JBoss 7.1
    Jesper Pedersen Master

    A follow-up, before people starts complaining about the AdminObject step, an AdminObject can also implement ResourceAdapterAssocation, so the same trick can be used. The only difference is that the copy part needs to be done once the identify property is set.

  • 11. Re: Configure MQ Resource Adapter for MDB - JBoss 7.1
    Stig Henriksen Newbie

    Alright, thanks for clearing that up, Jesper!

  • 12. Re: Configure MQ Resource Adapter for MDB - JBoss 7.1
    Paul DuBon Newbie

    Thanks Jesper,

     

    So what about the other option of using AspectDomain in the similiar thread:  https://community.jboss.org/message/649907

    2. In Jboss 6 it was possible to configure MDBs with annotations, using JNDI admin Objects (mbeans) in *-ds.xml file. Additionally, to avoid hardcoded server config parameters, it was possible to use "AspectDomain" option, to inject necessary properties into MDB using Interceptors. At the moment I did not find any information about how to configure such an "AspectDomains" under JBOSS 7/7.1

     

    I similiarly noticed that I couldn't find @AspectDomain in the class path or any of the AS 7 jars.  Is this functionality no longer available or is it done by some other mechanism in AS7?

  • 13. Re: Configure MQ Resource Adapter for MDB - JBoss 7.1
    jaikiran pai Master

    Paul DuBon wrote:

     

     

    I similiarly noticed that I couldn't find @AspectDomain in the class path or any of the AS 7 jars.  Is this functionality no longer available or is it done by some other mechanism in AS7?

    @AspectDomain and AOP are no longer available in AS7.

     

     

    Paul DuBon wrote:

     

    2. In Jboss 6 it was possible to configure MDBs with annotations, using JNDI admin Objects (mbeans) in *-ds.xml file. Additionally, to avoid hardcoded server config parameters, it was possible to use "AspectDomain" option, to inject necessary properties into MDB using Interceptors.

    Do you have a code example so that I can understand better?

  • 14. Re: Configure MQ Resource Adapter for MDB - JBoss 7.1
    Paul DuBon Newbie

    2. In Jboss 6 it was possible to configure MDBs with annotations, using JNDI admin Objects (mbeans) in *-ds.xml file. Additionally, to avoid hardcoded server config parameters, it was possible to use  "AspectDomain" option, to inject necessary properties into MDB using Interceptors.

     

     

    This is text I was referencing from the other thread.  I am moving from Websphere to JBoss, never having used any previous version of JBoss, so I personally haven't done this before, but have been researching different mechanisms for configuring the MDB with environment specific properties.  However I had also seen an example of this in the following thread and based on the responses, I assume it worked:

    https://community.jboss.org/wiki/HowToConfigureEJB3MDBsForIBMWebsphereMQ

1 2 3 Previous Next