Skip to content

Commit d3772dc

Browse files
committed
+ remote timeout & connect timeout setters
1 parent 0fc1336 commit d3772dc

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ This is just a simple implementation of single request/reply using dynamic regis
2222
.deserializer(deserializer)
2323
.serializer(serializer)
2424
.cacheable("!headers['host'].equals(\"127.0.0.1\")")
25+
.connectTimeout(30)
26+
.remoteTimeout(20_000L)
2527
.responseChannelName("serverResponseChannel"))
2628
.get();
2729
}

dynamic-tcp/src/main/java/org/spring/integration/dynamic/tcp/spec/DynamicTcpOutboundGatewaySpec.java

+25
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.springframework.integration.dsl.MessageProcessorSpec;
77
import org.springframework.integration.dsl.context.IntegrationFlowContext;
88
import org.springframework.integration.expression.FunctionExpression;
9+
import org.springframework.integration.expression.ValueExpression;
910
import org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer;
1011
import org.springframework.messaging.Message;
1112

@@ -142,6 +143,30 @@ public DynamicTcpOutboundGatewaySpec remoteTimeout(String expression) {
142143
return _this();
143144
}
144145

146+
/**
147+
* Setting a connectTimeout value retrieving expression from message
148+
*
149+
* @param timeout connect timeout value
150+
* @return DynamicTcpOutboundGatewaySpec
151+
*/
152+
public DynamicTcpOutboundGatewaySpec connectTimeout(int timeout) {
153+
getRequestFlow().setConnectTimeout(new ValueExpression<>(timeout));
154+
return _this();
155+
}
156+
157+
/**
158+
* Setting a remoteTimeout value retrieving expression from message
159+
*
160+
* @param timeout remote timeout value
161+
* @return DynamicTcpOutboundGatewaySpec
162+
*/
163+
public DynamicTcpOutboundGatewaySpec remoteTimeout(long timeout) {
164+
getRequestFlow().setRemoteTimeout(new ValueExpression<>(timeout));
165+
return _this();
166+
}
167+
168+
169+
145170
private DynamicTcpOutboundGateway getRequestFlow() {
146171
return (DynamicTcpOutboundGateway) this.target;
147172
}

0 commit comments

Comments
 (0)