added explicit-qos-enabled-for-replies attribute for inbound-gateway

This commit is contained in:
Mark Fisher
2010-03-12 17:57:05 +00:00
parent 7fa2c521a2
commit 238a18b5c2
6 changed files with 63 additions and 5 deletions

View File

@@ -62,6 +62,8 @@ public class ChannelPublishingJmsMessageListener implements SessionAwareMessageL
private volatile int replyDeliveryMode = javax.jms.Message.DEFAULT_DELIVERY_MODE;
private volatile boolean explicitQosEnabledForReplies;
private volatile DestinationResolver destinationResolver = new DynamicDestinationResolver();
private volatile JmsHeaderMapper headerMapper;
@@ -158,6 +160,14 @@ public class ChannelPublishingJmsMessageListener implements SessionAwareMessageL
this.replyDeliveryMode = replyDeliveryPersistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
}
/**
* Specify whether explicit QoS should be enabled for replies
* (for timeToLive, priority, and deliveryMode settings).
*/
public void setExplicitQosEnabledForReplies(boolean explicitQosEnabledForReplies) {
this.explicitQosEnabledForReplies = explicitQosEnabledForReplies;
}
/**
* Set the DestinationResolver that should be used to resolve reply
* destination names for this listener.
@@ -245,11 +255,14 @@ public class ChannelPublishingJmsMessageListener implements SessionAwareMessageL
jmsReply.setJMSCorrelationID(jmsMessage.getJMSMessageID());
}
MessageProducer producer = session.createProducer(destination);
producer.setTimeToLive(this.replyTimeToLive);
producer.setPriority(this.replyPriority);
producer.setDeliveryMode(this.replyDeliveryMode);
try {
producer.send(jmsReply);
if (this.explicitQosEnabledForReplies) {
producer.send(jmsReply,
this.replyDeliveryMode, this.replyPriority, this.replyTimeToLive);
}
else {
producer.send(jmsReply);
}
}
finally {
producer.close();

View File

@@ -47,6 +47,8 @@ public class JmsMessageDrivenEndpointParser extends AbstractSingleBeanDefinition
private static final String REPLY_DELIVERY_PERSISTENT = "reply-delivery-persistent";
private static final String EXPLICIT_QOS_ENABLED_FOR_REPLIES = "explicit-qos-enabled-for-replies";
private static String[] containerAttributes = new String[] {
JmsAdapterParserUtils.CONNECTION_FACTORY_PROPERTY,
@@ -176,6 +178,7 @@ public class JmsMessageDrivenEndpointParser extends AbstractSingleBeanDefinition
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, REPLY_TIME_TO_LIVE);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, REPLY_PRIORITY);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, REPLY_DELIVERY_PERSISTENT);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, EXPLICIT_QOS_ENABLED_FOR_REPLIES);
}
else {
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "channel", "requestChannel");

View File

@@ -522,6 +522,7 @@
<xsd:attribute name="reply-time-to-live" type="xsd:string"/>
<xsd:attribute name="reply-priority" type="xsd:string"/>
<xsd:attribute name="reply-delivery-persistent" type="xsd:string"/>
<xsd:attribute name="explicit-qos-enabled-for-replies" type="xsd:string"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

View File

@@ -274,6 +274,17 @@ public class JmsInboundGatewayParserTests {
assertEquals(12345L, accessor.getPropertyValue("replyTimeToLive"));
assertEquals(7, accessor.getPropertyValue("replyPriority"));
assertEquals(DeliveryMode.NON_PERSISTENT, accessor.getPropertyValue("replyDeliveryMode"));
assertEquals(true, accessor.getPropertyValue("explicitQosEnabledForReplies"));
}
@Test
public void replyQosPropertiesDisabledByDefault() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"inboundGatewayDefault.xml", this.getClass());
JmsMessageDrivenEndpoint gateway = context.getBean("gateway", JmsMessageDrivenEndpoint.class);
DirectFieldAccessor accessor = new DirectFieldAccessor(
new DirectFieldAccessor(gateway).getPropertyValue("listener"));
assertEquals(false, accessor.getPropertyValue("explicitQosEnabledForReplies"));
}
}

View File

@@ -0,0 +1,29 @@
<?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:si="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">
<si:channel id="requestChannel">
<si:queue/>
</si:channel>
<jms:inbound-gateway id="gateway"
request-destination-name="testDestinationName"
request-channel="requestChannel"/>
<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>
</beans>

View File

@@ -19,7 +19,8 @@
request-channel="requestChannel"
reply-time-to-live="12345"
reply-priority="7"
reply-delivery-persistent="false"/>
reply-delivery-persistent="false"
explicit-qos-enabled-for-replies="true"/>
<bean id="connectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory">
<constructor-arg>