INT-837 The 'inbound-channel-adapter' element in the JMS namespace now accepts a MessageConverter reference.
This commit is contained in:
@@ -60,6 +60,15 @@ public class JmsDestinationPollingSource extends AbstractJmsTemplateBasedAdapter
|
||||
this.messageSelector = messageSelector;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a MessageConverter to use when mapping from JMS Mesages to
|
||||
* Spring Integration Messages. If it is not itself an implementation
|
||||
* of {@link HeaderMappingMessageConverter}, it will be wrapped.
|
||||
*/
|
||||
public void setMessageConverter(MessageConverter messageConverter) {
|
||||
this.getJmsTemplate().setMessageConverter(messageConverter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether the payload should be extracted from each received JMS
|
||||
* Message to be used as the Spring Integration Message payload.
|
||||
|
||||
@@ -78,6 +78,7 @@ public class JmsInboundChannelAdapterParser extends AbstractPollingInboundChanne
|
||||
if (StringUtils.hasText(headerMapper)) {
|
||||
builder.addPropertyReference(JmsAdapterParserUtils.HEADER_MAPPER_PROPERTY, headerMapper);
|
||||
}
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "message-converter");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "selector", "messageSelector");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "extract-payload");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "destination-resolver");
|
||||
|
||||
@@ -131,15 +131,6 @@
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="message-converter" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.jms.support.converter.MessageConverter"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="header-mapper" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
@@ -254,15 +245,6 @@
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="default-reply-queue-name" type="xsd:string"/>
|
||||
<xsd:attribute name="default-reply-topic-name" type="xsd:string"/>
|
||||
<xsd:attribute name="message-converter" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.jms.support.converter.MessageConverter"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="header-mapper" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
@@ -373,15 +355,6 @@
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="message-converter" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.jms.support.converter.MessageConverter"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="header-mapper" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
@@ -600,6 +573,15 @@
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="message-converter" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.jms.support.converter.MessageConverter"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="pub-sub-domain" type="xsd:string"/>
|
||||
<xsd:attribute name="auto-startup" type="xsd:string" default="true"/>
|
||||
</xsd:complexType>
|
||||
|
||||
@@ -138,4 +138,24 @@ public class JmsInboundChannelAdapterParserTests {
|
||||
assertEquals("test [with selector: TestProperty = 'foo']", message.getPayload());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pollingAdapterWithMessageConverter() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"jmsInboundWithMessageConverter.xml", this.getClass());
|
||||
PollableChannel output = (PollableChannel) context.getBean("output1");
|
||||
Message<?> message = output.receive(timeoutOnReceive);
|
||||
assertNotNull("message should not be null", message);
|
||||
assertEquals("converted-test", message.getPayload());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void messageDrivenAdapterWithMessageConverter() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"jmsInboundWithMessageConverter.xml", this.getClass());
|
||||
PollableChannel output = (PollableChannel) context.getBean("output2");
|
||||
Message<?> message = output.receive(timeoutOnReceive);
|
||||
assertNotNull("message should not be null", message);
|
||||
assertEquals("converted-test", message.getPayload());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:integration="http://www.springframework.org/schema/integration"
|
||||
xmlns:jms="http://www.springframework.org/schema/integration/jms"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/jms
|
||||
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd">
|
||||
|
||||
<jms:inbound-channel-adapter destination-name="test" message-converter="testConverter" channel="output1"/>
|
||||
|
||||
<jms:message-driven-channel-adapter destination-name="test" message-converter="testConverter" channel="output2"/>
|
||||
|
||||
<integration:channel id="output1">
|
||||
<integration:queue capacity="1"/>
|
||||
</integration:channel>
|
||||
|
||||
<integration:channel id="output2">
|
||||
<integration:queue capacity="1"/>
|
||||
</integration:channel>
|
||||
|
||||
<bean id="connectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory">
|
||||
<constructor-arg>
|
||||
<bean class="org.springframework.integration.jms.StubConnection">
|
||||
<constructor-arg value="test"/>
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="testConverter" class="org.springframework.integration.jms.config.TestMessageConverter"/>
|
||||
|
||||
<integration:poller id="poller" default="true">
|
||||
<integration:interval-trigger interval="500"/>
|
||||
</integration:poller>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user