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 a
PollableMessageSource.- Since:
- 2.0
- Author:
- Gary Russell, Oleg Zhurakousky, David Turanski
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final ThreadLocal<org.springframework.core.AttributeAccessor> -
Constructor Summary
ConstructorsConstructorDescriptionDefaultPollableMessageSource(org.springframework.messaging.converter.SmartMessageConverter messageConverter) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInterceptor(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) boolean<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 booleanvoidstart()voidstop()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.retry.RetryListener
onSuccess
-
Field Details
-
attributesHolder
-
-
Constructor Details
-
DefaultPollableMessageSource
public DefaultPollableMessageSource(@Nullable org.springframework.messaging.converter.SmartMessageConverter messageConverter) - Parameters:
messageConverter- instance ofSmartMessageConverter. Can be null.
-
-
Method Details
-
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
-
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
-
onError
public <T,E extends Throwable> void onError(org.springframework.retry.RetryContext context, org.springframework.retry.RetryCallback<T, E> callback, Throwable throwable) - Specified by:
onErrorin interfaceorg.springframework.retry.RetryListener
-