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:
BeanFactoryAware, BeanNameAware, InitializingBean, Ordered, NamedComponent, 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.handler.AbstractReplyProducingMessageHandler
DEFAULT_SEND_TIMEOUT
 
Fields inherited from class org.springframework.integration.handler.AbstractMessageHandler
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, ideally a javax.jms.QueueConnection.
protected  javax.jms.Session createSession(javax.jms.Connection connection)
          Create a new JMS Session for this JMS gateway, ideally a javax.jms.QueueSession.
 String getComponentType()
          Subclasses may implement this method to provide component type information.
protected  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 setDeliveryMode(int deliveryMode)
          Specify the JMS DeliveryMode to use when sending request Messages.
 void setDestinationResolver(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 will take effect if no custom MessageConverter has been provided to the setMessageConverter(MessageConverter) method.
 void setExtractRequestPayload(boolean extractRequestPayload)
          This property will take effect if no custom MessageConverter has been provided to the setMessageConverter(MessageConverter) method.
 void setHeaderMapper(JmsHeaderMapper headerMapper)
          Provide a JmsHeaderMapper implementation for mapping the Spring Integration Message Headers to/from JMS Message properties.
 void setMessageConverter(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 setPubSubDomain(boolean pubSubDomain)
          Specify whether the request destination is a Topic.
 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(String replyDestinationName)
          Set the name of the JMS Destination from which reply Messages should be received.
 void setRequestDestination(javax.jms.Destination requestDestination)
          Set the JMS Destination to which request Messages should be sent.
 void setRequestDestinationName(String requestDestinationName)
          Set the name of the JMS Destination to which request Messages should be sent.
 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, getRequiredMetadataPersister, 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

getComponentType

public 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

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 the 'requestDestinationName' property is required.


setRequestDestinationName

public void setRequestDestinationName(String requestDestinationName)
Set the name of the JMS Destination to which request Messages should be sent. Either this or the 'requestDestination' property 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(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(DestinationResolver destinationResolver)
Provide the DestinationResolver to use when resolving either a 'requestDestinationName' or 'replyDestinationName' value. The default is an instance of DynamicDestinationResolver.


setPubSubDomain

public void setPubSubDomain(boolean pubSubDomain)
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:
pubSubDomain - true if the request 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).


setMessageConverter

public void setMessageConverter(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 a DefaultMessageConverter that delegates to a SimpleMessageConverter.


setHeaderMapper

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

This property will be ignored if a MessageConverter is provided to the setMessageConverter(MessageConverter) method. However, you may provide your own implementation of the delegating DefaultMessageConverter implementation.


setExtractRequestPayload

public void setExtractRequestPayload(boolean extractRequestPayload)
This property will take effect if no custom MessageConverter has been provided to the setMessageConverter(MessageConverter) method. In that case, a DefaultMessageConverter will be used by default, and this value will be passed along to that converter's 'extractIntegrationMessagePayload' property.

See Also:
DefaultMessageConverter#setExtractIntegrationMessagePayload(boolean)

setExtractReplyPayload

public void setExtractReplyPayload(boolean extractReplyPayload)
This property will take effect if no custom MessageConverter has been provided to the setMessageConverter(MessageConverter) method. In that case, a DefaultMessageConverter will be used by default, and this value will be passed along to that converter's 'extractJmsMessageBody' property.

See Also:
DefaultMessageConverter#setExtractJmsMessageBody(boolean)

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.


onInit

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

Overrides:
onInit in class AbstractReplyProducingMessageHandler

handleRequestMessage

protected 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, ideally a javax.jms.QueueConnection.

The default implementation uses the javax.jms.QueueConnectionFactory API if available, falling back to a standard JMS 1.1 ConnectionFactory otherwise. This is necessary for working with generic JMS 1.1 connection pools (such as ActiveMQ's org.apache.activemq.pool.PooledConnectionFactory).

Throws:
javax.jms.JMSException

createSession

protected javax.jms.Session createSession(javax.jms.Connection connection)
                                   throws javax.jms.JMSException
Create a new JMS Session for this JMS gateway, ideally a javax.jms.QueueSession.

The default implementation uses the javax.jms.QueueConnection API if available, falling back to a standard JMS 1.1 Connection otherwise. This is necessary for working with generic JMS 1.1 connection pools (such as ActiveMQ's org.apache.activemq.pool.PooledConnectionFactory).

Throws:
javax.jms.JMSException

Spring Integration

Copyright © 2010. All Rights Reserved.