Hi Folks, 
   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 some
leads to 
implement XA transaction. Below is the code sample which is working(but
without XA transaction)
The option transacted=true uses JMSTransactionManager which kind off
rollbacks the JMS transaction
if database transaction fails. But want some more control by doing commits
and rollbacks manually.
Thanks in advance.


CamelContext context = new DefaultCamelContext();

MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
  cf.setHostName("192.111.111.11");
  cf.setPort(1414);
  cf.setQueueManager("QM_user");
  cf.setChannel("S_user");
  cf.setTransportType(1);
JmsConfiguration jc = new JmsConfiguration(cf);
JmsComponent ibmmq = new JmsComponent(jc);
  context.addComponent("test-jms", ibmmq);

  context.addRoutes(new RouteBuilder() {

        public void configure() {

        from("test-jms:queue:Q1?transacted=true").process(new Processor(){
        
                public void process(Exchange arg0) throws Exception {

                     Object obj = arg0.getIn().getBody();
                     String sql = "insert into kk_testtab(x,y) values(?,?)";
                     Connection conn = OceanviewDataSource.getConnection();
                     PreparedStatement stmt = null;

                        try {
                                stmt = conn.prepareStatement(sql);

                                stmt.setInt(1, 
Integer.parseInt(obj.toString()));
                                stmt.setInt(2, 
Integer.parseInt(obj.toString()));
                                                        
                                stmt.execute();

                                }catch(Exception e){
                                        throw e;
                                }finally {
                                        conn.close();
                                }                               
                        });
                }
        });

   context.start();
   Thread.sleep(1000);
   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.

Reply via email to