users@glassfish.java.net

Re: how can i setup glassfish to deal with "poison message"

From: <glassfish_at_javadesktop.org>
Date: Wed, 04 Mar 2009 02:28:24 PST

I've looked into this a little more and have found that if I throw an Exception out of onMessage then the retry value is honoured. Like this:

        public void onMessage(Message msg) {
                try {
.....
                } catch (Throwable ex) {
                        // Force a transaction rollback and redelivery
                        messageDrivenContext.setRollbackOnly();
                        throw new RuntimeException(ex);
                }

I thought you were always meant to use setRollbackOnly() ?

If the code is:

        public void onMessage(Message msg) {
                try {
.....
                } catch (Throwable ex) {
                        // Force a transaction rollback and redelivery
                        messageDrivenContext.setRollbackOnly();
                }

The message retries forever until I purge the Queue. Incidentally the above code works fine in Weblogic 9. :-)
[Message sent by forum member 'scotty76' (scotty76)]

http://forums.java.net/jive/thread.jspa?messageID=334997