INT-2216 - For Payload Enricher - add: 'request-timeout' and 'reply-timeout' attributes

For reference see: https://jira.springsource.org/browse/INT-2216
This commit is contained in:
Gunnar Hillert
2011-11-21 16:18:37 -05:00
parent d484f65100
commit 94f2dc755f
6 changed files with 156 additions and 2 deletions

View File

@@ -44,7 +44,10 @@ public class EnricherParser extends AbstractConsumerEndpointParser {
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "request-channel");
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "reply-channel");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "request-timeout");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "reply-timeout");
List<Element> propertyElements = DomUtils.getChildElementsByTagName(element, "property");
if (!CollectionUtils.isEmpty(propertyElements)) {
ManagedMap<String, Object> propertyExpressions = new ManagedMap<String, Object>();

View File

@@ -63,6 +63,9 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
private volatile Gateway gateway = null;
private volatile Long requestTimeout;
private volatile Long replyTimeout;
/**
* Provide the map of expressions to evaluate when enriching the target payload.
@@ -102,6 +105,28 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
this.replyChannel = replyChannel;
}
/**
* Set the timeout value for sending request messages. If not explicitly
* configured, the default is one second.
*
* @param requestTimeout the timeout value in milliseconds. Must not be null.
*/
public void setRequestTimeout(Long requestTimeout) {
Assert.notNull(requestTimeout, "requestTimeout must not be null");
this.requestTimeout = requestTimeout;
}
/**
* Set the timeout value for receiving reply messages. If not explicitly
* configured, the default is one second.
*
* @param replyTimeout the timeout value in milliseconds. Must not be null.
*/
public void setReplyTimeout(Long replyTimeout) {
Assert.notNull(replyTimeout, "replyTimeout must not be null");
this.replyTimeout = replyTimeout;
}
/**
* By default the original message's payload will be used as the actual payload
* that will be send to the request-channel.
@@ -152,9 +177,19 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
if (this.requestChannel != null) {
this.gateway = new Gateway();
this.gateway.setRequestChannel(requestChannel);
if (this.requestTimeout != null) {
this.gateway.setRequestTimeout(this.requestTimeout);
}
if (this.replyTimeout != null) {
this.gateway.setReplyTimeout(this.replyTimeout);
}
if (replyChannel != null) {
this.gateway.setReplyChannel(replyChannel);
}
this.gateway.afterPropertiesSet();
}
this.evaluationContext.addPropertyAccessor(new MapAccessor());

View File

@@ -1043,6 +1043,24 @@ endpoint itself is a Polling Consumer for a channel with a queue.
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="request-timeout" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
Set the timeout value for sending request messages in milliseconds.
If not explicitly configured, the default is one second.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="reply-timeout" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
Set the timeout value for receiving reply messages in milliseconds.
If not explicitly configured, the default is one second.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="should-clone-payload">
<xsd:annotation>
<xsd:documentation>