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:
  1. Keeps track of the number of retries and correlates retry attempts according to the list of retry configs associated with NonBlockingRetryProperties.getBindings()
  2. Will send a message to a retry channel if a retry config is available and not exhausted
  3. Will send a message to a DLQ if one is configured and retries are exhausted
  4. Will log failure using the last exception if no DLQ is configured
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     

    Nested 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, logger

    Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement

    METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME

    Fields inherited from interface org.springframework.core.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors
    Constructor
    Description
    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 Summary

    Modifier and Type
    Method
    Description
    void
    accept(org.springframework.messaging.support.ErrorMessage errorMessage)
     
    protected org.springframework.classify.BinaryExceptionClassifier
    Build the BinaryExceptionClassifier instance responsible for inspecting exceptions and determining inclusion or exclusion, if applicable.
    protected Exception
    Retrieve the relevant root exception for reporting as a header on the message
    protected void
    handleMessageInternal(org.springframework.messaging.Message<?> message)
    Handle message failure.
    Identify the last retry config in the list of retry configs
    identifyRetryPhase(List<NonBlockingFixedRetryInfo> retries, org.springframework.messaging.MessagingException messagingException, AtomicInteger counter)
    Based on the count, identify the current retry config that should be considered
    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
    protected void
    sendToRetryChannel(NonBlockingFixedRetryInfo info, int attempt, org.springframework.messaging.Message<?> original)
    Send a failed message to a configured retry channel

    Methods inherited from class com.broadleafcommerce.common.messaging.error.LoggingGlobalErrorChannelListener

    formatOriginalMessageHeaders, formatOriginalMessagePayload, logErrorMessage

    Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler

    handleMessage, onComplete, onError, onNext, onSubscribe, setObservationConvention

    Methods 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, shouldTrack

    Methods 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, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.util.function.Consumer

    andThen

    Methods inherited from interface reactor.core.CoreSubscriber

    currentContext

    Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement

    getThisAs

    Methods 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)
      Specified by:
      accept in interface Consumer<org.springframework.messaging.support.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:
      handleMessageInternal in class LoggingGlobalErrorChannelListener
      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 configuration
      attempt - The retry attempt number
      original - 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 exhausted
      attempt - The attempt number
      errorMessage - The failed message
      original - 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 configs
      messagingException - The exception
      counter - The count
      Returns:
      The relevant config
    • buildExceptionClassifier

      protected org.springframework.classify.BinaryExceptionClassifier buildExceptionClassifier(NonBlockingFixedRetryInfo retryInfo)
      Build the BinaryExceptionClassifier instance responsible for inspecting exceptions and determining inclusion or exclusion, if applicable.
      Parameters:
      retryInfo - The retry config
      Returns:
      The exception classifier
      See Also:
    • getRoot

      protected Exception getRoot(Exception e)
      Retrieve the relevant root exception for reporting as a header on the message
      Parameters:
      e - The exception
      Returns:
      The relevant root exception