INT-1772 The 'send-timeout' attribute is now available on inbound-channel-adapter elements
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2011 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.
|
||||
@@ -45,6 +45,8 @@ public class SourcePollingChannelAdapterFactoryBean
|
||||
|
||||
private volatile PollerMetadata pollerMetadata;
|
||||
|
||||
private volatile Long sendTimeout;
|
||||
|
||||
private volatile boolean autoStartup = true;
|
||||
|
||||
private volatile String beanName;
|
||||
@@ -72,6 +74,10 @@ public class SourcePollingChannelAdapterFactoryBean
|
||||
this.pollerMetadata = pollerMetadata;
|
||||
}
|
||||
|
||||
public void setSendTimeout(Long sendTimeout) {
|
||||
this.sendTimeout = sendTimeout;
|
||||
}
|
||||
|
||||
public void setAutoStartup(boolean autoStartup) {
|
||||
this.autoStartup = autoStartup;
|
||||
}
|
||||
@@ -126,6 +132,9 @@ public class SourcePollingChannelAdapterFactoryBean
|
||||
}
|
||||
spca.setTrigger(this.pollerMetadata.getTrigger());
|
||||
spca.setMaxMessagesPerPoll(this.pollerMetadata.getMaxMessagesPerPoll());
|
||||
if (this.sendTimeout != null) {
|
||||
spca.setSendTimeout(this.sendTimeout);
|
||||
}
|
||||
spca.setTaskExecutor(this.pollerMetadata.getTaskExecutor());
|
||||
spca.setTransactionManager(this.pollerMetadata.getTransactionManager());
|
||||
spca.setTransactionDefinition(this.pollerMetadata.getTransactionDefinition());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2011 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.
|
||||
@@ -45,6 +45,7 @@ public abstract class AbstractPollingInboundChannelAdapterParser extends Abstrac
|
||||
if (pollerElement != null) {
|
||||
IntegrationNamespaceUtils.configurePollerMetadata(pollerElement, adapterBuilder, parserContext);
|
||||
}
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(adapterBuilder, element, "send-timeout");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(adapterBuilder, element, "auto-startup");
|
||||
return adapterBuilder.getBeanDefinition();
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="inbound-channel-adapter" type="methodInvokingChannelAdapterType">
|
||||
<xsd:element name="inbound-channel-adapter">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Defines a Channel Adapter that receives from a
|
||||
@@ -347,6 +347,20 @@
|
||||
MessageChannel.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="methodInvokingChannelAdapterType">
|
||||
<xsd:attribute name="send-timeout" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Maximum amount of time in milliseconds to wait when sending a message to the channel if such channel may block.
|
||||
For example, a Queue Channel can block until space is available if its maximum capacity has been reached.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="outbound-channel-adapter">
|
||||
|
||||
@@ -21,6 +21,17 @@
|
||||
</poller>
|
||||
</inbound-channel-adapter>
|
||||
|
||||
<channel id="withTimeoutChannel">
|
||||
<queue/>
|
||||
</channel>
|
||||
|
||||
<inbound-channel-adapter id="methodInvokingSourceWithTimeout" ref="testBean" method="getMessage"
|
||||
channel="withTimeoutChannel" auto-startup="false" send-timeout="999">
|
||||
<poller max-messages-per-poll="1">
|
||||
<interval-trigger interval="800" fixed-rate="true"/>
|
||||
</poller>
|
||||
</inbound-channel-adapter>
|
||||
|
||||
<beans:bean id="consumer" class="org.springframework.integration.config.TestConsumer"/>
|
||||
|
||||
<beans:bean id="testBean" class="org.springframework.integration.config.TestBean"/>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2011 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.
|
||||
@@ -36,6 +36,7 @@ import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
import org.springframework.integration.util.TestUtils;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -180,4 +181,14 @@ public class ChannelAdapterParserTests {
|
||||
channelResolver.resolveChannelName("methodInvokingSource");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void methodInvokingSourceWithSendTimeout() throws Exception{
|
||||
String beanName = "methodInvokingSourceWithTimeout";
|
||||
SourcePollingChannelAdapter adapter =
|
||||
(SourcePollingChannelAdapter) this.applicationContext.getBean(beanName);
|
||||
assertNotNull(adapter);
|
||||
long sendTimeout = TestUtils.getPropertyValue(adapter, "channelTemplate.sendTimeout", Long.class);
|
||||
assertEquals(999, sendTimeout);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user