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
This obviously applies to all 3 methods in the PR
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]