You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "Keith Wall (JIRA)" <ji...@apache.org> on 2011/02/03 17:12:29 UTC

[jira] Created: (QPID-3036) java.lang.RuntimeException within a client's onMessage is not handled per the JMS specification.

java.lang.RuntimeException within a client's onMessage is not handled per the JMS specification.
------------------------------------------------------------------------------------------------

                 Key: QPID-3036
                 URL: https://issues.apache.org/jira/browse/QPID-3036
             Project: Qpid
          Issue Type: Bug
          Components: Java Client
    Affects Versions: 0.9
            Reporter: Keith Wall
            Priority: Minor


Qpid's handling of RuntimeExceptions (and subclasses) thrown from within a client's MessageListener#onMessage(Message) does not follow the JMS specification.  This defect affects only JMS consumers using asynchronous delivery (via an onMessage callback rather than MessageConsumer#receive()) with delivery modes AUTO_ACKNOWLEDGE or DUPS_OK_ACKNOWLEDGE).

Delivery modes CLIENT_ACKNOWLEDGE and SESSION_TRANSACTED are NOT affected.

The JMS specification (Java Message Service, Version 1.1 April 12, 2002) states:

======

4.5.2 Asynchronous Delivery

A client can register an object that implements the JMS MessageListener
interface with a MessageConsumer. As messages arrive for the consumer, the
provider delivers them by calling the listener's onMessage method.
It is possible for a listener to throw a RuntimeException; however, this is
considered a client programming error. Well-behaved listeners should catch
such exceptions and attempt to divert messages causing them to some form of
application-specific 'unprocessable message' destination.
The result of a listener throwing a RuntimeException depends on the session's
acknowledgment mode.


* AUTO_ACKNOWLEDGE or DUPS_OK_ACKNOWLEDGE - the message
will be immediately redelivered. The number of times a JMS provider will
redeliver the same message before giving up is provider-dependent. The
JMSRedelivered message header field will be set for a message redelivered
under these circumstances.

======

Currently, Qpid handles a message that causes onMessage to throw a RuntimeException in the following manner:

1) The exception will be logged to the (client) application log:
Dispatcher-Channel-1 2011-02-03 11:37:43,095 ERROR [apache.qpid.client.BasicMessageConsumer] reNotification : Caught exception (dump follows) - ignoring...
java.lang.RuntimeException: Rejecting message <xxxxx> at org.apache.qpid.client.MessageListenerRuntimeExceptionHandlingTest$1.onMessage(MessageListenerRuntimeExceptionHandlingTest.java:229)
        at org.apache.qpid.client.BasicMessageConsumer.notifyMessage(BasicMessageConsumer.java:722)
        at org.apache.qpid.client.BasicMessageConsumer_0_10.notifyMessage(BasicMessageConsumer_0_10.java:164)
2) Subsequent messages continue to be delivered as normal.
3) The message that caused the RuntimeException will be not redelivered to the client _until_ the client recreates the MessageConsumer.
4) If the message continues to cause the RuntimeException, the message will be redelivered to the client on every client restart (unless message is expired by its time-to-live, persistence, queue durability etc).  


-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] Updated: (QPID-3036) java.lang.RuntimeException within a client's onMessage is not handled per the JMS specification.

Posted by "Keith Wall (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/QPID-3036?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Keith Wall updated QPID-3036:
-----------------------------

    Attachment: 0001-Test-case-to-demonstrate-QPID-3036.patch

Test case to demonstrate QPID-3036.

The following two test demonstrate the defect exhibited in delivery modes AUTO_ACKNOWLEDGE and DUPS_OK_ACKNOWLEDGE

testAutoAckConsumerWithMessageListenerThatThrowsRuntimeException
testDupsOkayAutoAckConsumerWithMessageListenerThatThrowsRuntimeException

The these two show that CLIENT_ACKNOWLEDGE and SESSION_TRANSACTED
are NOT AFFECTED.

testClientAckConsumerWithMessageListenerThatThrowsRuntimeException
testTransactedSessionConsumerWithMessageListenerThatThrowsRuntimeException


> java.lang.RuntimeException within a client's onMessage is not handled per the JMS specification.
> ------------------------------------------------------------------------------------------------
>
>                 Key: QPID-3036
>                 URL: https://issues.apache.org/jira/browse/QPID-3036
>             Project: Qpid
>          Issue Type: Bug
>          Components: Java Client
>    Affects Versions: 0.9
>            Reporter: Keith Wall
>            Priority: Minor
>         Attachments: 0001-Test-case-to-demonstrate-QPID-3036.patch
>
>
> Qpid's handling of RuntimeExceptions (and subclasses) thrown from within a client's MessageListener#onMessage(Message) does not follow the JMS specification.  This defect affects only JMS consumers using asynchronous delivery (via an onMessage callback rather than MessageConsumer#receive()) with delivery modes AUTO_ACKNOWLEDGE or DUPS_OK_ACKNOWLEDGE).
> Delivery modes CLIENT_ACKNOWLEDGE and SESSION_TRANSACTED are NOT affected.
> The JMS specification (Java Message Service, Version 1.1 April 12, 2002) states:
> ======
> 4.5.2 Asynchronous Delivery
> A client can register an object that implements the JMS MessageListener
> interface with a MessageConsumer. As messages arrive for the consumer, the
> provider delivers them by calling the listener's onMessage method.
> It is possible for a listener to throw a RuntimeException; however, this is
> considered a client programming error. Well-behaved listeners should catch
> such exceptions and attempt to divert messages causing them to some form of
> application-specific 'unprocessable message' destination.
> The result of a listener throwing a RuntimeException depends on the session's
> acknowledgment mode.
> * AUTO_ACKNOWLEDGE or DUPS_OK_ACKNOWLEDGE - the message
> will be immediately redelivered. The number of times a JMS provider will
> redeliver the same message before giving up is provider-dependent. The
> JMSRedelivered message header field will be set for a message redelivered
> under these circumstances.
> ======
> Currently, Qpid handles a message that causes onMessage to throw a RuntimeException in the following manner:
> 1) The exception will be logged to the (client) application log:
> Dispatcher-Channel-1 2011-02-03 11:37:43,095 ERROR [apache.qpid.client.BasicMessageConsumer] reNotification : Caught exception (dump follows) - ignoring...
> java.lang.RuntimeException: Rejecting message <xxxxx> at org.apache.qpid.client.MessageListenerRuntimeExceptionHandlingTest$1.onMessage(MessageListenerRuntimeExceptionHandlingTest.java:229)
>         at org.apache.qpid.client.BasicMessageConsumer.notifyMessage(BasicMessageConsumer.java:722)
>         at org.apache.qpid.client.BasicMessageConsumer_0_10.notifyMessage(BasicMessageConsumer_0_10.java:164)
> 2) Subsequent messages continue to be delivered as normal.
> 3) The message that caused the RuntimeException will be not redelivered to the client _until_ the client recreates the MessageConsumer.
> 4) If the message continues to cause the RuntimeException, the message will be redelivered to the client on every client restart (unless message is expired by its time-to-live, persistence, queue durability etc).  

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org