[prev in list] [next in list] [prev in thread] [next in thread] 

List:       activemq-users
Subject:    Re: Fail in the middle of proccess
From:       "martin () attivio ! com" <martin () attivio ! com>
Date:       2011-03-28 22:15:55
Message-ID: 1301350555887-3413232.post () n4 ! nabble ! com
[Download RAW message or body]

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.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic