INT-3902: XML: SmartLifecycle, Order Attributes
JIRA: https://jira.spring.io/browse/INT-3902 Polishing Polishing - PR Comments Introduce `RouterFactoryBean.setSendTimeout` and deprecate `setTimeout`
This commit is contained in:
committed by
Artem Bilan
parent
74cbc58698
commit
d684dc4d0e
@@ -44,7 +44,7 @@ public class RouterFactoryBean extends AbstractStandardMessageHandlerFactoryBean
|
||||
|
||||
private volatile String defaultOutputChannelName;
|
||||
|
||||
private volatile Long timeout;
|
||||
private volatile Long sendTimeout;
|
||||
|
||||
private volatile Boolean resolutionRequired;
|
||||
|
||||
@@ -60,8 +60,17 @@ public class RouterFactoryBean extends AbstractStandardMessageHandlerFactoryBean
|
||||
this.defaultOutputChannelName = defaultOutputChannelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param timeout the timeout.
|
||||
* @deprecated in favor of {@link #setSendTimeout(Long)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setTimeout(Long timeout) {
|
||||
this.timeout = timeout;
|
||||
this.sendTimeout = timeout;
|
||||
}
|
||||
|
||||
public void setSendTimeout(Long timeout) {
|
||||
this.sendTimeout = timeout;
|
||||
}
|
||||
|
||||
public void setResolutionRequired(Boolean resolutionRequired) {
|
||||
@@ -121,8 +130,8 @@ public class RouterFactoryBean extends AbstractStandardMessageHandlerFactoryBean
|
||||
if (this.defaultOutputChannelName != null) {
|
||||
router.setDefaultOutputChannelName(this.defaultOutputChannelName);
|
||||
}
|
||||
if (this.timeout != null) {
|
||||
router.setTimeout(this.timeout);
|
||||
if (this.sendTimeout != null) {
|
||||
router.setSendTimeout(this.sendTimeout);
|
||||
}
|
||||
if (this.applySequence != null) {
|
||||
router.setApplySequence(this.applySequence);
|
||||
@@ -152,7 +161,7 @@ public class RouterFactoryBean extends AbstractStandardMessageHandlerFactoryBean
|
||||
|
||||
private boolean noRouterAttributesProvided() {
|
||||
return this.channelMappings == null && this.defaultOutputChannel == null
|
||||
&& this.timeout == null && this.resolutionRequired == null && this.applySequence == null
|
||||
&& this.sendTimeout == null && this.resolutionRequired == null && this.applySequence == null
|
||||
&& this.ignoreSendFailures == null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -150,7 +150,7 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
((AbstractMessageProducingHandler) handler).setSendTimeout(value);
|
||||
}
|
||||
else {
|
||||
((AbstractMessageRouter) handler).setTimeout(value);
|
||||
((AbstractMessageRouter) handler).setSendTimeout(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -26,12 +26,14 @@ import org.springframework.beans.factory.support.ManagedMap;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.RouterFactoryBean;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
|
||||
/**
|
||||
* Base parser for routers.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public abstract class AbstractRouterParser extends AbstractConsumerEndpointParser {
|
||||
|
||||
@@ -39,7 +41,12 @@ public abstract class AbstractRouterParser extends AbstractConsumerEndpointParse
|
||||
protected final BeanDefinitionBuilder parseHandler(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(RouterFactoryBean.class);
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "default-output-channel");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "timeout");
|
||||
if (StringUtils.hasText(element.getAttribute("timeout"))
|
||||
&& StringUtils.hasText(element.getAttribute("send-timeout"))) {
|
||||
parserContext.getReaderContext().error("Only one of 'timeout' and 'send-timeout' is allowed", element);
|
||||
}
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "timeout", "sendTimeout");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "send-timeout");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "resolution-required");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "apply-sequence");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "ignore-send-failures");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -18,7 +18,6 @@ package org.springframework.integration.router;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.support.DefaultConversionService;
|
||||
import org.springframework.integration.channel.NullChannel;
|
||||
@@ -30,7 +29,6 @@ import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.core.DestinationResolutionException;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -80,11 +78,23 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler {
|
||||
* Set the timeout for sending a message to the resolved channel. By default, there is no timeout, meaning the send
|
||||
* will block indefinitely.
|
||||
* @param timeout The timeout.
|
||||
* @deprecated in favor of {@link #setSendTimeout(long)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setTimeout(long timeout) {
|
||||
this.messagingTemplate.setSendTimeout(timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the timeout for sending a message to the resolved channel.
|
||||
* By default, there is no timeout, meaning the send will block indefinitely.
|
||||
* @param timeout The timeout.
|
||||
* @since 4.3
|
||||
*/
|
||||
public void setSendTimeout(long timeout) {
|
||||
this.messagingTemplate.setSendTimeout(timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether send failures for one or more of the recipients should be ignored. By default this is
|
||||
* <code>false</code> meaning that an Exception will be thrown whenever a send fails. To override this and suppress
|
||||
|
||||
@@ -3394,8 +3394,21 @@
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Specify the maximum amount of time in milliseconds to wait
|
||||
when sending Messages to the target MessageChannels. By
|
||||
default the send will block indefinitely.
|
||||
when sending Messages to the target MessageChannels if blocking
|
||||
is possible (e.g. a bounded queue channel that is currently full).
|
||||
By default the send will block indefinitely.
|
||||
DEPRECATED in favor of 'send-timeout' for consistency with other elements.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="send-timeout" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Specify the maximum amount of time in milliseconds to wait
|
||||
when sending Messages to the target MessageChannels if blocking
|
||||
is possible (e.g. a bounded queue channel that is currently full).
|
||||
By default the send will block indefinitely.
|
||||
Synonym for 'timeout' - only one can be supplied.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -115,7 +115,7 @@ public class RecipientListRouterTests {
|
||||
channelB.setBeanName("channelB");
|
||||
channelC.setBeanName("channelC");
|
||||
RecipientListRouter router = new RecipientListRouter();
|
||||
router.setTimeout(0);
|
||||
router.setSendTimeout(0);
|
||||
List<MessageChannel> channels = new ArrayList<MessageChannel>();
|
||||
channels.add(channelA);
|
||||
channels.add(channelB);
|
||||
@@ -145,7 +145,7 @@ public class RecipientListRouterTests {
|
||||
channelB.setBeanName("channelB");
|
||||
channelC.setBeanName("channelC");
|
||||
RecipientListRouter router = new RecipientListRouter();
|
||||
router.setTimeout(0);
|
||||
router.setSendTimeout(0);
|
||||
List<MessageChannel> channels = new ArrayList<MessageChannel>();
|
||||
channels.add(channelA);
|
||||
channels.add(channelB);
|
||||
@@ -177,7 +177,7 @@ public class RecipientListRouterTests {
|
||||
channelB.setBeanName("channelB");
|
||||
channelC.setBeanName("channelC");
|
||||
RecipientListRouter router = new RecipientListRouter();
|
||||
router.setTimeout(0);
|
||||
router.setSendTimeout(0);
|
||||
List<MessageChannel> channels = new ArrayList<MessageChannel>();
|
||||
channels.add(channelA);
|
||||
channels.add(channelB);
|
||||
@@ -212,7 +212,7 @@ public class RecipientListRouterTests {
|
||||
channelC.setBeanName("channelC");
|
||||
RecipientListRouter router = new RecipientListRouter();
|
||||
router.setIgnoreSendFailures(true);
|
||||
router.setTimeout(0);
|
||||
router.setSendTimeout(0);
|
||||
List<MessageChannel> channels = new ArrayList<MessageChannel>();
|
||||
channels.add(channelA);
|
||||
channels.add(channelB);
|
||||
@@ -242,7 +242,7 @@ public class RecipientListRouterTests {
|
||||
channelC.setBeanName("channelC");
|
||||
RecipientListRouter router = new RecipientListRouter();
|
||||
router.setIgnoreSendFailures(true);
|
||||
router.setTimeout(0);
|
||||
router.setSendTimeout(0);
|
||||
List<MessageChannel> channels = new ArrayList<MessageChannel>();
|
||||
channels.add(channelA);
|
||||
channels.add(channelB);
|
||||
@@ -272,7 +272,7 @@ public class RecipientListRouterTests {
|
||||
channelC.setBeanName("channelC");
|
||||
RecipientListRouter router = new RecipientListRouter();
|
||||
router.setIgnoreSendFailures(true);
|
||||
router.setTimeout(0);
|
||||
router.setSendTimeout(0);
|
||||
List<MessageChannel> channels = new ArrayList<MessageChannel>();
|
||||
channels.add(channelA);
|
||||
channels.add(channelB);
|
||||
|
||||
Reference in New Issue
Block a user