INT-4103: Fix Amqp Channel Header Mappers
JIRA: https://jira.spring.io/browse/INT-4103
This commit is contained in:
@@ -80,7 +80,7 @@ public class PollableAmqpChannel extends AbstractAmqpChannel
|
||||
*/
|
||||
public PollableAmqpChannel(String channelName, AmqpTemplate amqpTemplate, AmqpHeaderMapper outboundMapper,
|
||||
AmqpHeaderMapper inboundMapper) {
|
||||
super(amqpTemplate, inboundMapper, outboundMapper);
|
||||
super(amqpTemplate, outboundMapper, inboundMapper);
|
||||
Assert.hasText(channelName, "channel name must not be empty");
|
||||
this.channelName = channelName;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
|
||||
<int-amqp:channel id="withEP" extract-payload="true" message-converter="jackson" />
|
||||
|
||||
<int-amqp:channel id="pollableWithEP" extract-payload="true" message-driven="false" message-converter="jackson" />
|
||||
<int-amqp:channel id="pollableWithEP" extract-payload="true" message-driven="false" message-converter="jackson"
|
||||
inbound-header-mapper="mapperIn" outbound-header-mapper="mapperOut" />
|
||||
|
||||
<int-amqp:publish-subscribe-channel id="pubSubWithEP" extract-payload="true" message-converter="jackson" />
|
||||
|
||||
@@ -29,4 +30,10 @@
|
||||
|
||||
<bean id="jackson" class="org.springframework.amqp.support.converter.Jackson2JsonMessageConverter" />
|
||||
|
||||
<bean id="mapperIn" class="org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper"
|
||||
factory-method="inboundMapper" />
|
||||
|
||||
<bean id="mapperOut" class="org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper"
|
||||
factory-method="outboundMapper" />
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -20,6 +20,7 @@ import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -44,6 +45,7 @@ import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.integration.amqp.config.AmqpChannelFactoryBean;
|
||||
import org.springframework.integration.amqp.rule.BrokerRunning;
|
||||
import org.springframework.integration.amqp.support.AmqpHeaderMapper;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.test.support.LogAdjustingTestSupport;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
@@ -90,6 +92,12 @@ public class ChannelTests extends LogAdjustingTestSupport {
|
||||
@Autowired
|
||||
private CachingConnectionFactory factory;
|
||||
|
||||
@Autowired
|
||||
private AmqpHeaderMapper mapperIn;
|
||||
|
||||
@Autowired
|
||||
private AmqpHeaderMapper mapperOut;
|
||||
|
||||
public ChannelTests() {
|
||||
super("org.springframework.integration", "org.springframework.integration.amqp", "org.springframework.amqp");
|
||||
}
|
||||
@@ -224,6 +232,9 @@ public class ChannelTests extends LogAdjustingTestSupport {
|
||||
assertNotNull(received);
|
||||
assertThat((Foo) received.getPayload(), equalTo(foo));
|
||||
assertThat((String) received.getHeaders().get("baz"), equalTo("qux"));
|
||||
|
||||
assertSame(this.mapperIn, TestUtils.getPropertyValue(this.pollableWithEP, "inboundHeaderMapper"));
|
||||
assertSame(this.mapperOut, TestUtils.getPropertyValue(this.pollableWithEP, "outboundHeaderMapper"));
|
||||
}
|
||||
|
||||
public static class Foo {
|
||||
|
||||
Reference in New Issue
Block a user