|   | 
	 
  
    | 
RSS Feed - WebSphere MQ Support
 | 
RSS Feed - Message Broker Support
 |   
 
  
	     | 
	 | 
   
 
  
	|  MQ XA Weblogic JMSAdmin | 
	« View previous topic :: View next topic »  | 
   
  
  	
	  
		
		
		  | Author | 
		  Message
		 |  
		
		  | karthik_utd | 
		  
		    
			  
				 Posted: Fri Mar 20, 2009 12:54 pm    Post subject: MQ XA Weblogic JMSAdmin | 
				     | 
			   
			 
		   | 
		 
		
		   Novice
 
 Joined: 11 Apr 2007 Posts: 10
  
  | 
		  
		    
			  
				Hello all,
 
 
I have problems with XA transactions. I tried many many many different configs but none of them worked.
 
 
Environment:
 
Weblogic 10.0
 
IBM MQ Series 6.x (Don't know exact version).
 
 
This is what I did starting from the beginning:
 
 
Using JMSAdmin, I did:
 
 
def xaqcf(_NGMQMGR) qmgr(EUMOTO2D)
 
def q(_NGMMDBQueue) qmgr(EUMOTO2D) queue(EU.MOTO.OASYS.IN)
 
def q(_NGMReplyMDBQueue) qmgr(EUMOTO2D) queue(EU.MOTO.OASYS.OUT)
 
end
 
 
I created a JMS Server in weblogic with a target server amsMOTOSITNode1
 
I created a foreign server and I created a subdeployment for that with the subdeployment pointing to the JMS Server above.
 
I created Destinations    Connection Factories   for the foreign server.
 
 
Then I created an MDB. This guy upon getting a message does some stuff, writes to a database and commits. (I don't manually commit. It is Container managed transaction).
 
 
 
 
   
	| Code: | 
   
  
	
 
<?xml version="1.0" encoding="UTF-8"?>
 
<ejb-jar version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
 
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
 
 
   <enterprise-beans>
 
      <message-driven>
 
        <ejb-name>MDBTemplate</ejb-name>
 
         <ejb-class>com.test.MDBTesting</ejb-class>
 
         <messaging-type>javax.jms.MessageListener</messaging-type>
 
         <transaction-type>Container</transaction-type>
 
         <message-destination-type>javax.jms.Queue</message-destination-type>     
 
      </message-driven>
 
   </enterprise-beans>
 
 
    <assembly-descriptor>
 
        <container-transaction>
 
            <method>
 
                <ejb-name>MDBTemplate</ejb-name>
 
                <method-name>*</method-name>
 
            </method>
 
            <trans-attribute>Required</trans-attribute>
 
        </container-transaction>
 
    </assembly-descriptor>
 
 
</ejb-jar>
 
 
 
--------------------------------------------------------------------------------
 
 
 
<?xml version="1.0" encoding="UTF-8"?>
 
 
<!DOCTYPE weblogic-ejb-jar PUBLIC "-//BEA Systems, Inc.//DTD WebLogic 8.1.0 EJB//EN"
 
 "http://www.bea.com/servers/wls810/dtd/weblogic-ejb-jar.dtd">
 
 
<weblogic-ejb-jar>
 
 <description><![CDATA[Generated by XDoclet]]></description>
 
   <weblogic-enterprise-bean>
 
      <ejb-name>MDBTemplate</ejb-name>
 
      <message-driven-descriptor>
 
         <pool>
 
            <max-beans-in-free-pool>1</max-beans-in-free-pool>
 
            <initial-beans-in-free-pool>1</initial-beans-in-free-pool>
 
         </pool>
 
         <destination-jndi-name>NGM_OASYS_IN</destination-jndi-name>
 
         <connection-factory-jndi-name>NGM_EUMOTO2DQCF</connection-factory-jndi-name>
 
      </message-driven-descriptor>
 
      <reference-descriptor>
 
      </reference-descriptor>
 
   </weblogic-enterprise-bean>
 
 
</weblogic-ejb-jar>
 
 
-------------------------------------------------------------------------------
 
JMSAdmin:
 
 
   a  SWIFT_LISTEN              com.ibm.mq.jms.MQQueue
 
   a  FAX_LISTEN                com.ibm.mq.jms.MQQueue
 
   a  SWIFT_CS                  com.ibm.mq.jms.MQQueue
 
   a  SWIFT_IN                  com.ibm.mq.jms.MQQueue
 
   a  LM_RESULTS                com.ibm.mq.jms.MQQueue
 
   a  MATCH                     com.ibm.mq.jms.MQQueue
 
   a  EXCEPTION_PROCESS         com.ibm.mq.jms.MQQueue
 
   a  OASYS_IN                  com.ibm.mq.jms.MQQueue
 
   a  CLINT_FX                  com.ibm.mq.jms.MQQueue
 
   a  CLINT_PNR                 com.ibm.mq.jms.MQQueue
 
   a  MULT_LM                   com.ibm.mq.jms.MQQueue
 
   a  SWIFT_ACK                 com.ibm.mq.jms.MQQueue
 
   a  MULT                      com.ibm.mq.jms.MQQueue
 
   a  EUMOTO2DQCF               com.ibm.mq.jms.MQXAQueueConnectionFactory
 
   a  SWIFT_OUT                 com.ibm.mq.jms.MQQueue
 
 
 
--------------------------------------------------------------------------------
 
Weblogic Destinations on the Foreign server mentioned above:
 
 
Destination Name   JNDI Name(as weblogic    JNDI Name(As given by JMSAdmin)
 
            knows it)
 
 
 NGM_CLINT_FX       NGM_CLINT_FX       CLINT_FX 
 
 
 NGM_CLINT_PNR       NGM_CLINT_PNR       CLINT_PNR 
 
 
 
 NGM_EXCEPTION_PROCESS   NGM_EXCEPTION_PROCESS    EXCEPTION_PROCESS 
 
 
 
 NGM_FAX_LISTEN    NGM_FAX_LISTEN       FAX_LISTEN 
 
 
 
 NGM_OASYS_IN       NGM_OASYS_IN       OASYS_IN 
 
 
 NGM_LM_RESULTS    NGM_LM_RESULTS       LM_RESULTS    
 
 
 NGM_MATCH       NGM_MATCH       MATCH    
 
 
 NGM_MULT_LM       NGM_MULT_LM       MULT_LM 
 
 
 NGM_SWIFT_ACK       NGM_SWIFT_ACK       SWIFT_ACK 
 
 
 NGM_SWIFT_CS       NGM_SWIFT_CS       SWIFT_CS 
 
 
 NGM_SWIFT_IN       NGM_SWIFT_IN       SWIFT_IN 
 
 
 
 NGM_SWIFT_LISTEN    NGM_SWIFT_LISTEN    SWIFT_LISTEN    
 
 
 NGM_SWIFT_OUT       NGM_SWIFT_OUT       SWIFT_OUT 
 
 
--------------------------------------------------------------------------------
 
weblogic connection factories on the Foreign server mentioned above:
 
 
 Name           Local JNDI Name    Remote JNDI Name 
 
 
 NGM_EUMOTO2DQCF    NGM_EUMOTO2DQCF    EUMOTO2DQCF 
 
 
 
 | 
   
 
 
 
I will continue my post as a reply. I am concerned about how the formatting will be..[/code] | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | karthik_utd | 
		  
		    
			  
				 Posted: Fri Mar 20, 2009 1:01 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		   Novice
 
 Joined: 11 Apr 2007 Posts: 10
  
  | 
		  
		    
			  
				Cool, It came neat..
 
 
 
Continued...
 
 
 
Below is my MDB. The database and the queue the MDB is listening to are working is a single unit and as expected. If I don't rollback,  because it is container managed transaction, both of them commit. If I set context.setRollbackOnly(), they both rollback as expected:
 
 
   
	| Code: | 
   
  
	
 
package com.abc;
 
 
import java.sql.Connection;
 
import java.util.Random;
 
 
import javax.ejb.EJBException;
 
import javax.ejb.MessageDrivenBean;
 
import javax.ejb.MessageDrivenContext;
 
import javax.jms.Message;
 
import javax.jms.MessageListener;
 
import javax.naming.InitialContext;
 
import javax.sql.DataSource;
 
public class XATestClass1234 implements MessageDrivenBean, MessageListener {
 
 
   private static final long serialVersionUID = 4286852471477024691L;
 
 
   private MessageDrivenContext context = null;
 
   DataSource ds = null;
 
   Connection con = null;
 
 
   public void ejbRemove() throws EJBException {
 
 
 
   }
 
 
   public void setMessageDrivenContext(MessageDrivenContext arg0)
 
         throws EJBException {
 
      System.out.println("setting context");
 
      this.context = arg0;
 
   }
 
 
   public void onMessage(Message arg0) {
 
      System.out.println("on message");
 
      try {
 
         int r = new Random().nextInt();
 
         con.createStatement().executeQuery("insert into ku_table values('"+r+"', 'karthik')");
 
         if(r%2==0) {
 
            System.out.println("even number generated: "+r+". unbearable condition.. rollback..");
 
            throw new Exception();
 
         }
 
         System.out.println("odd number generated: "+r+". desirable condition.. will commit..");
 
         con.createStatement().executeQuery("update ku_table set VAL='dartik' where theint='"+r+"'");
 
      } catch (Exception e) {
 
         context.setRollbackOnly();
 
         e.printStackTrace();
 
      }
 
   }
 
 
   public void ejbCreate() {
 
      System.out.println("EJB Create");
 
      try {
 
         InitialContext context = new InitialContext();
 
         ds = (DataSource) context.lookup("motongds");
 
         con = ds.getConnection();
 
      } catch(Exception e) {
 
         e.printStackTrace();
 
      }
 
   }
 
 
}
 
 
 
 | 
   
 
 
 
It is just some basic test code that I wrote. It basically generates a random number and if it is even, it throws an exception and I check to see if both the queue and the database rolled back.. They are..
 
 
If an odd number is generated, I see whether both the database and the MQ are committing, and they are..
 
 
 
Now, my problem starts.. 
 
 
 
Now I include third resource, which is another MQ. For simplicity, I removed the database from the picture as I am confident that it will work fine.. The third resource is another MQ. The challenge now for me is for the MDB to pick a message and consume it, and the second MQ must receive some message and both of them should be a single unit of work. But it doesn't work:
 
 
Below is my code:
 
 
   
	| Code: | 
   
  
	
 
package com.test;
 
 
import javax.ejb.EJBException;
 
import javax.ejb.MessageDrivenBean;
 
import javax.ejb.MessageDrivenContext;
 
import javax.jms.JMSException;
 
import javax.jms.Message;
 
import javax.jms.MessageListener;
 
import javax.jms.MessageProducer;
 
import javax.jms.QueueConnection;
 
import javax.jms.QueueSender;
 
import javax.jms.QueueSession;
 
import javax.jms.Session;
 
import javax.jms.XAQueueConnection;
 
import javax.jms.XAQueueConnectionFactory;
 
import javax.jms.XAQueueSession;
 
import javax.naming.Context;
 
import javax.naming.InitialContext;
 
import javax.naming.NamingException;
 
 
import com.ibm.mq.jms.MQQueue;
 
 
public class MDBTesting implements MessageListener, MessageDrivenBean  {
 
   private static int i = 1;
 
   private static final long serialVersionUID = 8889211012077622333L;
 
   private MessageDrivenContext context = null;
 
   
 
   public void ejbRemove() throws EJBException {
 
      System.out.println("ejb remove");
 
   }
 
 
   public void ejbCreate() {
 
      System.out.println("ejb Create");
 
   }
 
   
 
   public void setMessageDrivenContext(MessageDrivenContext arg0)
 
         throws EJBException {
 
      this.context = arg0;
 
   }
 
 
   public void onMessage(Message arg0) {
 
      try {
 
         System.out.println("msg received "+ i);
 
         //putMessage("NGM_FAX_LISTEN");
 
         //putMessage("NGM_CLINT_PNR")) ;
 
         putxaMessage("NGM_FAX_LISTEN");
 
            
 
 
         if(i % 2 != 0) {
 
            i++;
 
         } else {
 
            i++;
 
            System.out.println("trowing exception");
 
            throw new Exception("Should rollback!");
 
         }
 
      } catch(Exception e) {
 
         e.printStackTrace();
 
         System.out.println("setting rollback only");
 
         context.setRollbackOnly();
 
      } 
 
   }
 
   
 
   public final static String JNDI_FACTORY = "weblogic.jndi.WLInitialContextFactory";
 
   private MQQueue xaqueue ;
 
   private XAQueueConnectionFactory xaqcf;
 
 
   public boolean putxaMessage(String queueName) throws Exception {
 
      boolean put = false;
 
      System.out.println("=> Placing xa message on WLReplyQueue...");
 
      Context jndiContext = null;
 
        try {
 
            jndiContext = new InitialContext();
 
        } catch (NamingException e) {
 
            System.out.println("xa Could not create JNDI API " +
 
                    "context: " + e.toString());
 
            return false;
 
        } catch(Exception e) {
 
           System.out.println(e.getMessage());
 
           return false;
 
        }
 
      XAQueueConnection queueConnection = null;
 
      XAQueueSession queueSession = null;
 
 
        try {
 
           xaqcf = (XAQueueConnectionFactory) jndiContext.lookup("NGM_EUMOTO2DQCF");
 
           xaqueue = (MQQueue) jndiContext.lookup(queueName);
 
            xaqueue.setTargetClient(com.ibm.mq.jms.JMSC.MQJMS_CLIENT_NONJMS_MQ);
 
        } catch (NamingException e) {
 
            System.out.println("xa JNDI API lookup failed: " +
 
                    e.toString());
 
            return false;
 
        } 
 
        
 
        
 
 
      try {
 
         queueConnection = xaqcf.createXAQueueConnection();
 
         queueConnection.start();
 
         queueSession = queueConnection.createXAQueueSession();
 
         try {
 
            MessageProducer sender = queueSession.createProducer(xaqueue);
 
            sender.send(queueSession.createMessage());
 
            
 
            System.out.println("=>xa Message sent!");
 
         } catch(Exception e) {
 
            e.printStackTrace();
 
            System.out.println("----------------------------------------");
 
            if (e instanceof JMSException) {
 
               JMSException ex = (JMSException) e;
 
               ex.getLinkedException().printStackTrace();
 
                String msg = "JMS error: "+ex.getMessage();
 
                if(MQReasonCodeResolver.canResolve(ex)) {
 
                  msg += " "+MQReasonCodeResolver.resolve(ex);
 
                }
 
                System.out.println("Message: "+msg);
 
               
 
            }       else {
 
               System.out.println("Not JMS Exception");
 
            }
 
         }
 
         
 
         put = true;
 
      } catch (Exception e) {
 
         System.out.println("Exception: ");
 
         e.printStackTrace();
 
 
         if (e instanceof JMSException) {
 
            ((JMSException) e).getLinkedException().printStackTrace();
 
         }
 
 
      } 
 
      return put;
 
   }
 
 
 
}
 
 
 | 
   
 
 
 
I will continue as a reply.. | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | karthik_utd | 
		  
		    
			  
				 Posted: Fri Mar 20, 2009 1:09 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		   Novice
 
 Joined: 11 Apr 2007 Posts: 10
  
  | 
		  
		    
			  
				With this approach, I get the following exception:
 
 
   
	| Code: | 
   
  
	
 
<Mar 20, 2009 8:23:32 PM GMT> <Notice> <Stdout> <BEA-000000> <Exception:>
 
        at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:567)
 
        at com.ibm.mq.jms.MQMessageProducer.sendInternal(MQMessageProducer.java:1760)
 
        at com.ibm.mq.jms.MQMessageProducer.send(MQMessageProducer.java:1070)
 
        at com.ibm.mq.jms.MQMessageProducer.send(MQMessageProducer.java:1123)
 
        at com.test.MDBTesting.putxaMessage(MDBTesting.java:100)
 
        at com.test.MDBTesting.onMessage(MDBTesting.java:46)
 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 
        at java.lang.reflect.Method.invoke(Method.java:585)
 
        at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)
 
        at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
 
        at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
 
        at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
 
        at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
 
        at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
 
        at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
 
        at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
 
        at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
 
        at $Proxy75.onMessage(Unknown Source)
 
        at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:466)
 
        at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:371)
 
        at weblogic.ejb.container.internal.JMSMessagePoller.processOneMessage(JMSMessagePoller.java:330)
 
        at weblogic.ejb.container.internal.JMSMessagePoller.pollContinuously(JMSMessagePoller.java:404)
 
        at weblogic.ejb.container.internal.JMSMessagePoller.pollForParent(JMSMessagePoller.java:527)
 
        at weblogic.ejb.container.internal.JMSMessagePoller.run(JMSMessagePoller.java:543)
 
        at java.lang.Thread.run(Thread.java:595)
 
com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2072
 
        at com.ibm.mq.MQQueue.putMsg2(MQQueue.java:1687)
 
        at com.ibm.mq.jms.MQMessageProducer.sendInternal(MQMessageProducer.java:1732)
 
        at com.ibm.mq.jms.MQMessageProducer.send(MQMessageProducer.java:1070)
 
        at com.ibm.mq.jms.MQMessageProducer.send(MQMessageProducer.java:1123)
 
        at com.test.MDBTesting.putxaMessage(MDBTesting.java:100)
 
        at com.test.MDBTesting.onMessage(MDBTesting.java:46)
 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 
        at java.lang.reflect.Method.invoke(Method.java:585)
 
        at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)
 
        at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
 
        at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
 
        at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
 
        at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
 
        at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
 
        at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
 
        at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
 
        at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
 
        at $Proxy75.onMessage(Unknown Source)
 
        at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:466)
 
        at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:371)
 
        at weblogic.ejb.container.internal.JMSMessagePoller.processOneMessage(JMSMessagePoller.java:330)
 
        at weblogic.ejb.container.internal.JMSMessagePoller.pollContinuously(JMSMessagePoller.java:404)
 
        at weblogic.ejb.container.internal.JMSMessagePoller.pollForParent(JMSMessagePoller.java:527)
 
        at weblogic.ejb.container.internal.JMSMessagePoller.run(JMSMessagePoller.java:543)
 
        at java.lang.Thread.run(Thread.java:595)
 
 
 | 
   
 
 
 
Which has got to do with some syncpoint etc etc exception code 2072 and everything.. If so far what I have done is correct, please let me know how do I get this working. I am willing to try anything.
 
 
I also tried the below:
 
 
   
	| Code: | 
   
  
	
 
package com.abc;
 
 
import java.sql.Connection;
 
import java.util.Hashtable;
 
import java.util.Random;
 
 
import javax.ejb.EJBException;
 
import javax.ejb.MessageDrivenBean;
 
import javax.ejb.MessageDrivenContext;
 
import javax.jms.JMSException;
 
import javax.jms.Message;
 
import javax.jms.MessageListener;
 
import javax.jms.QueueConnection;
 
import javax.jms.QueueConnectionFactory;
 
import javax.jms.QueueSender;
 
import javax.jms.QueueSession;
 
import javax.jms.Session;
 
import javax.naming.Context;
 
import javax.naming.InitialContext;
 
import javax.naming.NamingException;
 
import javax.sql.DataSource;
 
 
import com.ibm.mq.jms.MQQueue;
 
 
public class XATestClass32141 implements MessageDrivenBean, MessageListener {
 
 
   private static final long serialVersionUID = 4286852471477024691L;
 
 
   DataSource ds = null;
 
   Connection con = null;
 
 
   public void ejbRemove() throws EJBException {
 
 
 
   }
 
 
   public void setMessageDrivenContext(MessageDrivenContext arg0)
 
         throws EJBException {
 
      System.out.println("setting context");
 
   }
 
 
   public void onMessage(Message arg0) throws RuntimeException {
 
      System.out.println("on message");
 
      try {
 
         putMessage(arg0);
 
      } catch (Exception e) {
 
         //context.setRollbackOnly();
 
         throw new RuntimeException(e);
 
      }
 
   }
 
 
   private com.ibm.mq.jms.MQQueue  queue ;
 
   private javax.jms.QueueConnectionFactory qcf;
 
   public final static String JNDI_FACTORY = "weblogic.jndi.WLInitialContextFactory";
 
 
   public void putMessage(javax.jms.Message msg) throws Exception {
 
      boolean put = false;
 
      System.out.println("=> Placing message on WLReplyQueue...");
 
      Context jndiContext = null;
 
        Hashtable<String, String> env = new Hashtable<String, String>();
 
        env.put(Context.INITIAL_CONTEXT_FACTORY,JNDI_FACTORY);
 
        try {
 
            jndiContext = new InitialContext(env);
 
        } catch (NamingException e) {
 
            System.out.println("Could not create JNDI API " +
 
                    "context: " + e.toString());
 
            return;
 
        } catch(Exception e) {
 
           System.out.println(e.getMessage());
 
           return;
 
        }
 
      QueueConnection queueConnection = null;
 
      QueueSession queueSession = null;
 
      QueueSender queueSender = null;
 
 
        try {
 
           qcf = (QueueConnectionFactory) jndiContext.lookup("MotoMQSenderQCF");
 
            queue = (MQQueue) jndiContext.lookup("MotoMQSenderQueue");
 
            queue.setTargetClient(com.ibm.mq.jms.JMSC.MQJMS_CLIENT_NONJMS_MQ);
 
        } catch (NamingException e) {
 
            System.out.println("JNDI API lookup failed: " +
 
                    e.toString());
 
            return;
 
        } catch (JMSException e2) {
 
           e2.printStackTrace();
 
        }
 
 
      try {
 
         queueConnection = qcf.createQueueConnection();
 
         queueSession = queueConnection.createQueueSession(false,
 
               Session.AUTO_ACKNOWLEDGE);
 
         queueSender = queueSession.createSender(queue);
 
 
         queueSender.send(msg);
 
         System.out.println("=> Message sent!");
 
         put = true;
 
      } catch (Exception e) {
 
         System.out.println("Exception: ");
 
         e.printStackTrace();
 
 
         if (e instanceof JMSException) {
 
            ((JMSException) e).getLinkedException().printStackTrace();
 
         }
 
 
      } finally {
 
 
         try {
 
            System.out.println("=> Closing Connection");
 
            queueSession.close();
 
            queueConnection.close();
 
         } catch (Exception e) {
 
            System.out.println("Exception: ");
 
            e.printStackTrace();
 
 
            if (e instanceof JMSException) {
 
               ((JMSException) e).getLinkedException().printStackTrace();
 
            }
 
         }
 
      }
 
      if(put == false)
 
         throw new Exception("Could not put msg. So throwing msg so that we can rollback!");
 
   }
 
 
   public void ejbCreate() {
 
      System.out.println("EJB Create");
 
      try {
 
         InitialContext context = new InitialContext();
 
         ds = (DataSource) context.lookup("motongds");
 
         con = ds.getConnection();
 
      } catch(Exception e) {
 
         e.printStackTrace();
 
      }
 
   }
 
 
}
 
 
 | 
   
 
 
 
If I rollback, only the MDB listening queue rollsback but the second queue is all committed and happy. This is an undesirable condition.
 
 
So, I guessed I have to set 
 
 
   
	| Code: | 
   
  
	
 
         queueSession = queueConnection.createQueueSession(false,
 
               Session.AUTO_ACKNOWLEDGE);
 
 | 
   
 
 
 
to
 
 
   
	| Code: | 
   
  
	
 
         queueSession = queueConnection.createQueueSession(true,
 
               Session.AUTO_ACKNOWLEDGE);
 
 
 | 
   
 
 
 
Now, though the MDB listening queue commits, the second queue does nothing. It doesn't get any message or anything.
 
 
I have also tried creating multiple queue connection factories JNDI names etc
 
 
I have tried to get a normal queueSession from an XAQueueSession and from that queueSession, create a queueSender and send the message. It  does send the message fine but doesn't rollback when a rollback is expected..
 
 
 
Please let me know what to do... 
 
 
Thank you,
 
Karthik. | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | karthik_utd | 
		  
		    
			  
				 Posted: Mon Mar 23, 2009 5:16 am    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		   Novice
 
 Joined: 11 Apr 2007 Posts: 10
  
  | 
		  
		    
			  
				Someone pls say something.. Not literally..
 
 
Please say something that can help me with the above posted problems. | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | Vitor | 
		  
		    
			  
				 Posted: Mon Mar 23, 2009 5:22 am    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		    Grand High Poobah
 
 Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA 
  | 
		  
		    
			  
				
   
	| karthik_utd wrote: | 
   
  
	| Someone pls say something..  | 
   
 
 
 
It's a plea from the heart!    
 
 
   
	| karthik_utd wrote: | 
   
  
	
 
Please say something that can help me with the above posted problems. | 
   
 
 
 
On the understanding I don't know a container managed MDB from a hole in the ground (and have more familiarity with holes in the ground), I'd start with that 2072 error. Are you sure the queue manager is participating properly in the XA managed transaction? Is the switch file configured correctly? Has the XA transaction properly started?
 
 
If that's all set up right, could be anything!    _________________ Honesty is the best policy.
 
Insanity is the best defence. | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | karthik_utd | 
		  
		    
			  
				 Posted: Tue Mar 24, 2009 6:12 am    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		   Novice
 
 Joined: 11 Apr 2007 Posts: 10
  
  | 
		  
		    
			  
				Thanks for the reply Vitor. I have no clue about MQ setup. It is done by the MQ support team. All we are given are the details such as port, qmanager, qname, channel, and hostname. I don't have any more details other than that. 
 
 
Neither do I know if the XA transaction has started properly. It is container managed transaction and I expect the container to do a good job.
 
 
Please help me more    | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | Vitor | 
		  
		    
			  
				 Posted: Tue Mar 24, 2009 6:17 am    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		    Grand High Poobah
 
 Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA 
  | 
		  
		    
			  
				
   
	| karthik_utd wrote: | 
   
  
	Please help me more    | 
   
 
 
 
   
	| Vitor wrote: | 
   
  
	| I don't know a container managed MDB from a hole in the ground  | 
   
 
 
 
So I'm not going to be any more help as you're out of my area of expertise.
 
 
Aside from if you've no clue about the MQ setup, the MQ support team should be your next port of call. They should at least have the answers to the questions I asked. _________________ Honesty is the best policy.
 
Insanity is the best defence. | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | karthik_utd | 
		  
		    
			  
				 Posted: Wed Mar 25, 2009 10:46 am    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		   Novice
 
 Joined: 11 Apr 2007 Posts: 10
  
  | 
		  
		    
			  
				I would like to thank you for your help. There was a small issue on my side that caused the issue. 
 
To make a resource available for XA transactions in weblogic, we have to use the following in ejb-jar.xml:
 
 
		<resource-ref>
 
		  <res-ref-name>jms/NGM_EUMOTO2DQCF</res-ref-name>
 
		  <res-type>javax.jms.QueueConnectionFactory</res-type>
 
		  <res-auth>Container</res-auth>
 
		  <res-sharing-scope>Shareable</res-sharing-scope>
 
		</resource-ref>
 
 
And the following in webjogic-ejb-jar.xml:
 
 
      <reference-descriptor>
 
      	<resource-description>
 
      		<res-ref-name>jms/NGM_EUMOTO2DQCF</res-ref-name>
 
      		<jndi-name>NGM_EUMOTO2DQCF</jndi-name>
 
      	</resource-description>
 
 
      </reference-descriptor>
 
 
 
Thanks again. I got it working now    
 
 
Regards,
 
Karthik. | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | karthik_utd | 
		  
		    
			  
				 Posted: Wed Mar 25, 2009 10:47 am    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		   Novice
 
 Joined: 11 Apr 2007 Posts: 10
  
  | 
		  
		    
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | 
		    
		   | 
		 
	   
	 | 
   
 
  
	     | 
	 | 
	Page 1 of 1 | 
   
 
 
 
  
  	
	  
		
		  
 
  | 
		  You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
  | 
  		 
	   
	 | 
   
 
  	 | 
	  |