3 Replies Latest reply on Mar 31, 2005 11:40 AM by mariovvl

    Rollback problem when sending to multiple queues.

      Hi,

      when sending a message to 2 queue destinations (using the same session) I want to rollback both sends when either of the 2 queues is down. To test this, I issued a stop() (using MBean method) on queue A at points (1) and (2) in my code (see below). The mpt.send(message) call doesn't fail, however when the commit is executed, I get a SpyTransactionRolledBackException which is what I would expect. It seems though that queue/testQueue did receive the message regardless of the rollback.

      Is this expected behaviour? If so, how can I make sure my scenario issues a rollback on both queues?

      Thanks,
      Mario

       ctx = new InitialContext();
       cf = (QueueConnectionFactory)ctx.lookup("ConnectionFactory");
       Connection c = cf.createConnection();
       Session s = c.createSession(true, Session.SESSION_TRANSACTED);
      
       destination1 = (Queue)ctx.lookup("queue/testQueue");
       message = s.createTextMessage();
       message.setText("***mymessage**");
       MessageProducer mpq = s.createProducer(destination1);
       mpq.send(message);
      
       destination2 = (Queue)ctx.lookup("queue/A");
       //(1)
       MessageProducer mpt = s.createProducer(destination2);
       //(2)
       mpt.send(message);
      
       s.commit();