Class MessageProducerSupport

All Implemented Interfaces:
Aware, BeanFactoryAware, BeanNameAware, DisposableBean, InitializingBean, SmartInitializingSingleton, ApplicationContextAware, Lifecycle, Phased, SmartLifecycle, ComponentSourceAware, ExpressionCapable, MessageProducer, IntegrationPattern, NamedComponent, IntegrationInboundManagement, IntegrationManagement, ManageableLifecycle, ManageableSmartLifecycle, TrackableComponent
Direct Known Subclasses:
AbstractHazelcastMessageProducer, AbstractInternetProtocolReceivingChannelAdapter, AbstractMqttMessageDrivenChannelAdapter, AbstractXmppConnectionAwareEndpoint, AmqpInboundChannelAdapter, DebeziumMessageProducer, ExpressionMessageProducerSupport, FileTailingMessageProducerSupport, HazelcastClusterMonitorMessageProducer, ImapIdleChannelAdapter, JmsMessageDrivenEndpoint, KafkaMessageDrivenChannelAdapter, MongoDbChangeStreamMessageProducer, NotificationListeningMessageProducer, ReactiveMessageSourceProducer, ReactiveRedisStreamMessageProducer, RedisInboundChannelAdapter, RedisQueueMessageDrivenEndpoint, StompInboundChannelAdapter, SyslogReceivingChannelAdapterSupport, TcpReceivingChannelAdapter, WebSocketInboundChannelAdapter, ZeroMqMessageProducer

A support class for producer endpoints that provides a setter for the output channel and a convenience method for sending Messages.
Author:
Mark Fisher, Artem Bilan, Gary Russell
  • Constructor Details

    • MessageProducerSupport

      protected MessageProducerSupport()
  • Method Details

    • setOutputChannel

      public void setOutputChannel(MessageChannel outputChannel)
      Description copied from interface: MessageProducer
      Specify the MessageChannel to which produced Messages should be sent.
      Specified by:
      setOutputChannel in interface MessageProducer
      Parameters:
      outputChannel - The output channel.
    • setOutputChannelName

      public void setOutputChannelName(String outputChannelName)
      Set the output channel name; overrides outputChannel if provided.
      Specified by:
      setOutputChannelName in interface MessageProducer
      Parameters:
      outputChannelName - the channel name.
      Since:
      4.3
    • getOutputChannel

      public @Nullable MessageChannel getOutputChannel()
      Description copied from interface: MessageProducer
      Return the output channel.
      Specified by:
      getOutputChannel in interface MessageProducer
      Returns:
      the channel.
    • getComponentType

      public String getComponentType()
      Specified by:
      getComponentType in interface NamedComponent
    • setErrorChannel

      public void setErrorChannel(MessageChannel errorChannel)
    • setErrorChannelName

      public void setErrorChannelName(String errorChannelName)
      Set the error channel name. If no error channel is provided, this endpoint will propagate Exceptions to the message-driven source. To completely suppress Exceptions, provide a reference to the "nullChannel" here.
      Parameters:
      errorChannelName - The error channel bean name.
      Since:
      4.3
    • getErrorChannel

      public @Nullable MessageChannel getErrorChannel()
      Return the error channel (if provided) to which error messages will be routed.
      Returns:
      the channel or null.
      Since:
      4.3
    • setSendTimeout

      public void setSendTimeout(long sendTimeout)
      Configure the default timeout value to use for send operations. May be overridden for individual messages.
      Parameters:
      sendTimeout - the 'send' operation timeout in milliseconds
      See Also:
    • setShouldTrack

      public void setShouldTrack(boolean shouldTrack)
      Specified by:
      setShouldTrack in interface TrackableComponent
    • setErrorMessageStrategy

      public void setErrorMessageStrategy(ErrorMessageStrategy errorMessageStrategy)
      Set an ErrorMessageStrategy to use to build an error message when a exception occurs. Default is the DefaultErrorMessageStrategy.
      Parameters:
      errorMessageStrategy - the ErrorMessageStrategy.
      Since:
      4.3.10
    • getErrorMessageStrategy

      protected ErrorMessageStrategy getErrorMessageStrategy()
      Get an ErrorMessageStrategy to use to build an error message when a exception occurs. Default is the DefaultErrorMessageStrategy.
      Returns:
      the errorMessageStrategy
      Since:
      6.0
    • getMessagingTemplate

      protected MessagingTemplate getMessagingTemplate()
    • setObservationConvention

      public void setObservationConvention(@Nullable MessageReceiverObservationConvention observationConvention)
      Set a custom MessageReceiverObservationConvention for IntegrationObservation.HANDLER. Ignored if an ObservationRegistry is not configured for this component.
      Parameters:
      observationConvention - the MessageReceiverObservationConvention to use.
      Since:
      6.0
    • registerObservationRegistry

      public void registerObservationRegistry(io.micrometer.observation.ObservationRegistry observationRegistry)
      Description copied from interface: IntegrationManagement
      Inject an ObservationRegistry. If provided, the MetricsCaptor is ignored. The meters capturing has to be configured as an ObservationHandler on the provided ObservationRegistry.
      Specified by:
      registerObservationRegistry in interface IntegrationManagement
      Parameters:
      observationRegistry - the ObservationRegistry to expose observations from the component.
      See Also:
    • isObserved

      public boolean isObserved()
      Description copied from interface: IntegrationManagement
      True if this implementation is going to deal with a registry other than the ObservationRegistry.NOOP instance.
      Specified by:
      isObserved in interface IntegrationManagement
      Returns:
      true if this implementation is going to deal with a registry other than the ObservationRegistry.NOOP instance.
    • getIntegrationPatternType

      public IntegrationPatternType getIntegrationPatternType()
      Description copied from interface: IntegrationPattern
      Return a pattern type this component implements.
      Specified by:
      getIntegrationPatternType in interface IntegrationPattern
      Returns:
      the IntegrationPatternType this component implements.
    • afterSingletonsInstantiated

      public void afterSingletonsInstantiated()
      Specified by:
      afterSingletonsInstantiated in interface SmartInitializingSingleton
    • onInit

      protected void onInit()
      Description copied from class: IntegrationObjectSupport
      Subclasses may implement this for initialization logic.
      Overrides:
      onInit in class AbstractEndpoint
    • doStart

      protected void doStart()
      Take no action by default. Subclasses may override this if they need lifecycle-managed behavior. Protected by 'lifecycleLock'.
      Specified by:
      doStart in class AbstractEndpoint
    • doStop

      protected void doStop()
      Take no action by default. Subclasses may override this if they need lifecycle-managed behavior.
      Specified by:
      doStop in class AbstractEndpoint
    • sendMessage

      protected void sendMessage(@Nullable Message<?> message)
    • subscribeToPublisher

      protected void subscribeToPublisher(org.reactivestreams.Publisher<? extends Message<?>> publisher)
    • sendErrorMessageIfNecessary

      protected final boolean sendErrorMessageIfNecessary(@Nullable Message<?> message, Exception exception)
      Send an error message based on the exception and message.
      Parameters:
      message - the message.
      exception - the exception.
      Returns:
      true if the error channel is available and message sent.
      Since:
      4.3.10
    • buildErrorMessage

      protected final ErrorMessage buildErrorMessage(@Nullable Message<?> message, Exception exception)
      Build an error message for the exception and message using the configured ErrorMessageStrategy.
      Parameters:
      message - the message.
      exception - the exception.
      Returns:
      the error message.
      Since:
      4.3.10
    • getErrorMessageAttributes

      protected AttributeAccessor getErrorMessageAttributes(@Nullable Message<?> message)
      Populate an AttributeAccessor to be used when building an error message with the errorMessageStrategy.
      Parameters:
      message - the message.
      Returns:
      the attributes.
      Since:
      4.3.10
    • getRequiredOutputChannel

      protected MessageChannel getRequiredOutputChannel()