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.

Reply via email to