From users-return-20336-apmail-activemq-users-archive=activemq.apache.org@activemq.apache.org Mon Sep 07 22:30:07 2009 Return-Path: Delivered-To: apmail-activemq-users-archive@www.apache.org Received: (qmail 49138 invoked from network); 7 Sep 2009 22:30:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Sep 2009 22:30:07 -0000 Received: (qmail 69560 invoked by uid 500); 7 Sep 2009 22:30:07 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 69490 invoked by uid 500); 7 Sep 2009 22:30:07 -0000 Mailing-List: contact users-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@activemq.apache.org Delivered-To: mailing list users@activemq.apache.org Received: (qmail 69480 invoked by uid 99); 7 Sep 2009 22:30:07 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Sep 2009 22:30:07 +0000 X-ASF-Spam-Status: No, hits=1.1 required=10.0 tests=FORGED_HOTMAIL_RCVD2,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Sep 2009 22:29:56 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1MkmiN-0006iA-5M for users@activemq.apache.org; Mon, 07 Sep 2009 15:29:35 -0700 Message-ID: <25337375.post@talk.nabble.com> Date: Mon, 7 Sep 2009 15:29:35 -0700 (PDT) From: sbuster To: users@activemq.apache.org Subject: Re: Another XA Transaction question In-Reply-To: <25331346.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: stevebuster911@hotmail.com References: <25331346.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org phil, either you response didn't come through, or I just don't see it. Did you have a suggestion? sbuster wrote: > > I'm using ActiveMQ 5.2 with WebSphere 7.0 and Sun JavaDB 10.x. Pretty > standard requirement, I have a message that arrives on a Queue, gets > pulled off with Message Drive Bean and needs to be directly insert into > JavaDB. However, when I thrown an exception inside my MDB to test the > rollback capabilities, the database is rolled back, the the messages is > never rolled back. The message is never placed back on the queue, it gets > consumed somehow. I have "transaction required" set in the MDB > deployment file(see below) and I've even tried changing the ra.xml file > for ActiveMQ to specifically state ActiveMQXAConnection factory. Can > anyone help? > > > > > > ejb deployment file > > xmlns="http://java.sun.com/xml/ns/j2ee" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee > http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"> > MessageEngine2 > > > EventConsumer > cat.cw.messaging.EventConsumerBean > javax.jms.MessageListener > Container > javax.jms.Queue > > > > destinationType > > javax.jms.Queue > > > > > > jdbc/NSSampleDB > javax.sql.DataSource > Container > Shareable > > > > > > > EventConsumer > * > > Required > > > > > > MDB > public void onMessage(javax.jms.Message msg) { > > > InitialContext ctx = null; > Connection con = null; > PreparedStatement stmt = null; > try { > String txtMsg = null; > if(msg instanceof BytesMessage){ > txtMsg = readByteData((BytesMessage)msg); > }else{ > txtMsg = ((TextMessage)msg).getText(); > } > ctx = new InitialContext(); > DataSource ds = (DataSource)ctx.lookup("jdbc/NSSampleDB"); > con = ds.getConnection(); > con.setAutoCommit(false); > stmt = con.prepareStatement("insert into app.messages(message) > values(?)"); > > stmt.setString(1,txtMsg); > int result = stmt.executeUpdate(); > if(txtMsg.equalsIgnoreCase("error")){ > throw new Exception("error"); > } > //con.commit(); > System.out.println("inserted message:"); > > > } catch (Exception e) { > // TODO Auto-generated catch block > fMessageDrivenCtx.setRollbackOnly(); > System.out.println(e.getMessage()); > }finally{ > try{ > stmt.close(); > con.close(); > }catch(Exception e){} > } > } > -- View this message in context: http://www.nabble.com/Another-XA-Transaction-question-tp25331346p25337375.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.