提交 e4faaa37 编写于 作者: J Juergen Hoeller

Reset BytesMessage after payload extraction

Issue: SPR-13769
(cherry picked from commit 8346eeda)
上级 d04f7850
......@@ -16,6 +16,7 @@
package org.springframework.jms.listener.adapter;
import javax.jms.BytesMessage;
import javax.jms.Destination;
import javax.jms.InvalidDestinationException;
import javax.jms.JMSException;
......@@ -204,9 +205,9 @@ public abstract class AbstractAdaptableMessageListener
/**
* Extract the message body from the given JMS message.
* @param message the JMS {@code Message}
* @return the content of the message, to be passed into the
* listener method as argument
* @throws MessageConversionException if the message could not be unmarshaled
* @return the content of the message, to be passed into the listener method
* as an argument
* @throws MessageConversionException if the message could not be extracted
*/
protected Object extractMessage(Message message) {
try {
......@@ -396,7 +397,19 @@ public abstract class AbstractAdaptableMessageListener
@Override
protected Object extractPayload(Message message) throws JMSException {
return extractMessage(message);
Object payload = extractMessage(message);
if (message instanceof BytesMessage) {
try {
// In case the BytesMessage is going to be received as a user argument:
// reset it, otherwise it would appear empty to such processing code...
((BytesMessage) message).reset();
}
catch (JMSException ex) {
// Continue since the BytesMessage typically won't be used any further.
logger.debug("Failed to reset BytesMessage after payload extraction", ex);
}
}
return payload;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册