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:
org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.core.Ordered, NamedComponent, Orderable, MessageHandler, MessageProducer, TrackableComponent

public class JmsOutboundGateway
extends AbstractReplyProducingMessageHandler

An outbound Messaging Gateway for request/reply JMS.

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

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.
protected  java.lang.Object handleRequestMessage(Message<?> message)
          Subclasses must implement this method to handle the request Message.
 void onInit()
          Subclasses may implement this for initialization logic.
 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)
          Specify the JMS DeliveryMode to use when sending request Messages.
 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 setReplyDestination(javax.jms.Destination replyDestination)
          Set the JMS Destination from which reply Messages should be received.
 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.
 
Methods inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
getMessagingTemplate, handleMessageInternal, 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, getBeanFactory, getComponentName, getConversionService, getTaskScheduler, 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:
setDeliveryMode(int), 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.


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

public void setDeliveryMode(int deliveryMode)
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.


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

onInit

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

Overrides:
onInit in class AbstractReplyProducingMessageHandler

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

Spring Integration