Class JmsOutboundGateway

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.jms.JmsOutboundGateway
All Implemented Interfaces:
javax.jms.MessageListener, 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<?>>

public class JmsOutboundGateway
extends org.springframework.integration.handler.AbstractReplyProducingMessageHandler
implements org.springframework.integration.support.management.ManageableLifecycle, javax.jms.MessageListener
An outbound Messaging Gateway for request/reply JMS.
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  JmsOutboundGateway.ReplyContainerProperties  

    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 
    Modifier and Type Field Description
    static long DEFAULT_RECEIVE_TIMEOUT
    A default receive timeout in milliseconds.

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

    Modifier and Type Method Description
    protected javax.jms.Connection createConnection()
    Create a new JMS Connection for this JMS gateway.
    protected javax.jms.Session createSession​(javax.jms.Connection connection)
    Create a new JMS Session using the provided Connection.
    protected void doInit()  
    java.lang.String getComponentType()  
    protected java.lang.Object handleRequestMessage​(org.springframework.messaging.Message<?> requestMessage)  
    boolean isRunning()  
    void onMessage​(javax.jms.Message message)  
    void setConnectionFactory​(javax.jms.ConnectionFactory connectionFactory)
    Set the JMS ConnectionFactory that this gateway should use.
    void setCorrelationKey​(java.lang.String correlationKey)
    Provide the name of a JMS property that should hold a generated UUID that the receiver of the JMS Message would expect to represent the CorrelationID.
    void setDefaultPriority​(int priority)
    Specify the default JMS priority to use when sending request Messages with no IntegrationMessageHeaderAccessor.PRIORITY header.
    void setDeliveryPersistent​(boolean deliveryPersistent)
    Set whether message delivery should be persistent or non-persistent, specified as a boolean value ("true" or "false").
    void setDestinationResolver​(org.springframework.jms.support.destination.DestinationResolver destinationResolver)
    Provide the DestinationResolver to use when resolving either a 'requestDestinationName' or 'replyDestinationName' value.
    void setExplicitQosEnabled​(boolean explicitQosEnabled)
    Specify whether explicit QoS settings are enabled (deliveryMode, priority, and timeToLive).
    void setExtractReplyPayload​(boolean extractReplyPayload)
    This property describes what to do with a JMS reply Message.
    void setExtractRequestPayload​(boolean extractRequestPayload)
    This property describes how a JMS Message should be generated from the Spring Integration Message.
    void setHeaderMapper​(JmsHeaderMapper headerMapper)
    Provide a JmsHeaderMapper implementation for mapping the Spring Integration Message Headers to/from JMS Message properties.
    void setIdleReplyContainerTimeout​(long idleReplyContainerTimeout)
    Set the target timeout for idle containers, in seconds.
    void setIdleReplyContainerTimeout​(long idleReplyContainerTimeout, java.util.concurrent.TimeUnit unit)
    Set the target timeout for idle containers.
    void setMessageConverter​(org.springframework.jms.support.converter.MessageConverter messageConverter)
    Provide a MessageConverter strategy to use for converting the Spring Integration request Message into a JMS Message and for converting the JMS reply Messages back into Spring Integration Messages.
    void setReceiveTimeout​(long receiveTimeout)
    Set the max timeout value for the MessageConsumer's receive call when waiting for a reply.
    void setReplyChannel​(org.springframework.messaging.MessageChannel replyChannel)
    Specify the Spring Integration reply channel.
    void setReplyContainerProperties​(JmsOutboundGateway.ReplyContainerProperties replyContainerProperties)  
    void setReplyDestination​(javax.jms.Destination replyDestination)
    Set the JMS Destination from which reply Messages should be received.
    void setReplyDestinationExpression​(org.springframework.expression.Expression replyDestinationExpression)
    Set the SpEL Expression to be used for determining the reply Destination instance or reply destination name.
    void setReplyDestinationName​(java.lang.String replyDestinationName)
    Set the name of the JMS Destination from which reply Messages should be received.
    void setReplyPubSubDomain​(boolean replyPubSubDomain)
    Specify whether the reply destination is a Topic.
    void setRequestDestination​(javax.jms.Destination requestDestination)
    Set the JMS Destination to which request Messages should be sent.
    void setRequestDestinationExpression​(org.springframework.expression.Expression requestDestinationExpression)
    Set the SpEL Expression to be used for determining the request Destination instance or request destination name.
    void setRequestDestinationName​(java.lang.String requestDestinationName)
    Set the name of the JMS Destination to which request Messages should be sent.
    void setRequestPubSubDomain​(boolean requestPubSubDomain)
    Specify whether the request destination is a Topic.
    void setRequiresReply​(boolean requiresReply)  
    void setTimeToLive​(long timeToLive)
    Specify the timeToLive for each sent Message.
    void setUseReplyContainer​(boolean useReplyContainer)  
    void start()  
    void stop()  

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

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

    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, 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
  • Field Details

  • Constructor Details

  • Method Details

    • setDeliveryPersistent

      public void setDeliveryPersistent​(boolean deliveryPersistent)
      Set whether message delivery should be persistent or non-persistent, specified as a boolean value ("true" or "false"). This will set the delivery mode accordingly to either "PERSISTENT" (1) or "NON_PERSISTENT" (2).

      The default is "true", i.e. delivery mode "PERSISTENT".

      Parameters:
      deliveryPersistent - true for a persistent delivery.
      See Also:
      DeliveryMode.PERSISTENT, DeliveryMode.NON_PERSISTENT
    • setConnectionFactory

      public void setConnectionFactory​(javax.jms.ConnectionFactory connectionFactory)
      Set the JMS ConnectionFactory that this gateway should use. This is a required property.
      Parameters:
      connectionFactory - The connection factory.
    • setRequestDestination

      public void setRequestDestination​(javax.jms.Destination requestDestination)
      Set the JMS Destination to which request Messages should be sent. Either this or one of 'requestDestinationName' or 'requestDestinationExpression' is required.
      Parameters:
      requestDestination - The request destination.
    • setRequestDestinationName

      public void setRequestDestinationName​(java.lang.String requestDestinationName)
      Set the name of the JMS Destination to which request Messages should be sent. Either this or one of 'requestDestination' or 'requestDestinationExpression' is required.
      Parameters:
      requestDestinationName - The request destination name.
    • setRequestDestinationExpression

      public void setRequestDestinationExpression​(org.springframework.expression.Expression requestDestinationExpression)
      Set the SpEL Expression to be used for determining the request Destination instance or request destination name. Either this or one of 'requestDestination' or 'requestDestinationName' is required.
      Parameters:
      requestDestinationExpression - The request destination expression.
    • setReplyDestination

      public void setReplyDestination​(javax.jms.Destination replyDestination)
      Set the JMS Destination from which reply Messages should be received. If none is provided, this gateway will create a TemporaryQueue per invocation.
      Parameters:
      replyDestination - The reply destination.
    • setReplyDestinationName

      public void setReplyDestinationName​(java.lang.String replyDestinationName)
      Set the name of the JMS Destination from which reply Messages should be received. If none is provided, this gateway will create a TemporaryQueue per invocation.
      Parameters:
      replyDestinationName - The reply destination name.
    • setReplyDestinationExpression

      public void setReplyDestinationExpression​(org.springframework.expression.Expression replyDestinationExpression)
      Set the SpEL Expression to be used for determining the reply Destination instance or reply destination name. Either this or one of 'replyDestination' or 'replyDestinationName' is required.
      Parameters:
      replyDestinationExpression - The reply destination expression.
    • setDestinationResolver

      public void setDestinationResolver​(org.springframework.jms.support.destination.DestinationResolver destinationResolver)
      Provide the DestinationResolver to use when resolving either a 'requestDestinationName' or 'replyDestinationName' value. The default is an instance of DynamicDestinationResolver.
      Parameters:
      destinationResolver - The destination resolver.
    • setRequestPubSubDomain

      public void setRequestPubSubDomain​(boolean requestPubSubDomain)
      Specify whether the request destination is a Topic. This value is necessary when providing a destination name for a Topic rather than a destination reference.
      Parameters:
      requestPubSubDomain - true if the request destination is a Topic.
    • setReplyPubSubDomain

      public void setReplyPubSubDomain​(boolean replyPubSubDomain)
      Specify whether the reply destination is a Topic. This value is necessary when providing a destination name for a Topic rather than a destination reference.
      Parameters:
      replyPubSubDomain - true if the reply destination is a Topic.
    • setReceiveTimeout

      public void setReceiveTimeout​(long receiveTimeout)
      Set the max timeout value for the MessageConsumer's receive call when waiting for a reply. The default value is 5 seconds.
      Parameters:
      receiveTimeout - The receive timeout.
    • setDefaultPriority

      public void setDefaultPriority​(int priority)
      Specify the default JMS priority to use when sending request Messages with no IntegrationMessageHeaderAccessor.PRIORITY header. The value should be within the range of 0-9.
      Parameters:
      priority - The priority.
      Since:
      5.1.2
    • setTimeToLive

      public void setTimeToLive​(long timeToLive)
      Specify the timeToLive for each sent Message. The default value indicates no expiration.
      Parameters:
      timeToLive - The time to live.
    • setExplicitQosEnabled

      public void setExplicitQosEnabled​(boolean explicitQosEnabled)
      Specify whether explicit QoS settings are enabled (deliveryMode, priority, and timeToLive).
      Parameters:
      explicitQosEnabled - true to enable explicit QoS.
    • setCorrelationKey

      public void setCorrelationKey​(java.lang.String correlationKey)
      Provide the name of a JMS property that should hold a generated UUID that the receiver of the JMS Message would expect to represent the CorrelationID. When waiting for the reply Message, a MessageSelector will be configured to match this property name and the UUID value that was sent in the request.

      If this value is NULL (the default) then the reply consumer's MessageSelector will be expecting the JMSCorrelationID to equal the Message ID of the request.

      If you want to store the outbound correlation UUID value in the actual JMSCorrelationID property, then set this value to "JMSCorrelationID".

      If you want to use and existing "JMSCorrelationID" from the inbound message (mapped from 'jms_correlationId'), you can set this property to "JMSCorrelationID*" with the trailing asterisk. If the message has a correlation id, it will be used, otherwise a new one will be set in the 'JMSCorrelationID' header. However, understand that the gateway has no means to ensure uniqueness and unexpected side effects can occur if the correlation id is not unique.

      This setting is not allowed if a reply listener is used.

      Parameters:
      correlationKey - The correlation key.
    • setMessageConverter

      public void setMessageConverter​(org.springframework.jms.support.converter.MessageConverter messageConverter)
      Provide a MessageConverter strategy to use for converting the Spring Integration request Message into a JMS Message and for converting the JMS reply Messages back into Spring Integration Messages.

      The default is SimpleMessageConverter.

      Parameters:
      messageConverter - The message converter.
    • setHeaderMapper

      public void setHeaderMapper​(JmsHeaderMapper headerMapper)
      Provide a JmsHeaderMapper implementation for mapping the Spring Integration Message Headers to/from JMS Message properties.
      Parameters:
      headerMapper - The header mapper.
    • setExtractRequestPayload

      public void setExtractRequestPayload​(boolean extractRequestPayload)
      This property describes how a JMS Message should be generated from the Spring Integration Message. If set to 'true', the body of the JMS Message will be created from the Spring Integration Message's payload (via the MessageConverter). If set to 'false', then the entire Spring Integration Message will serve as the base for JMS Message creation. Since the JMS Message is created by the MessageConverter, this really manages what is sent to the MessageConverter: the entire Spring Integration Message or only its payload. Default is 'true'.
      Parameters:
      extractRequestPayload - true to extract the request payload.
    • setExtractReplyPayload

      public void setExtractReplyPayload​(boolean extractReplyPayload)
      This property describes what to do with a JMS reply Message. If set to 'true', the payload of the Spring Integration Message will be created from the JMS Reply Message's body (via MessageConverter). Otherwise, the entire JMS Message will become the payload of the Spring Integration Message.
      Parameters:
      extractReplyPayload - true to extract the reply payload.
    • setReplyChannel

      public void setReplyChannel​(org.springframework.messaging.MessageChannel replyChannel)
      Specify the Spring Integration reply channel. If this property is not set the gateway will check for a 'replyChannel' header on the request.
      Parameters:
      replyChannel - The reply channel.
    • setReplyContainerProperties

      public void setReplyContainerProperties​(JmsOutboundGateway.ReplyContainerProperties replyContainerProperties)
      Parameters:
      replyContainerProperties - the replyContainerProperties to set
    • getComponentType

      public java.lang.String getComponentType()
      Specified by:
      getComponentType in interface org.springframework.integration.support.context.NamedComponent
      Overrides:
      getComponentType in class org.springframework.integration.handler.MessageHandlerSupport
    • setUseReplyContainer

      public void setUseReplyContainer​(boolean useReplyContainer)
      Parameters:
      useReplyContainer - the useReplyContainer to set
    • setRequiresReply

      public void setRequiresReply​(boolean requiresReply)
      Overrides:
      setRequiresReply in class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
    • setIdleReplyContainerTimeout

      public void setIdleReplyContainerTimeout​(long idleReplyContainerTimeout)
      Set the target timeout for idle containers, in seconds. Setting this greater than zero enables lazy starting of the reply listener container. The container will be started when a message is sent. It will be stopped when idle for at least this time. The actual stop time may be up to 1.5x this time.
      Parameters:
      idleReplyContainerTimeout - the timeout in seconds.
      Since:
      4.2
    • setIdleReplyContainerTimeout

      public void setIdleReplyContainerTimeout​(long idleReplyContainerTimeout, java.util.concurrent.TimeUnit unit)
      Set the target timeout for idle containers. Setting this greater than zero enables lazy starting of the reply listener container. The container will be started when a message is sent. It will be stopped when idle for at least this time. The actual stop time may be up to 1.5x this time.
      Parameters:
      idleReplyContainerTimeout - the timeout in seconds.
      unit - the time unit.
      Since:
      4.2
    • doInit

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

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

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

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

      protected java.lang.Object handleRequestMessage​(org.springframework.messaging.Message<?> requestMessage)
      Specified by:
      handleRequestMessage in class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
    • createConnection

      protected javax.jms.Connection createConnection() throws javax.jms.JMSException
      Create a new JMS Connection for this JMS gateway.
      Returns:
      The connection.
      Throws:
      javax.jms.JMSException - Any JMSException.
    • createSession

      protected javax.jms.Session createSession​(javax.jms.Connection connection) throws javax.jms.JMSException
      Create a new JMS Session using the provided Connection.
      Parameters:
      connection - The connection.
      Returns:
      The session.
      Throws:
      javax.jms.JMSException - Any JMSException.
    • onMessage

      public void onMessage​(javax.jms.Message message)
      Specified by:
      onMessage in interface javax.jms.MessageListener