GH-3107: Add errorOnTimeout for TcpInboundGateway
Fixes https://github.com/spring-projects/spring-integration/issues/3107 The `MessagingGatewaySupport` has an `errorOnTimeout` option to throw a `MessageTimeoutException` when downstream reply doesn't come back in time for configured reply timeout * Expose an `errorOnTimeout` option as a `TcpInboundGateway` ctor property * Add new factory methods into a `Tcp` factory for Java DSL * Ensure a property works as expected in the `IpIntegrationTests` * Document a new option * Add a setter for MessagingGatewaySupport.errorOnTimeout option * Expose an `errorOnTimeout` option on the DSL's `MessagingGatewaySpec` making all the out-of-the-box inbound gateways possible to react to the `MessageTimeoutException` when no reply during reply timeout * Propagate properly `errorOnTimeout` in the `JmsInboundGateway` * Modify docs respectively * Improve docs about `errorOnTimeout`
This commit is contained in:
committed by
Gary Russell
parent
0bbdd3a5f7
commit
72f7c72392
@@ -154,6 +154,22 @@ public abstract class MessagingGatewaySpec<S extends MessagingGatewaySpec<S, G>,
|
||||
return _this();
|
||||
}
|
||||
|
||||
/**
|
||||
* If errorOnTimeout is true, construct an instance that will send an
|
||||
* {@link org.springframework.messaging.support.ErrorMessage} with a
|
||||
* {@link org.springframework.integration.MessageTimeoutException} payload to the error channel
|
||||
* if a reply is expected but none is received. If no error channel is configured,
|
||||
* the {@link org.springframework.integration.MessageTimeoutException} will be thrown.
|
||||
* @param errorOnTimeout true to create the error message on reply timeout.
|
||||
* @return the spec
|
||||
* @since 5.2.2
|
||||
* @see MessagingGatewaySupport#setErrorOnTimeout
|
||||
*/
|
||||
public S errorOnTimeout(boolean errorOnTimeout) {
|
||||
this.target.setErrorOnTimeout(errorOnTimeout);
|
||||
return _this();
|
||||
}
|
||||
|
||||
/**
|
||||
* An {@link InboundMessageMapper} to use.
|
||||
* @param requestMapper the requestMapper.
|
||||
|
||||
@@ -88,7 +88,7 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
|
||||
private final Object replyMessageCorrelatorMonitor = new Object();
|
||||
|
||||
private final boolean errorOnTimeout;
|
||||
private boolean errorOnTimeout;
|
||||
|
||||
private final AtomicLong messageCount = new AtomicLong();
|
||||
|
||||
@@ -139,6 +139,7 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
* configured, the {@link MessageTimeoutException} will be thrown.
|
||||
* @param errorOnTimeout true to create the error message.
|
||||
* @since 4.2
|
||||
* @see #setErrorOnTimeout
|
||||
*/
|
||||
public MessagingGatewaySupport(boolean errorOnTimeout) {
|
||||
MessagingTemplate template = new MessagingTemplate();
|
||||
@@ -149,6 +150,17 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
this.errorOnTimeout = errorOnTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* If errorOnTimeout is true, construct an instance that will send an
|
||||
* {@link ErrorMessage} with a {@link MessageTimeoutException} payload to the error
|
||||
* channel if a reply is expected but none is received. If no error channel is
|
||||
* configured, the {@link MessageTimeoutException} will be thrown.
|
||||
* @param errorOnTimeout true to create the error message on reply timeout.
|
||||
* @since 5.2.2
|
||||
*/
|
||||
public void setErrorOnTimeout(boolean errorOnTimeout) {
|
||||
this.errorOnTimeout = errorOnTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the request channel.
|
||||
|
||||
Reference in New Issue
Block a user