ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » unable to obtain JMS local transaction for JBOSS EAP 6.1

Post new topic  Reply to topic
 unable to obtain JMS local transaction for JBOSS EAP 6.1 « View previous topic :: View next topic » 
Author Message
20.modha
PostPosted: Tue Sep 17, 2013 11:15 am    Post subject: unable to obtain JMS local transaction for JBOSS EAP 6.1 Reply with quote

Newbie

Joined: 17 Sep 2013
Posts: 1

Hi All,

We are in process of migrating one of our application which is running on WAS 5.1 to JBOSS EAP 6.1.

The application has a POJO which uses JMS for inbound message processing. It doesn't uses any user transaction only local JMS transactions.

When I try to run the same code on JBOSS EAP 6.1 I'm unable to obtain JMS local transactions while connecting to IBM MQ 6.x using a IBM's MQ resource adapter. I have also included extended transaction support jar (com.ibm.mqetclient.jar). But still I'm unable to get transacted JMS session.

The issue over here is that when I use

session = conn.createQueueSession(true,Session.AUTO_ACKNOWLEDGE);

the session that I'm getting is not transacted, even when I pass "true" to the createQueueSession(boolean transacted, int acknowledgeMode) method. I'm not sure what am I doing wrong over here . Also, the same code is able to provide me a transacted JMS session on WAS 5.1 without using user transactions I have spent lot of days debugging this, on how to obtain local JMS transaction without using a user transaction on JBOSS, but didn't have any luck. Any insight or help in resolving this is greatly appreciated.

I'm attaching the code and configuration files that I have used. Kindly let me know if you all see any issues with either of them .

1) Here's my POJO JMS code, which I'm invoking through a servlet.


Code:
    package com.example.test; 
     
    import javax.jms.JMSException; 
    import javax.jms.Message; 
    import javax.jms.MessageListener; 
    import javax.jms.Queue; 
    import javax.jms.QueueConnection; 
    import javax.jms.QueueConnectionFactory; 
    import javax.jms.QueueReceiver; 
    import javax.jms.QueueSession; 
    import javax.jms.TextMessage; 
    import javax.naming.Context; 
    import javax.naming.InitialContext; 
    import javax.naming.NamingException; 
     
    public class QueueConnectionTest implements MessageListener{ 
         
        private String jndiConnectionFactoryName = null; 
        private String jndiQueueName = null; 
        private QueueConnectionFactory factory = null; 
        private QueueConnection conn = null; 
        private QueueReceiver receiver = null; 
        private QueueSession session = null; 
        private Queue testQueue = null; 
         
        public QueueConnectionTest(String jndiConnectionFactoryName, String jndiQueueName){ 
            this.jndiConnectionFactoryName = jndiConnectionFactoryName; 
            this.jndiQueueName = jndiQueueName;         
        } 
         
        public void initilize(){ 
            if(this.jndiConnectionFactoryName!=null && this.jndiQueueName!=null){ 
                try{ 
                    Context context = new InitialContext(); 
                    factory = (QueueConnectionFactory) context.lookup(this.jndiConnectionFactoryName); 
                    if(factory!=null){ 
                        testQueue = (Queue) context.lookup(this.jndiQueueName); 
                        if(factory!=null && testQueue!=null){ 
                            conn =  factory.createQueueConnection(); 
                            session = conn.createQueueSession(true,QueueSession.AUTO_ACKNOWLEDGE); 
                            receiver = session.createReceiver(testQueue); 
                            receiver.setMessageListener(this); 
                            conn.start(); 
                            System.out.println(":::: Receiver STARTED for accepting messages ::::");                     
                        }     
                    } 
                }catch(NamingException nx){ 
                    nx.printStackTrace(); 
                }catch(JMSException ex){ 
                    ex.printStackTrace(); 
                } 
            } 
        }     
         
         
        public void onMessage(Message msg) { 
            // TODO Auto-generated method stub 
            if(msg!=null && msg instanceof TextMessage){ 
                TextMessage txtMsg = (TextMessage)msg; 
                try { 
                    System.out.println("Got Message : "+txtMsg.getText()); 
                    System.out.println("Is session transacted...."+session.getTransacted());                 
                } catch (JMSException e) { 
                    e.printStackTrace(); 
                } 
            } 
        }     
     
    } 


Here's my servlet code which initializes and starts the inbound message receiver.

Code:
import java.io.IOException; 
import javax.servlet.ServletException; 
import javax.servlet.annotation.WebServlet; 
import javax.servlet.http.HttpServlet; 
import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 
 
/**
* Servlet implementation class ConnectionServlet
*/ 
@WebServlet("/ConnectionServlet") 
public class ConnectionServlet extends HttpServlet { 
    private static final long serialVersionUID = 1L; 
       
    /**
     * @see HttpServlet#HttpServlet()
     */ 
    public ConnectionServlet() { 
        super(); 
        // TODO Auto-generated constructor stub 
    } 
 
    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */ 
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 
        // TODO Auto-generated method stub 
        doPost(request,response); 
    } 
 
    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */ 
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 
        // TODO Auto-generated method stub 
        QueueConnectionTest qConn = new QueueConnectionTest("jboss/jms/BPJMSQueueConnectionFactory","jboss/jms/BPJMSInboundQueue"); 
        qConn.initilize();         
    } 
 


I'm also attaching the WMQ resource adapter configuration, which I have used for standalone-full.xml
Code:
    <subsystem xmlns="urn:jboss:domain:resource-adapters:1.1"> 
        <resource-adapters> 
            <resource-adapter> 
                <archive>wmq.jmsra.rar</archive> 
                <transaction-support>LocalTransaction</transaction-support> 
                <config-property name="traceEnabled">true</config-property> 
                <config-property name="traceLevel">3</config-property> 
                <connection-definitions> 
                    <connection-definition class-name="com.ibm.mq.connector.outbound.ManagedQueueConnectionFactoryImpl" jndi-name="java:jboss/jms/BPJMSQueueConnectionFactory" enabled="true" use-java-context="true" pool-name="BPJMSQueueConnectionFactoryPool"> 
                        <config-property name="port">1417</config-property> 
                        <config-property name="hostName">xx.xx.xx.xxx</config-property> 
                        <config-property name="channel">MQ.CLIENT</config-property> 
                        <config-property name="transportType">CLIENT</config-property> 
                        <config-property name="queueManager">MYQGMR</config-property> 
                        <pool> 
                            <min-pool-size>1</min-pool-size> 
                            <max-pool-size>10</max-pool-size> 
                        </pool> 
                    </connection-definition>                         
                </connection-definitions> 
                <admin-objects> 
                    <admin-object class-name="com.ibm.mq.connector.outbound.MQQueueProxy" jndi-name="java:jboss/jms/BPJMSInboundQueue" enabled="true" use-java-context="true" pool-name="BPJMSInboundQueuePool"> 
                        <config-property name="baseQueueName">INBOUND.QUEUE.TESTING</config-property> 
                        <config-property name="baseQueueManagerName">MYQGMR</config-property> 
                        <config-property name="targetClient">JMS</config-property> 
                    </admin-object>                         
                </admin-objects> 
            </resource-adapter> 
        </resource-adapters> 
    </subsystem> 


so whenever I run my test, I always get the below message in the logs



13:45:56,735 INFO [stdout] (http-localhost/192.168.245.128:8080-1) Got Message : Hello



13:45:56,735 INFO [stdout] (http-localhost/192.168.245.128:8080-1) Is session transacted....false



Can someone please help me out in how to obtain transacted JMS session ?


Regard,
Chintan
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Sep 19, 2013 7:42 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

You need to use the J2EE MDB model and not the servlet model.
That's why you have a J2EE server and not just a web server.

In WAS the global transaction superseeds the session setting for the MQ session.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » unable to obtain JMS local transaction for JBOSS EAP 6.1
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.