|
16 | 16 |
|
17 | 17 | package org.springframework.jms.listener.adapter;
|
18 | 18 |
|
| 19 | +import javax.jms.BytesMessage; |
19 | 20 | import javax.jms.Destination;
|
20 | 21 | import javax.jms.InvalidDestinationException;
|
21 | 22 | import javax.jms.JMSException;
|
@@ -204,9 +205,9 @@ protected void handleListenerException(Throwable ex) {
|
204 | 205 | /**
|
205 | 206 | * Extract the message body from the given JMS message.
|
206 | 207 | * @param message the JMS {@code Message}
|
207 |
| - * @return the content of the message, to be passed into the |
208 |
| - * listener method as argument |
209 |
| - * @throws MessageConversionException if the message could not be unmarshaled |
| 208 | + * @return the content of the message, to be passed into the listener method |
| 209 | + * as an argument |
| 210 | + * @throws MessageConversionException if the message could not be extracted |
210 | 211 | */
|
211 | 212 | protected Object extractMessage(Message message) {
|
212 | 213 | try {
|
@@ -396,7 +397,19 @@ private class MessagingMessageConverterAdapter extends MessagingMessageConverter
|
396 | 397 |
|
397 | 398 | @Override
|
398 | 399 | protected Object extractPayload(Message message) throws JMSException {
|
399 |
| - return extractMessage(message); |
| 400 | + Object payload = extractMessage(message); |
| 401 | + if (message instanceof BytesMessage) { |
| 402 | + try { |
| 403 | + // In case the BytesMessage is going to be received as a user argument: |
| 404 | + // reset it, otherwise it would appear empty to such processing code... |
| 405 | + ((BytesMessage) message).reset(); |
| 406 | + } |
| 407 | + catch (JMSException ex) { |
| 408 | + // Continue since the BytesMessage typically won't be used any further. |
| 409 | + logger.debug("Failed to reset BytesMessage after payload extraction", ex); |
| 410 | + } |
| 411 | + } |
| 412 | + return payload; |
400 | 413 | }
|
401 | 414 | }
|
402 | 415 |
|
|
0 commit comments