Failed Attempt to integrate JBOSS AS with Websphere MQ
jeremyojeremy Feb 4, 2010 11:46 PMHello people,
Looking for some assistance with integrating WSMQ with JBOSS 5 GA,
Here is the problem:
Attempts to integrate JBOSS AS with Websphere MQ
Versions and Operating Systems:
Machine 1: (172.19.1.4)
· Red Hat Enterprise Linux Server release 5.4 (Tikanga)
· JBOSS-5.1.0
Machine 2: (172.19.1.14)
· Windows Server 2003 R2 Standard Edition
· IBM Websphere MQ 7 (Trial)
Articles Followed / Resourced:
· http://community.jboss.org/wiki/JBossEAP5IntegrationwithWebSphereMQ
· http://community.jboss.org/wiki/UsingWebSphereMQSeriesWithJBossAsPart4
Procedure Followed:
Define Test Queue Manager and test Queues in Websphere MQ as detailed below:
Queue Manager: ExampleQM
Queue:TEST.QUEUE
Install the Websphere MQ resource adapter (wmq.jmsra.rar) in JBOSS
Define Connection Factory wmqcf-ds.xml in JBOSS JNDI as :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<connection-factories>
<tx-connection-factory>
<jndi-name>wmqcf</jndi-name>
<rar-name>wmq.jmsra.rar</rar-name>
<use-java-context>true</use-java-context>
<connection-definition>javax.jms.ConnectionFactory</connection-definition>
<jmx-invoker-name>jboss:service=invoker,type=jrmp</jmx-invoker-name>
<min-pool-size>0</min-pool-size>
<max-pool-size>10</max-pool-size>
<blocking-timeout-millis>30000</blocking-timeout-millis>
<idle-timeout-minutes>30</idle-timeout-minutes>
<prefill>false</prefill>
<background-validation>false</background-validation>
<background-validation-millis>0</background-validation-millis>
<validate-on-match>true</validate-on-match>
<statistics-formatter>org.jboss.resource.statistic.pool.JBossDefaultSubPoolStatisticFormatter</statistics-formatter>
<isSameRM-override-value>false</isSameRM-override-value>
<allocation-retry>0</allocation-retry>
<allocation-retry-wait-millis>5000</allocation-retry-wait-millis>
<config-property type="java.lang.String" name="channel">SYSTEM.DEF.SVRCONN</config-property>
<config-property type="java.lang.String" name="hostName">172.19.1.14</config-property>
<config-property type="java.lang.String" name="port">1414</config-property>
<config-property type="java.lang.String" name="queueManager">ExampleQM</config-property>
<config-property type="java.lang.String" name="transportType">CLIENT</config-property>
<application-managed-security xsi:type="securityMetaData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">JmsXARealm</application-managed-security>
<metadata/>
<xa-resource-timeout>0</xa-resource-timeout>
<xa-transaction/>
</tx-connection-factory>
</connection-factories>
Define Destination QUEUE wmq.jmsra-ds.xml as:
<connection-factories>
<mbean code="org.jboss.resource.deployment.AdminObject"
name="jca.wmq:name=ivtqueue">
<!-- Bind this AdminObject with the JNDI name IVTQueue -->
<attribute name="JNDIName">IVTQueue</attribute>
<!-- this MBean depends on the WebSphere MQ resource adapter -->
<depends optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='wmq.jmsra.rar'</depends>
<!-- this admin object is a javax.jms.Queue -->
<attribute name="Type">javax.jms.Queue</attribute>
<!--
Configuration for Queue TEST.QUEUE on queue manager ExampleQM. All messages sent
to this queue will have their expiry time overridden so that messages never expire
-->
<attribute name="Properties">
baseQueueManagerName=ExampleQM
baseQueueName=TEST.QUEUE
</attribute>
</mbean>
</connection-factories>
Attempt to deploy simple test EJB3 Message Driven Bean to listen for messages arriving on queue defined in JNDI as IVTQueue which references MQ Queue TEST.QUEUE:
package au.com.loftusit.mqtest;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.ejb.MessageDriven;
import javax.ejb.ActivationConfigProperty;
import org.jboss.annotation.ejb.ResourceAdapter;
public @MessageDriven(name = "testbean", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "IVTQueue")})
@ResourceAdapter("wmq.jmsra.rar")
class WMQMDBTest implements MessageListener {
private static final Logger LOGGER = Logger.getLogger(WMQMDBTest.class
.toString());
public void onMessage(Message message) {
LOGGER.log(Level.INFO, message.toString());
}
}
Problem
When deploying Message Driven Bean detailed above we run into class cast exception errors receive the following errors in the JBOSS Log:
14:50:14,555 WARN [JmsActivation] Failure in jms activation org.jboss.resource.adapter.jms.inflow.JmsActivationSpec@855d52(ra=org.jboss.resource.adapter.jms.JmsResourceAdapter@6cad07 destination=IVTQueue destinationType=null 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_28121199.invoke(SessionAspect_z_handleCreateConnectionConsumer_28121199.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)
Conclusion
The lack of thorough documentation regarding setting up JCA / JMS /Websphere MQ connections has caused us significant time wastage. We would greatly appreciate a working example using the WS MQ resource Adapter within JBOSS to perform CLIENT POINT to POINT messaging.
Regards,
Jeremy O'Donohue
Loftus IT