3 Replies Latest reply on Jun 17, 2014 6:05 AM by murthy516

    JTA and JMS Hornetq Transactions

    murthy516

      Hi,

       

         I've a JTA Transaction which pushes the message to one of the remote queue (sitting in some other server) using Remote connection factory,and the same transaction includes the updation of table in database.

       

      Problem is if any updation of jta transaction fails,I'm unable to rollback the message which pushed earlier.Message pushing was done by establishing Remote Connection Factory and Session as non-transacted session.

       

       

       

        Hashtable<String, String> env = new Hashtable<String, String>();

            env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

            env.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces:org.jboss.naming");

            env.put(Context.PROVIDER_URL, "remote://122.162.2.207:4447");

        env.put(Context.SECURITY_PRINCIPAL, userName);

        env.put(Context.SECURITY_CREDENTIALS, password);

       

        initialContext = new InitialContext(env);

       

        connectionFactory = (ConnectionFactory) initialContext.lookup("jms/RemoteConnectionFactory");

        Queue queue = (Queue) initialContext.lookup(queueName);

        connection = connectionFactory.createConnection(userName, password);

       

        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

       

        TextMessage message = session.createTextMessage(textMessage);

       

        MessageProducer sender = session.createProducer(queue);

        sender.send(message);

       

        connection.start();

        connection.close();

       

      How can i commit both these at a time.Does the above code fits Ok?Please help me out JBOSS Team.

       

       

      Regards

      Krisv