Fix DefaultAmqpHeaderMapper for latest SA

The `correlationId` is `String` now, not `byte[]`
This commit is contained in:
Artem Bilan
2016-09-29 21:36:11 -04:00
parent fc3088d77d
commit 9bc2b6f62b
2 changed files with 9 additions and 6 deletions

View File

@@ -122,8 +122,8 @@ public class DefaultAmqpHeaderMapper extends AbstractHeaderMapper<MessagePropert
if (StringUtils.hasText(contentType)) {
headers.put(AmqpHeaders.CONTENT_TYPE, contentType);
}
byte[] correlationId = amqpMessageProperties.getCorrelationId();
if (correlationId != null && correlationId.length > 0) {
String correlationId = amqpMessageProperties.getCorrelationId();
if (StringUtils.hasText(contentType)) {
headers.put(AmqpHeaders.CORRELATION_ID, correlationId);
}
MessageDeliveryMode receivedDeliveryMode = amqpMessageProperties.getReceivedDeliveryMode();
@@ -234,10 +234,12 @@ public class DefaultAmqpHeaderMapper extends AbstractHeaderMapper<MessagePropert
if (StringUtils.hasText(contentType)) {
amqpMessageProperties.setContentType(contentType);
}
Object correlationId = headers.get(AmqpHeaders.CORRELATION_ID);
if (correlationId instanceof byte[]) {
amqpMessageProperties.setCorrelationId((byte[]) correlationId);
String correlationId = getHeaderIfAvailable(headers, AmqpHeaders.CONTENT_ENCODING, String.class);
if (StringUtils.hasText(correlationId)) {
amqpMessageProperties.setCorrelationId(correlationId);
}
Integer delay = getHeaderIfAvailable(headers, AmqpHeaders.DELAY, Integer.class);
if (delay != null) {
amqpMessageProperties.setDelay(delay);

View File

@@ -45,6 +45,7 @@ import org.springframework.util.MimeTypeUtils;
* @author Gary Russell
* @author Oleg Zhurakousky
* @author Stephane Nicoll
* @author Artem Bilan
* @since 2.1
*/
public class DefaultAmqpHeaderMapperTests {
@@ -158,7 +159,7 @@ public class DefaultAmqpHeaderMapperTests {
amqpProperties.setContentEncoding("test.contentEncoding");
amqpProperties.setContentLength(99L);
amqpProperties.setContentType("test.contentType");
byte[] testCorrelationId = new byte[] { 1, 2, 3 };
String testCorrelationId = "foo";
amqpProperties.setCorrelationId(testCorrelationId);
amqpProperties.setReceivedDeliveryMode(MessageDeliveryMode.NON_PERSISTENT);
amqpProperties.setDeliveryTag(1234L);