Class AmqpInboundGateway

java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.gateway.MessagingGatewaySupport
org.springframework.integration.amqp.inbound.AmqpInboundGateway
All Implemented Interfaces:
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.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle, org.springframework.integration.context.ExpressionCapable, org.springframework.integration.IntegrationPattern, org.springframework.integration.support.context.NamedComponent, org.springframework.integration.support.management.IntegrationInboundManagement, org.springframework.integration.support.management.IntegrationManagement, org.springframework.integration.support.management.ManageableLifecycle, org.springframework.integration.support.management.ManageableSmartLifecycle, org.springframework.integration.support.management.TrackableComponent

public class AmqpInboundGateway
extends org.springframework.integration.gateway.MessagingGatewaySupport
Adapter that receives Messages from an AMQP Queue, converts them into Spring Integration Messages, and sends the results to a Message Channel. If a reply Message is received, it will be converted and sent back to the AMQP 'replyTo'.
Since:
2.1
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    protected class  AmqpInboundGateway.Listener  

    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.gateway.MessagingGatewaySupport

    messagingTemplate

    Fields inherited from class org.springframework.integration.endpoint.AbstractEndpoint

    lifecycleCondition, lifecycleLock

    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.context.SmartLifecycle

    DEFAULT_PHASE
  • Constructor Summary

    Constructors 
    Constructor Description
    AmqpInboundGateway​(org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer listenerContainer)  
    AmqpInboundGateway​(org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer listenerContainer, org.springframework.amqp.core.AmqpTemplate amqpTemplate)
    Construct AmqpInboundGateway based on the provided AbstractMessageListenerContainer to receive request messages and AmqpTemplate to send replies.
    AmqpInboundGateway​(org.springframework.amqp.rabbit.listener.MessageListenerContainer listenerContainer, org.springframework.amqp.core.AmqpTemplate amqpTemplate)
    Construct AmqpInboundGateway based on the provided MessageListenerContainer to receive request messages and AmqpTemplate to send replies.
  • Method Summary

    Modifier and Type Method Description
    protected void doStart()  
    protected void doStop()  
    java.lang.String getComponentType()  
    protected org.springframework.core.AttributeAccessor getErrorMessageAttributes​(org.springframework.messaging.Message<?> message)  
    protected void onInit()  
    void setBatchingStrategy​(org.springframework.amqp.rabbit.batch.BatchingStrategy batchingStrategy)
    Set a batching strategy to use when de-batching messages.
    void setBindSourceMessage​(boolean bindSourceMessage)
    Set to true to bind the source message in the header named IntegrationMessageHeaderAccessor.SOURCE_DATA.
    void setDefaultReplyTo​(java.lang.String defaultReplyTo)
    The defaultReplyTo address with the form
    void setHeaderMapper​(AmqpHeaderMapper headerMapper)  
    void setMessageConverter​(org.springframework.amqp.support.converter.MessageConverter messageConverter)
    Specify the MessageConverter to convert request and reply to/from Message.
    void setMessageRecoverer​(org.springframework.amqp.rabbit.retry.MessageRecoverer messageRecoverer)
    Configure a MessageRecoverer for retry operations.
    void setRecoveryCallback​(org.springframework.retry.RecoveryCallback<? extends java.lang.Object> recoveryCallback)
    Set a RecoveryCallback when using retry within the gateway.
    void setReplyHeadersMappedLast​(boolean replyHeadersMappedLast)
    When mapping headers for the outbound (reply) message, determine whether the headers are mapped before the message is converted, or afterwards.
    void setRetryTemplate​(org.springframework.retry.support.RetryTemplate retryTemplate)
    Set a RetryTemplate to use for retrying a message delivery within the gateway.

    Methods inherited from class org.springframework.integration.gateway.MessagingGatewaySupport

    buildErrorMessage, buildSendTimer, destroy, getErrorChannel, getIntegrationPatternType, getManagedName, getManagedType, getOverrides, getReplyChannel, getRequestChannel, isLoggingEnabled, receive, receive, receiveMessage, receiveMessage, registerMetricsCaptor, registerReplyMessageCorrelatorIfNecessary, send, sendAndReceive, sendAndReceiveMessage, sendAndReceiveMessageReactive, sendTimer, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setErrorOnTimeout, setLoggingEnabled, setManagedName, setManagedType, setReplyChannel, setReplyChannelName, setReplyMapper, setReplyTimeout, setRequestChannel, setRequestChannelName, setRequestMapper, setRequestTimeout, setShouldTrack

    Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint

    doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stop

    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 org.springframework.integration.support.management.IntegrationManagement

    getThisAs

    Methods inherited from interface org.springframework.integration.support.context.NamedComponent

    getBeanName, getComponentName
  • Constructor Details

    • AmqpInboundGateway

      public AmqpInboundGateway​(org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer listenerContainer)
    • AmqpInboundGateway

      public AmqpInboundGateway​(org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer listenerContainer, org.springframework.amqp.core.AmqpTemplate amqpTemplate)
      Construct AmqpInboundGateway based on the provided AbstractMessageListenerContainer to receive request messages and AmqpTemplate to send replies.
      Parameters:
      listenerContainer - the MessageListenerContainer to receive AMQP messages.
      amqpTemplate - the AmqpTemplate to send reply messages.
      Since:
      4.2
    • AmqpInboundGateway

      public AmqpInboundGateway​(org.springframework.amqp.rabbit.listener.MessageListenerContainer listenerContainer, org.springframework.amqp.core.AmqpTemplate amqpTemplate)
      Construct AmqpInboundGateway based on the provided MessageListenerContainer to receive request messages and AmqpTemplate to send replies.
      Parameters:
      listenerContainer - the MessageListenerContainer to receive AMQP messages.
      amqpTemplate - the AmqpTemplate to send reply messages.
  • Method Details

    • setMessageConverter

      public void setMessageConverter​(org.springframework.amqp.support.converter.MessageConverter messageConverter)
      Specify the MessageConverter to convert request and reply to/from Message. If the amqpTemplate is explicitly set, this MessageConverter isn't populated there. You must configure that external amqpTemplate.
      Parameters:
      messageConverter - the MessageConverter to use.
    • setHeaderMapper

      public void setHeaderMapper​(AmqpHeaderMapper headerMapper)
    • setDefaultReplyTo

      public void setDefaultReplyTo​(java.lang.String defaultReplyTo)
      The defaultReplyTo address with the form
       (exchange)/(routingKey)
       
      or
       (queueName)
       
      if the request message doesn't have a replyTo property. The second form uses the default exchange ("") and the queue name as the routing key.
      Parameters:
      defaultReplyTo - the default replyTo address to use.
      Since:
      4.2
      See Also:
      Address
    • setRetryTemplate

      public void setRetryTemplate​(org.springframework.retry.support.RetryTemplate retryTemplate)
      Set a RetryTemplate to use for retrying a message delivery within the gateway. Unlike adding retry at the container level, this can be used with an ErrorMessageSendingRecoverer RecoveryCallback to publish to the error channel after retries are exhausted. You generally should not configure an error channel when using retry here, use a RecoveryCallback instead.
      Parameters:
      retryTemplate - the template.
      Since:
      4.3.10.
      See Also:
      setRecoveryCallback(RecoveryCallback)
    • setRecoveryCallback

      public void setRecoveryCallback​(org.springframework.retry.RecoveryCallback<? extends java.lang.Object> recoveryCallback)
      Set a RecoveryCallback when using retry within the gateway. Mutually exclusive with setMessageRecoverer(MessageRecoverer).
      Parameters:
      recoveryCallback - the callback.
      Since:
      4.3.10
      See Also:
      setRetryTemplate(RetryTemplate)
    • setMessageRecoverer

      public void setMessageRecoverer​(org.springframework.amqp.rabbit.retry.MessageRecoverer messageRecoverer)
      Configure a MessageRecoverer for retry operations. A more AMQP-specific convenience instead of setRecoveryCallback(RecoveryCallback).
      Parameters:
      messageRecoverer - the MessageRecoverer to use.
      Since:
      5.5
    • setBatchingStrategy

      public void setBatchingStrategy​(org.springframework.amqp.rabbit.batch.BatchingStrategy batchingStrategy)
      Set a batching strategy to use when de-batching messages. Default is SimpleBatchingStrategy.
      Parameters:
      batchingStrategy - the strategy.
      Since:
      5.2
    • setBindSourceMessage

      public void setBindSourceMessage​(boolean bindSourceMessage)
      Set to true to bind the source message in the header named IntegrationMessageHeaderAccessor.SOURCE_DATA.
      Parameters:
      bindSourceMessage - true to bind.
      Since:
      5.1.6
    • setReplyHeadersMappedLast

      public void setReplyHeadersMappedLast​(boolean replyHeadersMappedLast)
      When mapping headers for the outbound (reply) 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:
      replyHeadersMappedLast - true if reply headers are mapped after conversion.
      Since:
      5.1.9
    • getComponentType

      public java.lang.String getComponentType()
      Specified by:
      getComponentType in interface org.springframework.integration.support.context.NamedComponent
      Overrides:
      getComponentType in class org.springframework.integration.gateway.MessagingGatewaySupport
    • onInit

      protected void onInit()
      Overrides:
      onInit in class org.springframework.integration.gateway.MessagingGatewaySupport
    • doStart

      protected void doStart()
      Overrides:
      doStart in class org.springframework.integration.gateway.MessagingGatewaySupport
    • doStop

      protected void doStop()
      Overrides:
      doStop in class org.springframework.integration.gateway.MessagingGatewaySupport
    • getErrorMessageAttributes

      protected org.springframework.core.AttributeAccessor getErrorMessageAttributes​(org.springframework.messaging.Message<?> message)
      Overrides:
      getErrorMessageAttributes in class org.springframework.integration.gateway.MessagingGatewaySupport