INT-1768 added support for propagating AcknowledgeMode to JmsTemplate when explicitly set on JMS inbound-channel-adapter

This commit is contained in:
Oleg Zhurakousky
2011-01-28 10:43:52 -05:00
parent 2df24cc603
commit 061ce2f05d
4 changed files with 23 additions and 3 deletions

View File

@@ -57,7 +57,7 @@ abstract class JmsAdapterParserUtils {
private static final String[] JMS_TEMPLATE_ATTRIBUTES = {
"connection-factory", "message-converter", "destination-resolver", "pub-sub-domain",
"time-to-live", "priority", "delivery-persistent", "explicit-qos-enabled"
"time-to-live", "priority", "delivery-persistent", "explicit-qos-enabled", "acknowledge"
};
@@ -123,6 +123,11 @@ abstract class JmsAdapterParserUtils {
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "priority");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "delivery-persistent");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "explicit-qos-enabled");
Integer acknowledgeMode = parseAcknowledgeMode(element, parserContext);
if (acknowledgeMode != null){
builder.addPropertyValue("sessionAcknowledgeMode", acknowledgeMode);
}
return builder.getBeanDefinition();
}

View File

@@ -872,7 +872,7 @@
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="jmsAdapterType">
<xsd:attribute name="acknowledge" default="auto">
<xsd:attribute name="acknowledge">
<xsd:annotation>
<xsd:documentation><![CDATA[
The native JMS acknowledge mode: "auto", "client", "dups-ok" or "transacted".

View File

@@ -31,6 +31,7 @@ import org.springframework.integration.Message;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.jms.core.JmsTemplate;
/**
* @author Mark Fisher
@@ -40,7 +41,7 @@ public class JmsInboundChannelAdapterParserTests {
long timeoutOnReceive = 3000;
@Test
public void adapterWithJmsTemplate() {
public void adapterWithJmsTemplate() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"jmsInboundWithJmsTemplate.xml", this.getClass());
PollableChannel output = (PollableChannel) context.getBean("output");
@@ -53,6 +54,15 @@ public class JmsInboundChannelAdapterParserTests {
assertNotNull("message should not be null", message);
assertEquals("polling-test", message.getPayload());
}
@Test
public void adapterWithoutJmsTemplateAndAcknowlegeMode() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"jmsInboundWithJmsTemplate.xml", this.getClass());
JmsTemplate jmsTemplate =
TestUtils.getPropertyValue(context.getBean("inboundAdapterWithoutJmsTemplate"), "source.jmsTemplate", JmsTemplate.class);
assertEquals(0, jmsTemplate.getSessionAcknowledgeMode());
}
@Test
public void adapterWithConnectionFactoryAndDestination() {

View File

@@ -13,7 +13,12 @@
<integration:message-history/>
<jms:inbound-channel-adapter id="inboundAdapter" jms-template="jmsTemplate" channel="output"/>
<jms:inbound-channel-adapter id="inboundAdapterWithoutJmsTemplate" channel="outputA" acknowledge="transacted"
destination-name="foo.bar"/>
<integration:channel id="outputA"/>
<integration:channel id="output">
<integration:queue capacity="1"/>
</integration:channel>