activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "" <>
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

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();
    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:
Sent from the ActiveMQ - User mailing list archive at

View raw message