INT-1708, INT-1709 added error-channel to the poller

This commit is contained in:
Oleg Zhurakousky
2011-01-20 09:09:41 -05:00
parent 21b5809057
commit a1d205e7a1
6 changed files with 73 additions and 12 deletions

View File

@@ -130,7 +130,7 @@ public class SourcePollingChannelAdapterFactoryBean implements FactoryBean<Sourc
this.pollerMetadata.setMaxMessagesPerPoll(1);
}
spca.setPollerMetadata(this.pollerMetadata);
spca.setErrorHandler(this.pollerMetadata.getErrorHandler());
spca.setBeanClassLoader(this.beanClassLoader);
spca.setAutoStartup(this.autoStartup);
spca.setBeanName(this.beanName);

View File

@@ -99,6 +99,14 @@ public class PollerParser extends AbstractBeanDefinitionParser {
configureAdviceChain(adviceChainElement, txElement, metadataBuilder, parserContext);
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(metadataBuilder, element, "task-executor");
String errorChannel = element.getAttribute("error-channel");
if (StringUtils.hasText(errorChannel)){
BeanDefinitionBuilder errorHandler = BeanDefinitionBuilder.genericBeanDefinition(
"org.springframework.integration.channel.MessagePublishingErrorHandler");
errorHandler.addPropertyReference("defaultErrorChannel", errorChannel);
metadataBuilder.addPropertyValue("errorHandler", errorHandler.getBeanDefinition());
}
return metadataBuilder.getBeanDefinition();
}

View File

@@ -22,6 +22,7 @@ import java.util.concurrent.Executor;
import org.aopalliance.aop.Advice;
import org.springframework.scheduling.Trigger;
import org.springframework.scheduling.support.PeriodicTrigger;
import org.springframework.util.ErrorHandler;
/**
* @author Mark Fisher
@@ -36,6 +37,8 @@ public class PollerMetadata {
private volatile long maxMessagesPerPoll = MAX_MESSAGES_UNBOUNDED;
private volatile long receiveTimeout = 1000;
private volatile ErrorHandler errorHandler;
private List<Advice> adviceChain;
@@ -48,6 +51,14 @@ public class PollerMetadata {
public Trigger getTrigger() {
return this.trigger;
}
public ErrorHandler getErrorHandler() {
return errorHandler;
}
public void setErrorHandler(ErrorHandler errorHandler) {
this.errorHandler = errorHandler;
}
/**
* Set the maximum number of messages to receive for each poll.

View File

@@ -1242,6 +1242,15 @@ endpoint itself is a Polling Consumer for a channel with a queue.
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="error-channel" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
Identifies channel that error messages will be sent to if a failure occurs in this
poller's invocation. To completely suppress Exceptions, provide a
reference to the "nullChannel" here.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<xsd:complexType name="intervalTriggerType">