[ 
https://issues.apache.org/jira/browse/AMQ-8464?focusedWorklogId=883107&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-883107
 ]

ASF GitHub Bot logged work on AMQ-8464:
---------------------------------------

                Author: ASF GitHub Bot
            Created on: 03/Oct/23 12:48
            Start Date: 03/Oct/23 12:48
    Worklog Time Spent: 10m 
      Work Description: cshannon commented on code in PR #1046:
URL: https://github.com/apache/activemq/pull/1046#discussion_r1344045006


##########
activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java:
##########
@@ -589,6 +590,35 @@ public Message receive() throws JMSException {
         return createActiveMQMessage(md);
     }
 
+    /**
+     * JMS 2.0 support method for receiveBody(bodyType)
+     * AMQ-8464
+     */
+    <T> T receiveBody(Class<T> bodyType) throws JMSException {
+        checkClosed();
+        checkMessageListener();
+
+        sendPullCommand(0);
+        MessageDispatch md = dequeue(-1);
+        if (md == null) {
+            return null;
+        }
+
+        beforeMessageIsConsumed(md);
+        Message message = createActiveMQMessage(md);
+        try {
+            // This throws MessageFormatException if body is not of bodyType
+            T body = message.getBody(bodyType);
+            afterMessageIsConsumed(md, false);
+            return body;
+        } catch (MessageFormatException e) {
+            synchronized (unconsumedMessages.getMutex()) {

Review Comment:
   Ok so based on the spec I think we should only be re-enqueing for certain 
ack modes: 
https://jakarta.ee/specifications/messaging/3.0/apidocs/jakarta/jms/jmsconsumer#receiveBody-java.lang.Class-
   
   For example this is qpid jms: 
   
   
https://github.com/apache/qpid-jms/blob/149eeb01027120d84af3a62eb83858c86d244b90/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsMessageConsumer.java#L257-L264
   
    ```java
    // Should behave as if receiveBody never happened in these modes.
     if (acknowledgementMode == Session.AUTO_ACKNOWLEDGE ||
         acknowledgementMode == Session.DUPS_OK_ACKNOWLEDGE) {
   
   
         envelope.setEnqueueFirst(true);
         onInboundMessage(envelope);
         envelope = null;
     }
   ```





Issue Time Tracking
-------------------

    Worklog Id:     (was: 883107)
    Time Spent: 1.5h  (was: 1h 20m)

> Implement JMS 2.0 Consumer receiveBody
> --------------------------------------
>
>                 Key: AMQ-8464
>                 URL: https://issues.apache.org/jira/browse/AMQ-8464
>             Project: ActiveMQ
>          Issue Type: Task
>            Reporter: Matt Pavlovich
>            Assignee: Matt Pavlovich
>            Priority: Major
>              Labels: #jms2
>             Fix For: 6.0.0, 5.18.3
>
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to