Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EC8EB99A1 for ; Sat, 3 Mar 2012 09:28:45 +0000 (UTC) Received: (qmail 10973 invoked by uid 500); 3 Mar 2012 09:28:45 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 10917 invoked by uid 500); 3 Mar 2012 09:28:44 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 10902 invoked by uid 99); 3 Mar 2012 09:28:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Mar 2012 09:28:44 +0000 X-ASF-Spam-Status: No, hits=0.6 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of claus.ibsen@gmail.com designates 209.85.215.45 as permitted sender) Received: from [209.85.215.45] (HELO mail-lpp01m010-f45.google.com) (209.85.215.45) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Mar 2012 09:28:40 +0000 Received: by lahe6 with SMTP id e6so3830513lah.32 for ; Sat, 03 Mar 2012 01:28:18 -0800 (PST) Received-SPF: pass (google.com: domain of claus.ibsen@gmail.com designates 10.152.102.173 as permitted sender) client-ip=10.152.102.173; Authentication-Results: mr.google.com; spf=pass (google.com: domain of claus.ibsen@gmail.com designates 10.152.102.173 as permitted sender) smtp.mail=claus.ibsen@gmail.com; dkim=pass header.i=claus.ibsen@gmail.com Received: from mr.google.com ([10.152.102.173]) by 10.152.102.173 with SMTP id fp13mr9759076lab.38.1330766898610 (num_hops = 1); Sat, 03 Mar 2012 01:28:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=nCiXChvZV40zGrdG3BSFAT0T+BcZLgqlGjUgTSCqKDE=; b=eqg9iaSX8RTQVCOVjJcFC7iTdG27YOJ7EAGY1qhopm2m75NkPcDPV38qxI/Fqykd8Q XrWpR4Sh+h9JdHHxH41PCEMZXmCy1scL4oL4YC4sMuM3H+YIMWQoGP8X3or1HPmjArHU J13soc2y66YbsInQtqX3B9r2XBdI41kv4FG0j2EC9KB7Lr/WLzgRqQFa+K0XKfMBAQs7 +3tcay/lpEtKfcesiSgRayJP17lVxEhqIeXt6qRAVVzz7FwKti9vWDSpifiXmW4HWVaF OFUd3qYoYc59SrXXym76ryefC4J3weo3QhtWFft8wcTKHgxOtTpQsjvUET4RzPeTIdpj YTlg== Received: by 10.152.102.173 with SMTP id fp13mr8042667lab.38.1330766898531; Sat, 03 Mar 2012 01:28:18 -0800 (PST) MIME-Version: 1.0 Received: by 10.112.87.100 with HTTP; Sat, 3 Mar 2012 01:27:58 -0800 (PST) In-Reply-To: <1330734718974-5532697.post@n5.nabble.com> References: <1330734718974-5532697.post@n5.nabble.com> From: Claus Ibsen Date: Sat, 3 Mar 2012 10:27:58 +0100 Message-ID: Subject: Re: help with websphere MQ with XA transaction. Sample code below. To: users@camel.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Hi If you need XA then you need to use a XA transaction manager, as well XA capable resources (in your case IBM WebSphereMQ) for the JMS broker and then a XA JDBC driver for the JDBC. So when you get the JDBC connection you need to get it in a way that the XA transaction manager can orchestrate it. I doubt by calling the code you do, works in that way. You may need to check the documentation of your JDBC driver to learn how to do that. Also if you got Camel in Action book, we cover all about transactions and XA in chapter 9. And have examples how to do XA with JMS and JDBC. On Sat, Mar 3, 2012 at 1:31 AM, dmhatre wrote: > Hi Folks, > =A0 I am new to Apache camel. And got the JMS websphere MQ with camel. > But I am struggling with XA transaction. Can somebody help me and give so= me > leads to > implement XA transaction. Below is the code sample which is working(but > without XA transaction) > The option transacted=3Dtrue uses JMSTransactionManager which kind off > rollbacks the JMS transaction > if database transaction fails. But want some more control by doing commit= s > and rollbacks manually. > Thanks in advance. > > > CamelContext context =3D new DefaultCamelContext(); > > MQQueueConnectionFactory cf =3D new MQQueueConnectionFactory(); > =A0cf.setHostName("192.111.111.11"); > =A0cf.setPort(1414); > =A0cf.setQueueManager("QM_user"); > =A0cf.setChannel("S_user"); > =A0cf.setTransportType(1); > JmsConfiguration jc =3D new JmsConfiguration(cf); > JmsComponent ibmmq =3D new JmsComponent(jc); > =A0context.addComponent("test-jms", ibmmq); > > =A0context.addRoutes(new RouteBuilder() { > > =A0 =A0 =A0 =A0public void configure() { > > =A0 =A0 =A0 =A0from("test-jms:queue:Q1?transacted=3Dtrue").process(new Pr= ocessor(){ > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0public void process(Exchange arg0) throws = Exception { > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Object obj =3D arg0.getIn().getBo= dy(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 String sql =3D "insert into kk_te= sttab(x,y) values(?,?)"; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Connection conn =3D OceanviewData= Source.getConnection(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 PreparedStatement stmt =3D null; > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0try { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0stmt =3D c= onn.prepareStatement(sql); > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0stmt.setIn= t(1, Integer.parseInt(obj.toString())); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0stmt.setIn= t(2, Integer.parseInt(obj.toString())); > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0stmt.execu= te(); > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}catch(Exc= eption e){ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0throw e; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}finally { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0conn.close(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0}); > > =A0 context.start(); > =A0 Thread.sleep(1000); > =A0 context.stop(); > > -- > View this message in context: http://camel.465427.n5.nabble.com/help-with= -websphere-MQ-with-XA-transaction-Sample-code-below-tp5532697p5532697.html > Sent from the Camel - Users mailing list archive at Nabble.com. --=20 Claus Ibsen ----------------- FuseSource Email: cibsen@fusesource.com Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/