Class AbstractAmqpOutboundEndpoint

All Implemented Interfaces:
org.reactivestreams.Subscriber<Message<?>>, Aware, BeanClassLoaderAware, BeanFactoryAware, BeanNameAware, DisposableBean, InitializingBean, ApplicationContextAware, Lifecycle, Ordered, ExpressionCapable, Orderable, MessageProducer, HeaderPropagationAware, IntegrationPattern, NamedComponent, IntegrationManagement, ManageableLifecycle, TrackableComponent, MessageHandler, reactor.core.CoreSubscriber<Message<?>>
Direct Known Subclasses:
AmqpOutboundEndpoint, AsyncAmqpOutboundGateway

public abstract class AbstractAmqpOutboundEndpoint extends AbstractReplyProducingMessageHandler implements ManageableLifecycle
A base AbstractReplyProducingMessageHandler extension for AMQP message handlers.
Since:
4.3
Author:
Gary Russell, Artem Bilan
  • Constructor Details

    • AbstractAmqpOutboundEndpoint

      public AbstractAmqpOutboundEndpoint()
  • 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(String exchangeName)
      Configure an AMQP exchange name for sending messages.
      Parameters:
      exchangeName - the exchange name for sending messages.
    • setExchangeNameExpression

      public void setExchangeNameExpression(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(String exchangeNameExpression)
      Parameters:
      exchangeNameExpression - the String in SpEL syntax.
      Since:
      4.3
    • setRoutingKey

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

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

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

      public void setConfirmCorrelationExpression(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(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(MessageChannel ackChannel)
      Set the channel to which acks are send (publisher confirms).
      Parameters:
      ackChannel - the channel.
    • setConfirmAckChannelName

      public void setConfirmAckChannelName(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(MessageChannel nackChannel)
      Set the channel to which nacks are send (publisher confirms).
      Parameters:
      nackChannel - the channel.
    • setConfirmNackChannelName

      public void setConfirmNackChannelName(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(MessageChannel returnChannel)
      Set the channel to which returned messages are sent.
      Parameters:
      returnChannel - the channel.
    • setDefaultDeliveryMode

      public void setDefaultDeliveryMode(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(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 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(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:
    • setConnectionFactory

      protected final void setConnectionFactory(ConnectionFactory connectionFactory)
    • getExchangeName

      protected String getExchangeName()
    • getRoutingKey

      protected String getRoutingKey()
    • getExchangeNameExpression

      protected Expression getExchangeNameExpression()
    • getRoutingKeyExpression

      protected Expression getRoutingKeyExpression()
    • getRoutingKeyGenerator

      protected ExpressionEvaluatingMessageProcessor<String> getRoutingKeyGenerator()
    • getExchangeNameGenerator

      protected ExpressionEvaluatingMessageProcessor<String> getExchangeNameGenerator()
    • getHeaderMapper

      public AmqpHeaderMapper getHeaderMapper()
    • getConfirmCorrelationExpression

      protected Expression getConfirmCorrelationExpression()
    • getCorrelationDataGenerator

      protected ExpressionEvaluatingMessageProcessor<Object> getCorrelationDataGenerator()
    • getConfirmAckChannel

      protected MessageChannel getConfirmAckChannel()
    • getConfirmNackChannel

      protected MessageChannel getConfirmNackChannel()
    • getReturnChannel

      protected MessageChannel getReturnChannel()
    • getDefaultDeliveryMode

      protected MessageDeliveryMode getDefaultDeliveryMode()
    • isLazyConnect

      protected boolean isLazyConnect()
    • isHeadersMappedLast

      protected boolean isHeadersMappedLast()
    • getConfirmTimeout

      @Nullable protected Duration getConfirmTimeout()
    • doInit

      protected final void doInit()
      Overrides:
      doInit in class 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 Lifecycle
      Specified by:
      start in interface ManageableLifecycle
    • getRabbitTemplate

      @Nullable protected abstract RabbitTemplate getRabbitTemplate()
    • stop

      public void stop()
      Specified by:
      stop in interface Lifecycle
      Specified by:
      stop in interface ManageableLifecycle
    • doStart

      protected void doStart()
    • doStop

      protected void doStop()
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface Lifecycle
      Specified by:
      isRunning in interface ManageableLifecycle
    • generateCorrelationData

      protected CorrelationData generateCorrelationData(Message<?> requestMessage)
    • generateExchangeName

      protected String generateExchangeName(Message<?> requestMessage)
    • generateRoutingKey

      protected String generateRoutingKey(Message<?> requestMessage)
    • addDelayProperty

      protected void addDelayProperty(Message<?> message, Message amqpMessage)
    • buildReply

      protected AbstractIntegrationMessageBuilder<?> buildReply(MessageConverter converter, Message amqpReplyMessage)
    • buildReturnedMessage

      protected Message<?> buildReturnedMessage(ReturnedMessage returnedMessage, MessageConverter converter)
    • handleConfirm

      protected void handleConfirm(CorrelationData correlationData, boolean ack, String cause)