Unable to set JBoss 5.1.0-GA consuming IBM MQ in annotated MDB
zecas Jul 28, 2011 7:13 AMHi,
I'm searching for some help on setting up JBoss to work out with a remote WebSphere MQ.
I've read some info around, but still I'm missing something, and I have some specific needs that I must conform to.
Versions:
JBoss 5.1.0 GA
Java JDK 1.6.0
WebSphere MQ 7.0.1 (on remote machine, 192.168.1.30:1414)
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"?> <connection-factories> <mbean code="org.jboss.resource.deployment.AdminObject" name="jboss.jca:service=WASDestination,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"> baseQueueManagerName=QM_server01 baseQueueName=TestQ </attribute> </mbean> <tx-connection-factory> <jndi-name>queue/TestQ</jndi-name> <xa-transaction></xa-transaction> <rar-name>wmq.jmsra.rar</rar-name> <connection-definition>javax.jms.ConnectionFactory</connection-definition> <config-property name="channel" type="java.lang.String">SYSTEM.DEF.SVRCONN</config-property> <config-property name="hostName" type="java.lang.String">192.168.1.30</config-property> <config-property name="port" type="java.lang.String">1414</config-property> <config-property name="queueManager" type="java.lang.String">QM_server01</config-property> <config-property name="transportType" type="java.lang.String">CLIENT</config-property> <!--<max-pool-size>20</max-pool-size>--> </tx-connection-factory> </connection-factories>
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:
package com.queue; import javax.ejb.ActivationConfigProperty; import javax.ejb.MessageDriven; import javax.ejb.TransactionManagement; import javax.ejb.TransactionManagementType; import javax.jms.Message; import javax.jms.MessageListener; @MessageDriven( activationConfig = { @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"), @ActivationConfigProperty(propertyName="destination", propertyValue="queue/TestQ") }) @TransactionManagement(TransactionManagementType.CONTAINER) public class TestMQ implements MessageListener { public void onMessage(Message message) { System.out.println(message.toString()); } }
This class was working fine, when not using MQ, but just JBoss Messaging with the following definition file "MyQIn-service.xml":
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <server> <mbean xmbean-dd="xmdesc/Queue-xmbean.xml" name="jboss.messaging.destination:service=Queue,name=MyQIncoming" code="org.jboss.jms.server.destination.QueueService"> <attribute name="JNDIName">queue/TestQ</attribute> <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends> <depends>jboss.messaging:service=PostOffice</depends> </mbean> </server>
Now when moving to MQ, replacing "MyQIn-service.xml" for "wmq.jmsra-ds.xml" it doesn't work anymore, throwing the following exception during server startup:
2011-07-25 14:52:13,313 INFO [org.jboss.ejb3.EJBContainer] (main) STARTED EJB: com.queue.TestMQ ejbName: TestMQ 2011-07-25 14:52:13,532 INFO [org.jboss.web.tomcat.service.deployers.TomcatDeployment] (main) deploy, ctxPath=/mq-web 2011-07-25 14:52:13,954 INFO [org.apache.coyote.http11.Http11Protocol] (main) Starting Coyote HTTP/1.1 on http-127.0.0.1-8080 2011-07-25 14:52:13,969 INFO [org.apache.coyote.ajp.AjpProtocol] (main) Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009 2011-07-25 14:52:13,969 INFO [org.jboss.bootstrap.microcontainer.ServerImpl] (main) JBoss (Microcontainer) [5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221634)] Started in 30s:937ms 2011-07-25 14:52:14,063 WARN [org.jboss.resource.adapter.jms.inflow.JmsActivation] (WorkManager(2)-4) Failure in jms activation org.jboss.resource.adapter.jms.inflow.JmsActivationSpec@10fab68(ra=org.jboss.resource.adapter.jms.JmsResourceAdapter@1157757 destination=queue/TestQ destinationType=javax.jms.Queue tx=true durable=false reconnect=10 provider=java:/DefaultJMSProvider user=null maxMessages=1 minSession=1 maxSession=15 keepAlive=60000 useDLQ=true DLQHandler=org.jboss.resource.adapter.jms.inflow.dlq.GenericDLQHandler DLQJndiName=queue/DLQ DLQUser=null DLQMaxResent=5) java.lang.ClassCastException: com.ibm.mq.jms.MQQueue cannot be cast to org.jboss.jms.destination.JBossDestination at org.jboss.jms.client.container.SessionAspect.handleCreateConnectionConsumer(SessionAspect.java:766) at org.jboss.aop.advice.org.jboss.jms.client.container.SessionAspect_z_handleCreateConnectionConsumer_14919969.invoke(SessionAspect_z_handleCreateConnectionConsumer_14919969.java) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.jms.client.container.ClosedInterceptor.invoke(ClosedInterceptor.java:170) at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:86) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.jms.client.delegate.ClientConnectionDelegate.createConnectionConsumer(ClientConnectionDelegate.java) at org.jboss.jms.client.JBossConnection.createConnectionConsumer(JBossConnection.java:140) at org.jboss.resource.adapter.jms.inflow.JmsServerSessionPool.setupConsumer(JmsServerSessionPool.java:289) at org.jboss.resource.adapter.jms.inflow.JmsServerSessionPool.start(JmsServerSessionPool.java:89) at org.jboss.resource.adapter.jms.inflow.JmsActivation.setupSessionPool(JmsActivation.java:656) at org.jboss.resource.adapter.jms.inflow.JmsActivation.setup(JmsActivation.java:359) at org.jboss.resource.adapter.jms.inflow.JmsActivation$SetupActivation.run(JmsActivation.java:729) at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:205) at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:260) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619)
I've searched around a bit, and found some people with similar problem, and the solution seems to be a bit complicated for my setup, because it appears that some JBoss specific classes/configurations to be used.
The main problem is that we have 2 different application servers, "JBoss 5.1.0GA" and "WebSphere AS 7.5", and the code must execute correctly in both environments. We start implementing this solution in JMS, because it would feel like a safer way not to be dependent on a specific application server.
At first glance, it appears the ClassCastException should be a problem in JBoss code? Or most probably there is something else in my config settings.
So can anyone please point me what I'm missing? Or what should I be looking for?
I was thinking about using "destination" property in MDB for a JNDI search and, in the config file "wmq.jmsra-ds.xml" (to be more exact), I would config all settings to connect to the MQ machine and the existing queue name.
Some examples contain "@ResourceAdapter(value = "wmq.jmsra.rar")" annotation on the MDB, that should be available in "...\jboss-5.1.0.GA\common\lib\jboss-ejb3-ext-api.jar", still it fells that I'll have to change code if I wanna deploy to the other environment, WebSphere. And I need it to run on both environments.
I've already invested some time with this situation, and I'm starting to feel the time pressure to solve this situation, so ANY help would be very welcome.
Thank You.