INT-2264, INT-2263 TCP GW Reconcile reply-timeout
reply-timeout had the wrong function, when compared to other gateways. Add remote-timeout to reflect the time we will wait for a reply from the remote system Make reply-timeout set the sendTimeout on the messaging template Set remore-timeout to reply-timeout (if set) unless remote-timeout is explicitly set. Update reference doc, and migration guide on Wiki.
This commit is contained in:
@@ -95,6 +95,8 @@ public abstract class IpAdapterParserUtils {
|
||||
|
||||
public static final String REQUEST_TIMEOUT = "request-timeout";
|
||||
|
||||
public static final String REMOTE_TIMEOUT = "remote-timeout";
|
||||
|
||||
public static final String REPLY_TIMEOUT = "reply-timeout";
|
||||
|
||||
public static final String REPLY_CHANNEL = "reply-channel";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,7 +29,7 @@ import org.w3c.dom.Element;
|
||||
* @since 2.0
|
||||
*/
|
||||
public class TcpOutboundGatewayParser extends AbstractConsumerEndpointParser {
|
||||
|
||||
|
||||
private static final String BASE_PACKAGE = "org.springframework.integration.ip.tcp";
|
||||
|
||||
@Override
|
||||
@@ -41,14 +41,16 @@ public class TcpOutboundGatewayParser extends AbstractConsumerEndpointParser {
|
||||
protected BeanDefinitionBuilder parseHandler(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(BASE_PACKAGE +
|
||||
".TcpOutboundGateway");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element,
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element,
|
||||
IpAdapterParserUtils.TCP_CONNECTION_FACTORY);
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element,
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element,
|
||||
IpAdapterParserUtils.REPLY_CHANNEL);
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element,
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element,
|
||||
IpAdapterParserUtils.REQUEST_TIMEOUT);
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element,
|
||||
IpAdapterParserUtils.REPLY_TIMEOUT);
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element,
|
||||
IpAdapterParserUtils.REMOTE_TIMEOUT);
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element,
|
||||
IpAdapterParserUtils.REPLY_TIMEOUT, "sendTimeout");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element,
|
||||
IpAdapterParserUtils.AUTO_STARTUP);
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2011 the original author or authors.
|
||||
* Copyright 2001-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,7 +57,9 @@ public class TcpOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
|
||||
private Semaphore semaphore = new Semaphore(1, true);
|
||||
|
||||
private volatile long replyTimeout = 10000;
|
||||
private volatile long remoteTimeout = 10000L;
|
||||
|
||||
private volatile boolean remoteTimeoutSet = false;
|
||||
|
||||
private volatile long requestTimeout = 10000;
|
||||
|
||||
@@ -73,10 +75,24 @@ public class TcpOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
}
|
||||
|
||||
/**
|
||||
* @param replyTimeout the replyTimeout to set
|
||||
* @param remoteTimeout the remoteTimeout to set
|
||||
*/
|
||||
public void setReplyTimeout(long replyTimeout) {
|
||||
this.replyTimeout = replyTimeout;
|
||||
public void setRemoteTimeout(long remoteTimeout) {
|
||||
this.remoteTimeout = remoteTimeout;
|
||||
this.remoteTimeoutSet = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSendTimeout(long sendTimeout) {
|
||||
super.setSendTimeout(sendTimeout);
|
||||
/*
|
||||
* For backwards compatibility, also set the remote
|
||||
* timeout to this value, unless it has been
|
||||
* explicitly set.
|
||||
*/
|
||||
if (!this.remoteTimeoutSet) {
|
||||
this.remoteTimeout = sendTimeout;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -167,6 +183,7 @@ public class TcpOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
public void setReplyChannel(MessageChannel replyChannel) {
|
||||
this.setOutputChannel(replyChannel);
|
||||
}
|
||||
@Override
|
||||
public String getComponentType(){
|
||||
return "ip:tcp-outbound-gateway";
|
||||
}
|
||||
@@ -233,7 +250,7 @@ public class TcpOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
*/
|
||||
public Message<?> getReply() throws Exception {
|
||||
try {
|
||||
if (!this.latch.await(replyTimeout, TimeUnit.MILLISECONDS)) {
|
||||
if (!this.latch.await(remoteTimeout, TimeUnit.MILLISECONDS)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,8 +329,38 @@ task executors such as a WorkManagerTaskExecutor.
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="request-timeout" type="xsd:string"/>
|
||||
<xsd:attribute name="reply-timeout" type="xsd:string"/>
|
||||
<xsd:attribute name="request-timeout" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
When using a shared socket, specifies the time the gateway will wait
|
||||
to get access to the socket to send the request.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="reply-timeout" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Specifies the time the gateway will wait while sending
|
||||
the reply to the reply channel; only applies when the
|
||||
channel might block (such as a bounded queue channel that
|
||||
is currently full).
|
||||
Prior to 2.2, this attribute served the function of
|
||||
the remote-timeout attribute; it has been changed
|
||||
to make it consistent with other endpoints.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="remote-timeout" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Specifies the time the gateway will wait for a reply
|
||||
from the remote system. Prior to 2.2, this was specified
|
||||
with the reply-timeout attribute. To provide easier migration,
|
||||
this attribute defaults to the same value of the reply-timeout,
|
||||
if supplied, or 10 seconds otherwise.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="order">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
|
||||
Reference in New Issue
Block a user