3 Replies Latest reply on Jul 6, 2006 4:31 PM by Jim Ross

    Trying to override from SpyDestination to use MQSeries inste

    Jim Ross Newbie

      I?m trying to get JBoss v4.0.3SP1 to read/write to/from MQSeries v5.3. I can successfully write to the MQSeries queue, but am failing when I attempt to read from it. Specifically, I get:

      java.lang.ClassCastException: com.ibm.mq.jms.MQQueue
       at org.jboss.mq.SpyConnectionConsumer.<init>(SpyConnectionConsumer.java:91)
       at org.jboss.mq.SpyConnection.createConnectionConsumer(SpyConnection.java:168)
       at org.jboss.ejb3.mdb.MDB.innerCreateQueue(MDB.java:308)
       at org.jboss.ejb3.mdb.MDB.innerCreate(MDB.java:232)
       at org.jboss.ejb3.mdb.MDB.start(MDB.java:136)
       at org.jboss.ejb3.mdb.MessageDrivenManager.startService(MessageDrivenManager.java:90) ...

      Looking at the SpyConnectionConsumer code, it appears that it is assuming that whatever it gets off the queue is a SpyDestination. I am trying to figure out how to tell JBoss that it?s actually something else.

      Here is what I?ve tried so far:
      1. I spent a lot of time with the http://wiki.jboss.org/wiki/Wiki.jsp?page=UsingWebSphereMQSeriesWithJBossASPartI (and part 2). Using the downloadable examples that come with it, I was able to modify the configuration to get it to successfully read and write from my MQSeries queue. This success occurred while running the tutorial examples in the stand-alone mode that they are written in. However, when I transferred that knowledge over into my real application, I am still getting the ClassCastException. The difference being that my real application is configured as an MDB that launches as JBoss is coming up. So I get the ClassCastException before it the logic ever gets to my code. This contrasts with the tutorial example that does not attempt to read the queue until I start the test program.
      2. So I deduced that the problem is with the way I have my queue configured in the JBoss configuration files. I then spent a lot of time studying the ?MQSeries/JBoss MDB/3rd Party Messaging? thread in the forum. Specifically, this post http://www.jboss.org/index.html?module=bb&op=viewtopic&t=1070&start=18. It seems pcallies had a problem very similar to mine (and in fact, after spending the last three days trolling the web, it is the only reference I found that describes my problem). Several posts later, he describes a solution. The solution he describes involves the use of org.jboss.jms.jndi.JBossMQProvider. However, that class has since been deprecated and JNDIProviderAdapter is recommended instead. I?ve been studying that, and can?t figure out how to make it work. To make matters even harder, the XML files that pcallies describes in his solution don?t seem to exist in my version of JBoss.

      So I conclude that I need to configure JBoss to tell it that my queue needs to be processed as a wsmq destination, instead of as a SpyDestination. I just can?t figure out how to do it. Can anybody point me to some straightforward documentation that explains how to tell JBoss that the queue is an MQSeries queue?

      In the interest of full disclosure, I should admit I?m new to both JBoss and JMS, so I?m definitely hampered by my lack of experience.


        • 1. Re: Trying to override from SpyDestination to use MQSeries i
          Elias Ross Master

          You need to use the correct MQ series ConnectionFactory.

          • 2. Re: Trying to override from SpyDestination to use MQSeries i
            Jim Ross Newbie

            Here is the configuration from my jbossmq-destinations-service.xml that I've been trying to use. I think this is the correct MQ series ConnectionFactory, but maybe that's my problem.


            <mbean code="jmx.service.wsmq.WSMQConnectionFactory"
             <attribute name="JndiName">MyMQQueueConnectionFactory</attribute>
             <attribute name="JMSStyle">Queue</attribute>
             <attribute name="IsXA">false</attribute>
             <attribute name="QueueManagerName">QM_IESYS</attribute>
             <attribute name="HostName">myserver.mydomain.org</attribute>
             <attribute name="Channel">CHL.TO.APP</attribute>
             <attribute name="TransportType">MQJMS_TP_CLIENT_MQ_TCPIP</attribute>
             <mbean code="jmx.service.wsmq.WSMQDestination"
             <attribute name="JndiName">wsmq/HL7Outbound</attribute>
             <attribute name="JMSStyle">Queue</attribute>
             <attribute name="QueueManagerName">QM_IESYS</attribute>
             <attribute name="DestinationName">IESYS.RECV</attribute>
             <mbean code="jmx.service.wsmq.WSMQDestination"
             <attribute name="JndiName">wsmq/HL7Inbound</attribute>
             <attribute name="JMSStyle">Queue</attribute>
             <attribute name="QueueManagerName">QM_IESYS</attribute>
             <attribute name="DestinationName">IESYS.SEND</attribute>

            • 3. Re: Trying to override from SpyDestination to use MQSeries i
              Jim Ross Newbie

              For those interested, the missing piece that I could not deduce from the documentation, was the need for an annotation in my MDB class. Specifically:

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

              The annotation references the following which I stuck in the jms-ds.xml file:
              <!-- non XA provider loader and connection factory -->
               <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>
               <!-- The queue connection factory -->
               <attribute name="QueueFactoryRef">WSMQQueueConnectionFactory</attribute>
               <!-- The topic factory -->
               <attribute name="TopicFactoryRef">WSMQTopicConnectionFactory</attribute>
               <adapter-display-name>JMS Adapter</adapter-display-name>
               <!-- JCA 1.0 Comment out for JBoss 3.2.x / Remove it for JBoss 4.x -->
               <!-- <rar-name>jms-ra.rar</rar-name> -->
               <!-- JCA 1.5 Comment out for JBoss 4.x / Remove it for JBoss 3.2.x -->
               <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>
               <!-- <security-domain-and-application>JmsXARealm</security-domain-and-application> -->