Class DefaultPollableMessageSource
- java.lang.Object
-
- org.springframework.cloud.stream.binder.DefaultPollableMessageSource
-
- All Implemented Interfaces:
PollableMessageSource,PollableSource<org.springframework.messaging.MessageHandler>,org.springframework.context.Lifecycle,org.springframework.retry.RetryListener
public class DefaultPollableMessageSource extends Object implements PollableMessageSource, org.springframework.context.Lifecycle, org.springframework.retry.RetryListener
The default implementation of aPollableMessageSource.- Since:
- 2.0
- Author:
- Gary Russell, Oleg Zhurakousky, David Turanski
-
-
Field Summary
Fields Modifier and Type Field Description protected static ThreadLocal<org.springframework.core.AttributeAccessor>attributesHolder
-
Constructor Summary
Constructors Constructor Description DefaultPollableMessageSource(org.springframework.messaging.converter.SmartMessageConverter messageConverter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInterceptor(int index, org.springframework.messaging.support.ChannelInterceptor interceptor)voidaddInterceptor(org.springframework.messaging.support.ChannelInterceptor interceptor)<T,E extends Throwable>
voidclose(org.springframework.retry.RetryContext context, org.springframework.retry.RetryCallback<T,E> callback, Throwable throwable)booleanisRunning()<T,E extends Throwable>
voidonError(org.springframework.retry.RetryContext context, org.springframework.retry.RetryCallback<T,E> callback, Throwable throwable)<T,E extends Throwable>
booleanopen(org.springframework.retry.RetryContext context, org.springframework.retry.RetryCallback<T,E> callback)booleanpoll(org.springframework.messaging.MessageHandler handler)Poll the consumer.booleanpoll(org.springframework.messaging.MessageHandler handler, org.springframework.core.ParameterizedTypeReference<?> type)Poll the consumer and convert the payload to the type.voidsetAttributesProvider(BiConsumer<org.springframework.core.AttributeAccessor,org.springframework.messaging.Message<?>> attributesProvider)voidsetErrorChannel(org.springframework.messaging.MessageChannel errorChannel)voidsetErrorMessageStrategy(org.springframework.integration.support.ErrorMessageStrategy errorMessageStrategy)voidsetRecoveryCallback(org.springframework.retry.RecoveryCallback<Object> recoveryCallback)voidsetRetryTemplate(org.springframework.retry.support.RetryTemplate retryTemplate)voidsetSource(org.springframework.integration.core.MessageSource<?> source)protected booleanshouldRequeue(Exception e)voidstart()voidstop()
-
-
-
Field Detail
-
attributesHolder
protected static final ThreadLocal<org.springframework.core.AttributeAccessor> attributesHolder
-
-
Method Detail
-
setSource
public void setSource(org.springframework.integration.core.MessageSource<?> source)
-
setRetryTemplate
public void setRetryTemplate(org.springframework.retry.support.RetryTemplate retryTemplate)
-
setRecoveryCallback
public void setRecoveryCallback(org.springframework.retry.RecoveryCallback<Object> recoveryCallback)
-
setErrorChannel
public void setErrorChannel(org.springframework.messaging.MessageChannel errorChannel)
-
setErrorMessageStrategy
public void setErrorMessageStrategy(org.springframework.integration.support.ErrorMessageStrategy errorMessageStrategy)
-
setAttributesProvider
public void setAttributesProvider(BiConsumer<org.springframework.core.AttributeAccessor,org.springframework.messaging.Message<?>> attributesProvider)
-
addInterceptor
public void addInterceptor(org.springframework.messaging.support.ChannelInterceptor interceptor)
-
addInterceptor
public void addInterceptor(int index, org.springframework.messaging.support.ChannelInterceptor interceptor)
-
isRunning
public boolean isRunning()
- Specified by:
isRunningin interfaceorg.springframework.context.Lifecycle
-
start
public void start()
- Specified by:
startin interfaceorg.springframework.context.Lifecycle
-
stop
public void stop()
- Specified by:
stopin interfaceorg.springframework.context.Lifecycle
-
poll
public boolean poll(org.springframework.messaging.MessageHandler handler)
Description copied from interface:PollableSourcePoll the consumer.- Specified by:
pollin interfacePollableSource<org.springframework.messaging.MessageHandler>- Parameters:
handler- the handler.- Returns:
- true if a message was handled.
-
poll
public boolean poll(org.springframework.messaging.MessageHandler handler, org.springframework.core.ParameterizedTypeReference<?> type)Description copied from interface:PollableSourcePoll the consumer and convert the payload to the type. Throw aRequeueCurrentMessageExceptionto force the current message to be requeued in the broker (after retries are exhausted, if configured).- Specified by:
pollin interfacePollableSource<org.springframework.messaging.MessageHandler>- Parameters:
handler- the handler.type- the type.- Returns:
- true if a message was handled.
-
shouldRequeue
protected boolean shouldRequeue(Exception e)
-
open
public <T,E extends Throwable> boolean open(org.springframework.retry.RetryContext context, org.springframework.retry.RetryCallback<T,E> callback)
- Specified by:
openin interfaceorg.springframework.retry.RetryListener
-
close
public <T,E extends Throwable> void close(org.springframework.retry.RetryContext context, org.springframework.retry.RetryCallback<T,E> callback, Throwable throwable)
- Specified by:
closein interfaceorg.springframework.retry.RetryListener
-
-