Class AbstractAmqpOutboundEndpoint

java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.MessageHandlerSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.handler.AbstractMessageProducingHandler
org.springframework.integration.handler.AbstractReplyProducingMessageHandler
org.springframework.integration.amqp.outbound.AbstractAmqpOutboundEndpoint
All Implemented Interfaces:
org.reactivestreams.Subscriber<org.springframework.messaging.Message<?>>, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, 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.context.Lifecycle, org.springframework.core.Ordered, org.springframework.integration.context.ExpressionCapable, org.springframework.integration.context.Orderable, org.springframework.integration.core.MessageProducer, org.springframework.integration.handler.HeaderPropagationAware, org.springframework.integration.IntegrationPattern, org.springframework.integration.support.context.NamedComponent, org.springframework.integration.support.management.IntegrationManagement, org.springframework.integration.support.management.ManageableLifecycle, org.springframework.integration.support.management.TrackableComponent, org.springframework.messaging.MessageHandler, reactor.core.CoreSubscriber<org.springframework.messaging.Message<?>>
Direct Known Subclasses:
AmqpOutboundEndpoint, AsyncAmqpOutboundGateway

public abstract class AbstractAmqpOutboundEndpoint
extends org.springframework.integration.handler.AbstractReplyProducingMessageHandler
implements org.springframework.integration.support.management.ManageableLifecycle
A base AbstractReplyProducingMessageHandler extension for AMQP message handlers.
Since:
4.3
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    protected static class  AbstractAmqpOutboundEndpoint.CorrelationDataWrapper  

    Nested classes/interfaces inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler

    org.springframework.integration.handler.AbstractReplyProducingMessageHandler.RequestHandler

    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.handler.AbstractMessageProducingHandler

    messagingTemplate

    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
    AbstractAmqpOutboundEndpoint()  
  • Method Summary

    Modifier and Type Method Description
    protected void addDelayProperty​(org.springframework.messaging.Message<?> message, org.springframework.amqp.core.Message amqpMessage)  
    protected org.springframework.integration.support.AbstractIntegrationMessageBuilder<?> buildReply​(org.springframework.amqp.support.converter.MessageConverter converter, org.springframework.amqp.core.Message amqpReplyMessage)  
    protected org.springframework.messaging.Message<?> buildReturnedMessage​(org.springframework.amqp.core.Message message, int replyCode, java.lang.String replyText, java.lang.String exchange, java.lang.String returnedRoutingKey, org.springframework.amqp.support.converter.MessageConverter converter)
    protected org.springframework.messaging.Message<?> buildReturnedMessage​(org.springframework.amqp.core.ReturnedMessage returnedMessage, org.springframework.amqp.support.converter.MessageConverter converter)  
    protected void doInit()  
    protected void doStart()  
    protected void doStop()  
    protected void endpointInit()
    Subclasses can override to perform any additional initialization.
    protected org.springframework.amqp.rabbit.connection.CorrelationData generateCorrelationData​(org.springframework.messaging.Message<?> requestMessage)  
    protected java.lang.String generateExchangeName​(org.springframework.messaging.Message<?> requestMessage)  
    protected java.lang.String generateRoutingKey​(org.springframework.messaging.Message<?> requestMessage)  
    protected org.springframework.messaging.MessageChannel getConfirmAckChannel()  
    protected org.springframework.expression.Expression getConfirmCorrelationExpression()  
    protected org.springframework.messaging.MessageChannel getConfirmNackChannel()  
    protected java.time.Duration getConfirmTimeout()  
    protected org.springframework.integration.handler.ExpressionEvaluatingMessageProcessor<java.lang.Object> getCorrelationDataGenerator()  
    protected org.springframework.amqp.core.MessageDeliveryMode getDefaultDeliveryMode()  
    protected java.lang.String getExchangeName()  
    protected org.springframework.expression.Expression getExchangeNameExpression()  
    protected org.springframework.integration.handler.ExpressionEvaluatingMessageProcessor<java.lang.String> getExchangeNameGenerator()  
    AmqpHeaderMapper getHeaderMapper()  
    protected abstract org.springframework.amqp.rabbit.core.RabbitTemplate getRabbitTemplate()  
    protected org.springframework.messaging.MessageChannel getReturnChannel()  
    protected java.lang.String getRoutingKey()  
    protected org.springframework.expression.Expression getRoutingKeyExpression()  
    protected org.springframework.integration.handler.ExpressionEvaluatingMessageProcessor<java.lang.String> getRoutingKeyGenerator()  
    protected void handleConfirm​(org.springframework.amqp.rabbit.connection.CorrelationData correlationData, boolean ack, java.lang.String cause)  
    protected boolean isHeadersMappedLast()  
    protected boolean isLazyConnect()  
    boolean isRunning()  
    void setConfirmAckChannel​(org.springframework.messaging.MessageChannel ackChannel)
    Set the channel to which acks are send (publisher confirms).
    void setConfirmAckChannelName​(java.lang.String ackChannelName)
    Set the channel name to which acks are send (publisher confirms).
    void setConfirmCorrelationExpression​(org.springframework.expression.Expression confirmCorrelationExpression)
    Set a SpEL expression to evaluate confirm correlation at runtime.
    void setConfirmCorrelationExpressionString​(java.lang.String confirmCorrelationExpression)
    Set a SpEL expression to evaluate confirm correlation at runtime.
    void setConfirmNackChannel​(org.springframework.messaging.MessageChannel nackChannel)
    Set the channel to which nacks are send (publisher confirms).
    void setConfirmNackChannelName​(java.lang.String nackChannelName)
    Set the channel name to which nacks are send (publisher confirms).
    void setConfirmTimeout​(long confirmTimeout)
    Set a timeout after which a nack will be synthesized if no publisher confirm has been received within that time.
    protected void setConnectionFactory​(org.springframework.amqp.rabbit.connection.ConnectionFactory connectionFactory)  
    void setDefaultDeliveryMode​(org.springframework.amqp.core.MessageDeliveryMode defaultDeliveryMode)
    Set the default delivery mode.
    void setDelay​(int delay)
    Set the value to set in the x-delay header when using the RabbitMQ delayed message exchange plugin.
    void setDelayExpression​(org.springframework.expression.Expression delayExpression)
    Set the SpEL expression to calculate the x-delay header when using the RabbitMQ delayed message exchange plugin.
    void setDelayExpressionString​(java.lang.String delayExpression)
    Set the SpEL expression to calculate the x-delay header when using the RabbitMQ delayed message exchange plugin.
    void setErrorMessageStrategy​(org.springframework.integration.support.ErrorMessageStrategy errorMessageStrategy)
    Set the error message strategy to use for returned (or negatively confirmed) messages.
    void setExchangeName​(java.lang.String exchangeName)
    Configure an AMQP exchange name for sending messages.
    void setExchangeNameExpression​(org.springframework.expression.Expression exchangeNameExpression)
    Configure a SpEL expression to evaluate an exchange name at runtime.
    void setExchangeNameExpressionString​(java.lang.String exchangeNameExpression)  
    void setHeaderMapper​(AmqpHeaderMapper headerMapper)
    Set a custom AmqpHeaderMapper for mapping request and reply headers.
    void setHeadersMappedLast​(boolean headersMappedLast)
    When mapping headers for the outbound message, determine whether the headers are mapped before the message is converted, or afterwards.
    void setLazyConnect​(boolean lazyConnect)
    Set to false to attempt to connect during endpoint start; default true, meaning the connection will be attempted to be established on the arrival of the first message.
    void setReturnChannel​(org.springframework.messaging.MessageChannel returnChannel)
    Set the channel to which returned messages are sent.
    void setRoutingKey​(java.lang.String routingKey)
    Configure an AMQP routing key for sending messages.
    void setRoutingKeyExpression​(org.springframework.expression.Expression routingKeyExpression)  
    void setRoutingKeyExpressionString​(java.lang.String routingKeyExpression)  
    void start()  
    void stop()  

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

    doInvokeAdvisedRequestHandler, getBeanClassLoader, getIntegrationPatternType, getRequiresReply, handleMessageInternal, handleRequestMessage, hasAdviceChain, onInit, setAdviceChain, setBeanClassLoader, setRequiresReply

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

    addNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, shouldCopyRequestHeaders, shouldSplitOutput, updateNotPropagatedHeaders

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

    handleMessage, onComplete, onError, onNext, onSubscribe

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

    buildSendTimer, destroy, getComponentType, getManagedName, getManagedType, getMetricsCaptor, getOrder, getOverrides, isLoggingEnabled, registerMetricsCaptor, 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, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, 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 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

  • Method Details

    • setHeaderMapper

      public void setHeaderMapper​(AmqpHeaderMapper headerMapper)
      Set a custom AmqpHeaderMapper for mapping request and reply headers. Defaults to DefaultAmqpHeaderMapper.outboundMapper().
      Parameters:
      headerMapper - the AmqpHeaderMapper to use.
    • setHeadersMappedLast

      public void setHeadersMappedLast​(boolean headersMappedLast)
      When mapping headers for the outbound message, determine whether the headers are mapped before the message is converted, or afterwards. This only affects headers that might be added by the message converter. When false, the converter's headers win; when true, any headers added by the converter will be overridden (if the source message has a header that maps to those headers). You might wish to set this to true, for example, when using a SimpleMessageConverter with a String payload that contains json; the converter will set the content type to text/plain which can be overridden to application/json by setting the AmqpHeaders.CONTENT_TYPE message header. Default: false.
      Parameters:
      headersMappedLast - true if headers are mapped after conversion.
      Since:
      5.0
    • setExchangeName

      public void setExchangeName​(java.lang.String exchangeName)
      Configure an AMQP exchange name for sending messages.
      Parameters:
      exchangeName - the exchange name for sending messages.
    • setExchangeNameExpression

      public void setExchangeNameExpression​(org.springframework.expression.Expression exchangeNameExpression)
      Configure a SpEL expression to evaluate an exchange name at runtime.
      Parameters:
      exchangeNameExpression - the expression to use.
      Since:
      4.3
    • setExchangeNameExpressionString

      public void setExchangeNameExpressionString​(java.lang.String exchangeNameExpression)
      Parameters:
      exchangeNameExpression - the String in SpEL syntax.
      Since:
      4.3
    • setRoutingKey

      public void setRoutingKey​(java.lang.String routingKey)
      Configure an AMQP routing key for sending messages.
      Parameters:
      routingKey - the routing key to use
    • setRoutingKeyExpression

      public void setRoutingKeyExpression​(org.springframework.expression.Expression routingKeyExpression)
      Parameters:
      routingKeyExpression - the expression to use.
      Since:
      4.3
    • setRoutingKeyExpressionString

      public void setRoutingKeyExpressionString​(java.lang.String routingKeyExpression)
      Parameters:
      routingKeyExpression - the String in SpEL syntax.
      Since:
      4.3
    • setConfirmCorrelationExpression

      public void setConfirmCorrelationExpression​(org.springframework.expression.Expression confirmCorrelationExpression)
      Set a SpEL expression to evaluate confirm correlation at runtime.
      Parameters:
      confirmCorrelationExpression - the expression to use.
      Since:
      4.3
    • setConfirmCorrelationExpressionString

      public void setConfirmCorrelationExpressionString​(java.lang.String confirmCorrelationExpression)
      Set a SpEL expression to evaluate confirm correlation at runtime.
      Parameters:
      confirmCorrelationExpression - the String in SpEL syntax.
      Since:
      4.3
    • setConfirmAckChannel

      public void setConfirmAckChannel​(org.springframework.messaging.MessageChannel ackChannel)
      Set the channel to which acks are send (publisher confirms).
      Parameters:
      ackChannel - the channel.
    • setConfirmAckChannelName

      public void setConfirmAckChannelName​(java.lang.String ackChannelName)
      Set the channel name to which acks are send (publisher confirms).
      Parameters:
      ackChannelName - the channel name.
      Since:
      4.3.12
    • setConfirmNackChannel

      public void setConfirmNackChannel​(org.springframework.messaging.MessageChannel nackChannel)
      Set the channel to which nacks are send (publisher confirms).
      Parameters:
      nackChannel - the channel.
    • setConfirmNackChannelName

      public void setConfirmNackChannelName​(java.lang.String nackChannelName)
      Set the channel name to which nacks are send (publisher confirms).
      Parameters:
      nackChannelName - the channel name.
      Since:
      4.3.12
    • setReturnChannel

      public void setReturnChannel​(org.springframework.messaging.MessageChannel returnChannel)
      Set the channel to which returned messages are sent.
      Parameters:
      returnChannel - the channel.
    • setDefaultDeliveryMode

      public void setDefaultDeliveryMode​(org.springframework.amqp.core.MessageDeliveryMode defaultDeliveryMode)
      Set the default delivery mode.
      Parameters:
      defaultDeliveryMode - the delivery mode.
    • setLazyConnect

      public void setLazyConnect​(boolean lazyConnect)
      Set to false to attempt to connect during endpoint start; default true, meaning the connection will be attempted to be established on the arrival of the first message.
      Parameters:
      lazyConnect - the lazyConnect to set
      Since:
      4.1
    • setDelay

      public void setDelay​(int delay)
      Set the value to set in the x-delay header when using the RabbitMQ delayed message exchange plugin. By default, the AmqpHeaders.DELAY header (if present) is mapped; setting the delay here overrides that value.
      Parameters:
      delay - the delay.
      Since:
      4.3.5
    • setDelayExpression

      public void setDelayExpression​(org.springframework.expression.Expression delayExpression)
      Set the SpEL expression to calculate the x-delay header when using the RabbitMQ delayed message exchange plugin. By default, the AmqpHeaders.DELAY header (if present) is mapped; setting the expression here overrides that value.
      Parameters:
      delayExpression - the expression.
      Since:
      4.3.5
    • setDelayExpressionString

      public void setDelayExpressionString​(@Nullable java.lang.String delayExpression)
      Set the SpEL expression to calculate the x-delay header when using the RabbitMQ delayed message exchange plugin. By default, the AmqpHeaders.DELAY header (if present) is mapped; setting the expression here overrides that value.
      Parameters:
      delayExpression - the expression.
      Since:
      4.3.5
    • setErrorMessageStrategy

      public void setErrorMessageStrategy​(org.springframework.integration.support.ErrorMessageStrategy errorMessageStrategy)
      Set the error message strategy to use for returned (or negatively confirmed) messages.
      Parameters:
      errorMessageStrategy - the strategy.
      Since:
      4.3.12
    • setConfirmTimeout

      public void setConfirmTimeout​(long confirmTimeout)
      Set a timeout after which a nack will be synthesized if no publisher confirm has been received within that time. Missing confirms will be checked every 50% of this value so the synthesized nack will be sent between 1x and 1.5x this timeout.
      Parameters:
      confirmTimeout - the approximate timeout.
      Since:
      5.2
      See Also:
      setConfirmNackChannel(MessageChannel)
    • setConnectionFactory

      protected final void setConnectionFactory​(org.springframework.amqp.rabbit.connection.ConnectionFactory connectionFactory)
    • getExchangeName

      protected java.lang.String getExchangeName()
    • getRoutingKey

      protected java.lang.String getRoutingKey()
    • getExchangeNameExpression

      protected org.springframework.expression.Expression getExchangeNameExpression()
    • getRoutingKeyExpression

      protected org.springframework.expression.Expression getRoutingKeyExpression()
    • getRoutingKeyGenerator

      protected org.springframework.integration.handler.ExpressionEvaluatingMessageProcessor<java.lang.String> getRoutingKeyGenerator()
    • getExchangeNameGenerator

      protected org.springframework.integration.handler.ExpressionEvaluatingMessageProcessor<java.lang.String> getExchangeNameGenerator()
    • getHeaderMapper

      public AmqpHeaderMapper getHeaderMapper()
    • getConfirmCorrelationExpression

      protected org.springframework.expression.Expression getConfirmCorrelationExpression()
    • getCorrelationDataGenerator

      protected org.springframework.integration.handler.ExpressionEvaluatingMessageProcessor<java.lang.Object> getCorrelationDataGenerator()
    • getConfirmAckChannel

      protected org.springframework.messaging.MessageChannel getConfirmAckChannel()
    • getConfirmNackChannel

      protected org.springframework.messaging.MessageChannel getConfirmNackChannel()
    • getReturnChannel

      protected org.springframework.messaging.MessageChannel getReturnChannel()
    • getDefaultDeliveryMode

      protected org.springframework.amqp.core.MessageDeliveryMode getDefaultDeliveryMode()
    • isLazyConnect

      protected boolean isLazyConnect()
    • isHeadersMappedLast

      protected boolean isHeadersMappedLast()
    • getConfirmTimeout

      @Nullable protected java.time.Duration getConfirmTimeout()
    • doInit

      protected final void doInit()
      Overrides:
      doInit in class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
    • endpointInit

      protected void endpointInit()
      Subclasses can override to perform any additional initialization. Called from afterPropertiesSet().
    • start

      public void start()
      Specified by:
      start in interface org.springframework.context.Lifecycle
      Specified by:
      start in interface org.springframework.integration.support.management.ManageableLifecycle
    • getRabbitTemplate

      @Nullable protected abstract org.springframework.amqp.rabbit.core.RabbitTemplate getRabbitTemplate()
    • stop

      public void stop()
      Specified by:
      stop in interface org.springframework.context.Lifecycle
      Specified by:
      stop in interface org.springframework.integration.support.management.ManageableLifecycle
    • doStart

      protected void doStart()
    • doStop

      protected void doStop()
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface org.springframework.context.Lifecycle
      Specified by:
      isRunning in interface org.springframework.integration.support.management.ManageableLifecycle
    • generateCorrelationData

      protected org.springframework.amqp.rabbit.connection.CorrelationData generateCorrelationData​(org.springframework.messaging.Message<?> requestMessage)
    • generateExchangeName

      protected java.lang.String generateExchangeName​(org.springframework.messaging.Message<?> requestMessage)
    • generateRoutingKey

      protected java.lang.String generateRoutingKey​(org.springframework.messaging.Message<?> requestMessage)
    • addDelayProperty

      protected void addDelayProperty​(org.springframework.messaging.Message<?> message, org.springframework.amqp.core.Message amqpMessage)
    • buildReply

      protected org.springframework.integration.support.AbstractIntegrationMessageBuilder<?> buildReply​(org.springframework.amqp.support.converter.MessageConverter converter, org.springframework.amqp.core.Message amqpReplyMessage)
    • buildReturnedMessage

      @Deprecated protected org.springframework.messaging.Message<?> buildReturnedMessage​(org.springframework.amqp.core.Message message, int replyCode, java.lang.String replyText, java.lang.String exchange, java.lang.String returnedRoutingKey, org.springframework.amqp.support.converter.MessageConverter converter)
      Build Spring message object based on the provided returned AMQP message info.
      Parameters:
      message - the returned AMQP message
      replyCode - the returned message reason code
      replyText - the returned message reason text
      exchange - the exchange the message returned from
      returnedRoutingKey - the routing key for returned message
      converter - the converter to deserialize body of the returned AMQP message
      Returns:
      the Spring message which represents a returned AMQP message
    • buildReturnedMessage

      protected org.springframework.messaging.Message<?> buildReturnedMessage​(org.springframework.amqp.core.ReturnedMessage returnedMessage, org.springframework.amqp.support.converter.MessageConverter converter)
    • handleConfirm

      protected void handleConfirm​(org.springframework.amqp.rabbit.connection.CorrelationData correlationData, boolean ack, java.lang.String cause)