[ https://issues.apache.org/jira/browse/AMQ-8464?focusedWorklogId=883097&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-883097 ]
ASF GitHub Bot logged work on AMQ-8464: --------------------------------------- Author: ASF GitHub Bot Created on: 03/Oct/23 12:23 Start Date: 03/Oct/23 12:23 Worklog Time Spent: 10m Work Description: cshannon commented on code in PR #1046: URL: https://github.com/apache/activemq/pull/1046#discussion_r1344012434 ########## activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java: ########## @@ -675,6 +705,49 @@ public Message receive(long timeout) throws JMSException { return null; } + /** + * JMS 2.0 support method for receiveBody(long timeout) + * AMQ-8464 + */ + <T> T receiveBody(Class<T> bodyType, long timeout) throws JMSException { + checkClosed(); + checkMessageListener(); + if (timeout == 0) { + return this.receiveBody(bodyType); + } + + sendPullCommand(timeout); + while (timeout > 0) { + + MessageDispatch md; + if (info.getPrefetchSize() == 0) { + md = dequeue(-1); // We let the broker let us know when we timeout. + } else { + md = dequeue(timeout); + } + + 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()) { + unconsumedMessages.enqueueFirst(md); Review Comment: This doesn't make any sense to me. Why would we add a bad message that had an exception back to the unconsumedMessages queue? I haven't looked at this in a long time but I think that would attempt to redispatch again as it's meant for redlivery so we would just error over and over. This error should just be propagated back up like a nomral JMSException I would think, no reason to catch and re-add it here Issue Time Tracking ------------------- Worklog Id: (was: 883097) Time Spent: 20m (was: 10m) > 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: 20m > Remaining Estimate: 0h > -- This message was sent by Atlassian Jira (v8.20.10#820010)