Class AbstractAmqpChannel

All Implemented Interfaces:
ConnectionListener, Aware, BeanFactoryAware, BeanNameAware, DisposableBean, InitializingBean, ApplicationContextAware, ExpressionCapable, IntegrationPattern, NamedComponent, IntegrationManagement, TrackableComponent, MessageChannel, InterceptableChannel
Direct Known Subclasses:
PointToPointSubscribableAmqpChannel, PollableAmqpChannel, PublishSubscribeAmqpChannel

public abstract class AbstractAmqpChannel extends AbstractMessageChannel implements ConnectionListener
The base AbstractMessageChannel implementation for AMQP.
Since:
2.1
Author:
Mark Fisher, Artem Bilan, Gary Russell
  • Method Details

    • isLoggingEnabled

      public boolean isLoggingEnabled()
      Description copied from interface: IntegrationManagement
      Return whether logging is enabled.
      Specified by:
      isLoggingEnabled in interface IntegrationManagement
      Overrides:
      isLoggingEnabled in class AbstractMessageChannel
      Returns:
      true if enabled.
    • setLoggingEnabled

      public void setLoggingEnabled(boolean loggingEnabled)
      Description copied from interface: IntegrationManagement
      Enable logging or not.
      Specified by:
      setLoggingEnabled in interface IntegrationManagement
      Overrides:
      setLoggingEnabled in class AbstractMessageChannel
      Parameters:
      loggingEnabled - false to disable.
    • setDefaultDeliveryMode

      public void setDefaultDeliveryMode(MessageDeliveryMode defaultDeliveryMode)
      Set the delivery mode to use if the message has no "amqp_deliveryMode" header and the message property was not set by the MessagePropertiesConverter.
      Parameters:
      defaultDeliveryMode - the default delivery mode.
      Since:
      4.3
    • setExtractPayload

      public void setExtractPayload(boolean extractPayload)
      Set to true to extract the payload and map the headers; otherwise the entire message is converted and sent. Default false.
      Parameters:
      extractPayload - true to extract and map.
      Since:
      4.3
    • isExtractPayload

      protected boolean isExtractPayload()
      Returns:
      the extract payload.
      Since:
      4.3
      See Also:
    • 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. Only applies when extractPayload is true. Default: false.
      Parameters:
      headersMappedLast - true if headers are mapped after conversion.
      Since:
      5.0
    • getExchangeName

      protected String getExchangeName()
      Subclasses may override this method to return an Exchange name. By default, Messages will be sent to the no-name Direct Exchange.
      Returns:
      The exchange name.
    • getRoutingKey

      protected String getRoutingKey()
      Subclasses may override this method to return a routing key. By default, there will be no routing key (empty string).
      Returns:
      The routing key.
    • getInboundHeaderMapper

      protected AmqpHeaderMapper getInboundHeaderMapper()
    • getAmqpTemplate

      protected AmqpTemplate getAmqpTemplate()
    • getRabbitTemplate

      protected RabbitTemplate getRabbitTemplate()
    • setAdmin

      protected final void setAdmin(AmqpAdmin admin)
    • setConnectionFactory

      protected final void setConnectionFactory(ConnectionFactory connectionFactory)
    • getAdmin

      protected AmqpAdmin getAdmin()
    • getConnectionFactory

      protected ConnectionFactory getConnectionFactory()
    • onInit

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

      public void destroy()
      Specified by:
      destroy in interface DisposableBean
      Specified by:
      destroy in interface IntegrationManagement
      Overrides:
      destroy in class AbstractMessageChannel
    • doSend

      protected boolean doSend(Message<?> message, long timeout)
      Description copied from class: AbstractMessageChannel
      Subclasses must implement this method. A non-negative timeout indicates how long to wait if the channel is at capacity (if the value is 0, it must return immediately with or without success). A negative timeout value indicates that the method should block until either the message is accepted or the blocking thread is interrupted.
      Specified by:
      doSend in class AbstractMessageChannel
      Parameters:
      message - The message.
      timeout - The timeout.
      Returns:
      true if the send was successful.
    • onCreate

      public void onCreate(Connection connection)
      Specified by:
      onCreate in interface ConnectionListener
    • onClose

      public void onClose(Connection connection)
      Specified by:
      onClose in interface ConnectionListener
    • doDeclares

      protected abstract void doDeclares()