Spring Integration

org.springframework.integration.jms
Class JmsOutboundGateway

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.handler.AbstractMessageHandler
          extended by org.springframework.integration.handler.AbstractReplyProducingMessageHandler
              extended by org.springframework.integration.jms.JmsOutboundGateway
All Implemented Interfaces:
javax.jms.MessageListener, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle, org.springframework.core.Ordered, NamedComponent, Orderable, MessageHandler, MessageProducer, TrackableComponent

public class JmsOutboundGateway
extends AbstractReplyProducingMessageHandler
implements org.springframework.context.SmartLifecycle, javax.jms.MessageListener

An outbound Messaging Gateway for request/reply JMS.

Author:
Mark Fisher, Arjen Poutsma, Juergen Hoeller, Oleg Zhurakousky, Gary Russell

Nested Class Summary
static class JmsOutboundGateway.ReplyContainerProperties
           
 
Nested classes/interfaces inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
AbstractReplyProducingMessageHandler.RequestHandler
 
Field Summary
 
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
logger
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
JmsOutboundGateway()
           
 
Method Summary
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.
 java.lang.String getComponentType()
          Subclasses may implement this method to provide component type information.
 int getPhase()
           
protected  java.lang.Object handleRequestMessage(Message<?> message)
          Subclasses must implement this method to handle the request Message.
 boolean isAutoStartup()
           
 boolean isRunning()
           
 void onInit()
          Subclasses may implement this for initialization logic.
 void onMessage(javax.jms.Message message)
           
 void setAutoStartup(boolean autoStartup)
           
 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 setDeliveryMode(int deliveryMode)
          Deprecated. use setDeliveryPersistent(boolean) This should have been deprecated in 2.0 when the attribute was deprecated in the schema. As of 3.0, the attribute has been removed but this remains to allow users of the API to migrate. TODO: Remove in 3.1/4.0
 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 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 setPriority(int priority)
          Specify the JMS priority to use when sending request Messages.
 void setReceiveTimeout(long receiveTimeout)
          Set the max timeout value for the MessageConsumer's receive call when waiting for a reply.
 void setReplyChannel(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 setTimeToLive(long timeToLive)
          Specify the timeToLive for each sent Message.
 void setUseReplyContainer(boolean useReplyContainer)
           
 void start()
           
 void stop()
           
 void stop(java.lang.Runnable callback)
           
 
Methods inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
doInvokeAdvisedRequestHandler, getMessagingTemplate, handleMessageInternal, hasAdviceChain, setAdviceChain, setBeanClassLoader, setChannelResolver, setOutputChannel, setRequiresReply, setSendTimeout, shouldCopyRequestHeaders
 
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
getOrder, handleMessage, setOrder, setShouldTrack
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getApplicationContextId, getBeanFactory, getComponentName, getConversionService, getTaskScheduler, setApplicationContext, setBeanFactory, setBeanName, setComponentName, setConversionService, 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.context.NamedComponent
getComponentName
 

Constructor Detail

JmsOutboundGateway

public JmsOutboundGateway()
Method Detail

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".

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.


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.


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.


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.


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.


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.


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.


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.


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.


setDeliveryMode

@Deprecated
public void setDeliveryMode(int deliveryMode)
Deprecated. use setDeliveryPersistent(boolean) This should have been deprecated in 2.0 when the attribute was deprecated in the schema. As of 3.0, the attribute has been removed but this remains to allow users of the API to migrate. TODO: Remove in 3.1/4.0

Specify the JMS DeliveryMode to use when sending request Messages.


setPriority

public void setPriority(int priority)
Specify the JMS priority to use when sending request Messages. The value should be within the range of 0-9.


setTimeToLive

public void setTimeToLive(long timeToLive)
Specify the timeToLive for each sent Message. The default value indicates no expiration.


setExplicitQosEnabled

public void setExplicitQosEnabled(boolean explicitQosEnabled)
Specify whether explicit QoS settings are enabled (deliveryMode, priority, and timeToLive).


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". However, any other value will be treated as a JMS String Property.


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.


setHeaderMapper

public void setHeaderMapper(JmsHeaderMapper headerMapper)
Provide a JmsHeaderMapper implementation for mapping the Spring Integration Message Headers to/from JMS Message properties.


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 -

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 -

setReplyChannel

public void setReplyChannel(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.


setReplyContainerProperties

public void setReplyContainerProperties(JmsOutboundGateway.ReplyContainerProperties replyContainerProperties)
Parameters:
replyContainerProperties - the replyContainerproperties to set

getComponentType

public java.lang.String getComponentType()
Description copied from class: IntegrationObjectSupport
Subclasses may implement this method to provide component type information.

Specified by:
getComponentType in interface NamedComponent
Overrides:
getComponentType in class AbstractMessageHandler

setUseReplyContainer

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

getPhase

public int getPhase()
Specified by:
getPhase in interface org.springframework.context.Phased

isAutoStartup

public boolean isAutoStartup()
Specified by:
isAutoStartup in interface org.springframework.context.SmartLifecycle

setAutoStartup

public void setAutoStartup(boolean autoStartup)

onInit

public final void onInit()
Description copied from class: IntegrationObjectSupport
Subclasses may implement this for initialization logic.

Overrides:
onInit in class AbstractReplyProducingMessageHandler

start

public void start()
Specified by:
start in interface org.springframework.context.Lifecycle

stop

public void stop()
Specified by:
stop in interface org.springframework.context.Lifecycle

isRunning

public boolean isRunning()
Specified by:
isRunning in interface org.springframework.context.Lifecycle

stop

public void stop(java.lang.Runnable callback)
Specified by:
stop in interface org.springframework.context.SmartLifecycle

handleRequestMessage

protected java.lang.Object handleRequestMessage(Message<?> message)
Description copied from class: AbstractReplyProducingMessageHandler
Subclasses must implement this method to handle the request Message. The return value may be a Message, a MessageBuilder, or any plain Object. The base class will handle the final creation of a reply Message from any of those starting points. If the return value is null, the Message flow will end here.

Specified by:
handleRequestMessage in class AbstractReplyProducingMessageHandler

createConnection

protected javax.jms.Connection createConnection()
                                         throws javax.jms.JMSException
Create a new JMS Connection for this JMS gateway.

Throws:
javax.jms.JMSException

createSession

protected javax.jms.Session createSession(javax.jms.Connection connection)
                                   throws javax.jms.JMSException
Create a new JMS Session using the provided Connection.

Throws:
javax.jms.JMSException

onMessage

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

Spring Integration