[jboss-user] [JBoss Messaging] - OrderingGroup and Transaction Rollback

mclu do-not-reply at jboss.com
Thu Jun 4 05:22:15 EDT 2009


Hi!

I just tested the new function ordering group of 1.4.4.GA because I want to replace my own ordering keeper implementation.
But What I see is that is does not work with transaction rolled back:

What I have done:

I add 4 Messages:

  | Connection connection = getConnection();
  | Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
  | JBossMessageProducer sender = (JBossMessageProducer) session.createProducer(queue);
  | sender.enableOrderingGroup("testordergrp");
  | 
  |     TextMessage msg1 = session.createTextMessage("1");
  |     TextMessage msg2 = session.createTextMessage("Ordergrp - shouldrollback");
  |     TextMessage msg3 = session.createTextMessage("2");
  |     TextMessage msg4 = session.createTextMessage("3");
  |     sender.send(msg1);
  |     sender.send(msg2);
  |     sender.send(msg3);
  |     sender.send(msg4);
  | closeConnection(connection);
  | 

Those messages are added to the testqueue and as I also see they are added to the LinkedList in the OrderingGroup.class. So this seems to be fine.

On my server I have a service which starts a consumeSingle() method from an Statefull Session bean ( This method bean call automatically creates the XA Transaction). Inside this consumeSingle() method I now receive one message! and delegate it.


  |  conn = getConnection();
  |   boolean transacted = true;
  |   session = conn.createSession(transacted, Session.SESSION_TRANSACTED);
  | 
  | consumer = session.createConsumer(m_queue);
  | 
  |  // keep waittime small to ensure handling inside the transaction
  |  Message msg = consumer.receive(20000);
  | 
  |  // now delegate this message to the right handler....
  | 

The second message causes an error so the tx is rolled back.
In the old implementation the Message was also rolled back to the queue and the JMSXDeliveryCount was increased by one.
Next time consumeSingle() method was called this previous message was received again and again until it was moved to DLQ.

But with the new version and the orderinggroup on this behaviour changed?!?.
The second Message is still delivered as the second message but after the rollback first the other messages are delivered and at the end the second one again?? 

My server log:

  

  | 
  | INFO  [TestMessageHandlerBean] Got:1 mID:ID:JBM-7228da24-988e-44e9-b1d5-36af6e220d3e
  | INFO  [TestMessageHandlerBean] Got:Ordergrp - shouldrollback mID:ID:JBM-03e2198d-2e5d-490b-8631-56d596c689fe
  | ERROR [TestMessageHandlerBean] Error: Rollback because:For input string: "Ordergrp - shouldrollback"
  | INFO  [TestMessageHandlerBean] Got:2 mID:ID:JBM-89bc4425-68f6-476e-abbf-b55938d36dca
  | INFO  [TestMessageHandlerBean] Got:3 mID:ID:JBM-973afa1d-824a-4557-a316-9e9c1d6c9ed2
  | INFO  [TestMessageHandlerBean] Got:Ordergrp - shouldrollback mID:ID:JBM-03e2198d-2e5d-490b-8631-56d596c689fe
  | ERROR [TestMessageHandlerBean] Error: Rollback because:For input string: "Ordergrp - shouldrollback"
  | INFO  [TestMessageHandlerBean] Got:Ordergrp - shouldrollback mID:ID:JBM-03e2198d-2e5d-490b-8631-56d596c689fe
  | ERROR [TestMessageHandlerBean] Error: Rollback because:For input string: "Ordergrp - shouldrollback"
  | INFO  [TestMessageHandlerBean] Got:Ordergrp - shouldrollback mID:ID:JBM-03e2198d-2e5d-490b-8631-56d596c689fe
  | ERROR [TestMessageHandlerBean] Error: Rollback because:For input string: "Ordergrp - shouldrollback"
  | INFO  [TestMessageHandlerBean] Got:Ordergrp - shouldrollback mID:ID:JBM-03e2198d-2e5d-490b-8631-56d596c689fe
  | ERROR [TestMessageHandlerBean] Error: Rollback because:For input string: "Ordergrp - shouldrollback"
  | INFO  [TestMessageHandlerBean] Got:Ordergrp - shouldrollback mID:ID:JBM-03e2198d-2e5d-490b-8631-56d596c689fe
  | ERROR [TestMessageHandlerBean] Error: Rollback because:For input string: "Ordergrp - shouldrollback"
  | INFO  [TestMessageHandlerBean] Got:Ordergrp - shouldrollback mID:ID:JBM-03e2198d-2e5d-490b-8631-56d596c689fe
  | ERROR [TestMessageHandlerBean] Error: Rollback because:For input string: "Ordergrp - shouldrollback"
  | INFO  [TestMessageHandlerBean] Got:Ordergrp - shouldrollback mID:ID:JBM-03e2198d-2e5d-490b-8631-56d596c689fe
  | ERROR [TestMessageHandlerBean] Error: Rollback because:For input string: "Ordergrp - shouldrollback"
  | 


Can you explain this? Does the orderingGroup does not work if a transaction is rolled back?

Just for the history info:
I don't think that my own solution has something to do with this. I simply receive() one message inside a transaction. This "service" just makes sure that only one message is handles by one consumer at a time. I first had a singleton MDB solution for this but the internal handling of message also queues at least 2 messages before delegating them to the MDB. So I had also problems with ordering and rollback there too... 

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4235208#4235208

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4235208



More information about the jboss-user mailing list