Class NonBlockingRetryErrorHandler
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.MessageHandlerSupport
org.springframework.integration.handler.AbstractMessageHandler
com.broadleafcommerce.common.messaging.error.LoggingGlobalErrorChannelListener
com.broadleafcommerce.common.messaging.retry.nonblocking.NonBlockingRetryErrorHandler
- All Implemented Interfaces:
GlobalErrorChannelListener,Consumer<org.springframework.messaging.support.ErrorMessage>,org.reactivestreams.Subscriber<org.springframework.messaging.Message<?>>,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware,org.springframework.core.Ordered,org.springframework.integration.context.ExpressionCapable,org.springframework.integration.context.Orderable,org.springframework.integration.IntegrationPattern,org.springframework.integration.support.context.NamedComponent,org.springframework.integration.support.management.IntegrationManagement,org.springframework.integration.support.management.TrackableComponent,org.springframework.messaging.MessageHandler,reactor.core.CoreSubscriber<org.springframework.messaging.Message<?>>
public class NonBlockingRetryErrorHandler
extends LoggingGlobalErrorChannelListener
implements Consumer<org.springframework.messaging.support.ErrorMessage>
For the non-blocking retry case. Handles exceptions during message processing attempts. Performs
a number of interesting functions:
- Keeps track of the number of retries and correlates retry attempts according to the list of
retry configs associated with
NonBlockingRetryProperties.getBindings() - Will send a message to a retry channel if a retry config is available and not exhausted
- Will send a message to a DLQ if one is configured and retries are exhausted
- Will log failure using the last exception if no DLQ is configured
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
org.springframework.integration.support.management.IntegrationManagement.ManagementOverrides -
Field Summary
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionNonBlockingRetryErrorHandler(String originalProducerBinding, String originalConsumerBinding, String group, NonBlockingRetryProperties nonBlockingRetryProperties, com.broadleafcommerce.common.extension.compatibility.support.messaging.TimeoutAwareStreamBridge streamBridge, org.springframework.core.convert.converter.Converter<String, String> traceTruncator) -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(org.springframework.messaging.support.ErrorMessage errorMessage) protected org.springframework.classify.BinaryExceptionClassifierBuild theBinaryExceptionClassifierinstance responsible for inspecting exceptions and determining inclusion or exclusion, if applicable.protected ExceptionRetrieve the relevant root exception for reporting as a header on the messageprotected voidhandleMessageInternal(org.springframework.messaging.Message<?> message) Handle message failure.protected NonBlockingFixedRetryInfoIdentify the last retry config in the list of retry configsprotected NonBlockingFixedRetryInfoidentifyRetryPhase(List<NonBlockingFixedRetryInfo> retries, org.springframework.messaging.MessagingException messagingException, AtomicInteger counter) Based on the count, identify the current retry config that should be consideredprotected voidsendToDlq(NonBlockingFixedRetryInfo finalRetry, int attempt, org.springframework.messaging.support.ErrorMessage errorMessage, org.springframework.messaging.Message<?> original) Send a failed message to a DLQprotected voidsendToRetryChannel(NonBlockingFixedRetryInfo info, int attempt, org.springframework.messaging.Message<?> original) Send a failed message to a configured retry channelMethods inherited from class com.broadleafcommerce.common.messaging.error.LoggingGlobalErrorChannelListener
formatOriginalMessageHeaders, formatOriginalMessagePayload, logErrorMessageMethods inherited from class org.springframework.integration.handler.AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribe, setObservationConventionMethods inherited from class org.springframework.integration.handler.MessageHandlerSupport
buildSendTimer, destroy, getComponentType, getIntegrationPatternType, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrackMethods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, onInit, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface reactor.core.CoreSubscriber
currentContextMethods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAsMethods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
NonBlockingRetryErrorHandler
public NonBlockingRetryErrorHandler(String originalProducerBinding, String originalConsumerBinding, String group, NonBlockingRetryProperties nonBlockingRetryProperties, com.broadleafcommerce.common.extension.compatibility.support.messaging.TimeoutAwareStreamBridge streamBridge, org.springframework.core.convert.converter.Converter<String, String> traceTruncator)
-
-
Method Details
-
accept
public void accept(org.springframework.messaging.support.ErrorMessage errorMessage) -
handleMessageInternal
protected void handleMessageInternal(org.springframework.messaging.Message<?> message) Handle message failure. Will send to a retry channel, send to a DLQ, or log message failure as appropriate.- Overrides:
handleMessageInternalin classLoggingGlobalErrorChannelListener- Parameters:
message- The failed message
-
sendToRetryChannel
protected void sendToRetryChannel(NonBlockingFixedRetryInfo info, int attempt, org.springframework.messaging.Message<?> original) Send a failed message to a configured retry channel- Parameters:
info- The individual retry configurationattempt- The retry attempt numberoriginal- The original failed message
-
sendToDlq
protected void sendToDlq(NonBlockingFixedRetryInfo finalRetry, int attempt, org.springframework.messaging.support.ErrorMessage errorMessage, org.springframework.messaging.Message<?> original) Send a failed message to a DLQ- Parameters:
finalRetry- The final retry configuration in the list whose attempt count has been exhaustedattempt- The attempt numbererrorMessage- The failed messageoriginal- The original message
-
identifyLastRetryPhase
@Nullable protected NonBlockingFixedRetryInfo identifyLastRetryPhase(List<NonBlockingFixedRetryInfo> retries) Identify the last retry config in the list of retry configs- Parameters:
retries- The list of retry configs- Returns:
- The final retry config
-
identifyRetryPhase
@Nullable protected NonBlockingFixedRetryInfo identifyRetryPhase(List<NonBlockingFixedRetryInfo> retries, org.springframework.messaging.MessagingException messagingException, AtomicInteger counter) Based on the count, identify the current retry config that should be considered- Parameters:
retries- The list of retry configsmessagingException- The exceptioncounter- The count- Returns:
- The relevant config
-
buildExceptionClassifier
protected org.springframework.classify.BinaryExceptionClassifier buildExceptionClassifier(NonBlockingFixedRetryInfo retryInfo) Build theBinaryExceptionClassifierinstance responsible for inspecting exceptions and determining inclusion or exclusion, if applicable.- Parameters:
retryInfo- The retry config- Returns:
- The exception classifier
- See Also:
-
getRoot
Retrieve the relevant root exception for reporting as a header on the message- Parameters:
e- The exception- Returns:
- The relevant root exception
-