activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "martin@attivio.com" <mar...@attivio.com>
Subject Re: Fail in the middle of proccess
Date Mon, 28 Mar 2011 22:15:55 GMT
Not sure exactly what you are asking for, but here is an attempt at
answering.

Yes.  You should should use a transacted session.  So, assuming you already
have a connection:


  Session session = connection.createSession(true, 0);
  Destination queue = session.createQueue("some-queue-name");
  MessageConsumer consumer = session.createConsumer(queue);

  Message message;
  while (doing stuff) {
    message = consumer.receive();
    processTheMessage(message);
    if (doneWithChunkOfWork) session.commit();
  }


If there is an exception while processing the message or the system crashes
(assuming you are using persisted messages), then the transaction will be
rolled back and the next time you run the messages will be replayed.



--
View this message in context: http://activemq.2283324.n4.nabble.com/Fail-in-the-middle-of-proccess-tp3412553p3413232.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message