INT-3887: Add receiveTimeout into the @Poller
JIRA: https://jira.spring.io/browse/INT-3887
This commit is contained in:
committed by
Gary Russell
parent
13f9ab6da8
commit
7702a6f89e
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2018 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.
|
||||
@@ -39,6 +39,7 @@ import org.springframework.scheduling.support.PeriodicTrigger;
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Target({})
|
||||
@@ -92,4 +93,15 @@ public @interface Poller {
|
||||
*/
|
||||
String errorChannel() default "";
|
||||
|
||||
/**
|
||||
* Only applies to polling consumers.
|
||||
* @return the time the poll thread will wait after the trigger for a new message to arrive.
|
||||
* Defaults to 1000 (1 second).
|
||||
* For polled inbound channel adapters, whether or not the polling thread blocks
|
||||
* is dependent on the message source implementation.
|
||||
* Can be specified as 'property placeholder', e.g. {@code ${my.poller.receiveTimeout}}.
|
||||
* @since 5.1
|
||||
*/
|
||||
String receiveTimeout() default "";
|
||||
|
||||
}
|
||||
|
||||
@@ -364,6 +364,7 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
String maxMessagesPerPollValue = this.beanFactory.resolveEmbeddedValue(poller.maxMessagesPerPoll());
|
||||
String cron = this.beanFactory.resolveEmbeddedValue(poller.cron());
|
||||
String errorChannel = this.beanFactory.resolveEmbeddedValue(poller.errorChannel());
|
||||
String receiveTimeout = this.beanFactory.resolveEmbeddedValue(poller.receiveTimeout());
|
||||
|
||||
if (StringUtils.hasText(ref)) {
|
||||
Assert.state(!StringUtils.hasText(triggerRef) && !StringUtils.hasText(executorRef) &&
|
||||
@@ -416,6 +417,10 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
errorHandler.setBeanFactory(this.beanFactory);
|
||||
pollerMetadata.setErrorHandler(errorHandler);
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(receiveTimeout)) {
|
||||
pollerMetadata.setReceiveTimeout(Long.parseLong(receiveTimeout));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -499,8 +504,8 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
for (Annotation annotation : annotations) {
|
||||
Object value = AnnotationUtils.getValue(annotation, attribute);
|
||||
if (MessagingAnnotationUtils.hasValue(value)) {
|
||||
throw new BeanDefinitionValidationException("The MessageHandler [" + handlerBeanName + "] can not" +
|
||||
" be populated because of ambiguity with annotation attributes " +
|
||||
throw new BeanDefinitionValidationException("The MessageHandler [" + handlerBeanName +
|
||||
"] can not be populated because of ambiguity with annotation attributes " +
|
||||
this.messageHandlerAttributes + " which are not allowed when an integration annotation " +
|
||||
"is used with a @Bean definition for a MessageHandler." +
|
||||
"\nThe attribute causing the ambiguity is: [" + attribute + "]." +
|
||||
|
||||
Reference in New Issue
Block a user