Hi!

I think you should use transactions. I use them and they work perfectly :))

Best regards,
         Kovi


At 01:03 30.5.01 +0200, you wrote:
>Greetings!  This isn't SwiftMQ-specific but rather a JMS best practices
>question...
>
>We've set up a statistics logging application built on the publish/subscribe
>model.  An application publishes information to some topic, and then we add
>a message listener to pick up the info and log it to a database.  The
>session is in CLIENT_ACKNOWLEDGE mode, which means my MessageListener
>instance is responsible for acknowledging the message.
>
>In the onMessage method in my MessageListener, if the database is
>temporarily unavailable I don't acknowledge the message since I can't log
>it.  I set some flag denoting failure, and the next time the onMessage
>method is called, I check to see if the database is available again.  If it
>is, I want to call session.recover() to re-deliver all the messages I didn't
>acknowledge so I can now log them.  In pseudocode:
>
>public void onMessage(Message message)
>{
>         if (failure)
>         {
>                 if (recoverDBConnection() == true)
>                 {
>                         try { session.recover(); }
>                         catch (JMSException jme)
>                         {
>                                 jme.printStackTrace(); //still in failure 
> mode
>                                 return;
>                         }
>                         failure = false;
>                 } //else still in failure mode
>                 return;
>         }
>
>         try
>         {
>                 //process message
>                 //life is good and we can acknowledge the message
>                 message.acknowledge();
>         }
>         catch(Exception e)
>
>
>                 e.printStackTrace();
>                 failure = true;
>                 return;
>         }
>}
>
>The sticking point is the call to session.recover() -- the MessageListener
>has no knowledge of the session, and it doesn't seem like it should.  I
>would prefer to keep them decoupled, but I'm not sure how to trigger a
>recovery otherwise.  Any suggestions or better ideas on how to handle this?
>I've scoured the web and various newsgroups and I can't seem to find any
>examples of how other folks are handling this.
>
>         Thanks!
>         -- Kyal
>
>----------------------------------------------------
>Kyallee Dalrymple           [EMAIL PROTECTED]
>Sr. Software Engineer
>BrandMatrix              http://www.brandmatrix.com/
>----------------------------------------------------
>
>
>------------------------------------------------------
>SwiftMQ developers mailing list * http://www.swiftmq.com
>To unsubscribe from this list, send an eMail to
>[EMAIL PROTECTED] and write in the body of your message:
>UNSUBSCRIBE developers <your-email-address>
>Archive: http://www.mail-archive.com/developers@mail.iit.de/


------------------------------------------------------
SwiftMQ developers mailing list * http://www.swiftmq.com
To unsubscribe from this list, send an eMail to 
[EMAIL PROTECTED] and write in the body of your message:
UNSUBSCRIBE developers <your-email-address>
Archive: http://www.mail-archive.com/developers@mail.iit.de/




Reply via email to