org.springframework.integration.jms
Class ChannelPublishingJmsMessageListener

java.lang.Object
  extended by org.springframework.integration.jms.ChannelPublishingJmsMessageListener
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean, org.springframework.jms.listener.SessionAwareMessageListener

public class ChannelPublishingJmsMessageListener
extends java.lang.Object
implements org.springframework.jms.listener.SessionAwareMessageListener, org.springframework.beans.factory.InitializingBean

JMS MessageListener that converts a JMS Message into a Spring Integration Message and sends that Message to a channel. If the 'expectReply' value is true, it will also wait for a Spring Integration reply Message and convert that into a JMS reply.

Author:
Mark Fisher, Juergen Hoeller

Constructor Summary
ChannelPublishingJmsMessageListener()
           
 
Method Summary
 void afterPropertiesSet()
           
 void onMessage(javax.jms.Message jmsMessage, javax.jms.Session session)
           
 void setDefaultReplyDestination(javax.jms.Destination defaultReplyDestination)
          Set the default reply destination to send reply messages to.
 void setDefaultReplyQueueName(java.lang.String destinationName)
          Set the name of the default reply queue to send reply messages to.
 void setDefaultReplyTopicName(java.lang.String destinationName)
          Set the name of the default reply topic to send reply messages to.
 void setDestinationResolver(org.springframework.jms.support.destination.DestinationResolver destinationResolver)
          Set the DestinationResolver that should be used to resolve reply destination names for this listener.
 void setExpectReply(boolean expectReply)
          Specify whether a JMS reply Message is expected.
 void setExtractReplyPayload(boolean extractReplyPayload)
          Specify whether the Spring Integration reply Message's payload should be extracted prior to converting into a JMS Message.
 void setExtractRequestPayload(boolean extractRequestPayload)
          Specify whether the JMS request Message's body should be extracted prior to converting into a Spring Integration Message.
 void setHeaderMapper(JmsHeaderMapper headerMapper)
          Provide a JmsHeaderMapper implementation to use when converting between JMS Messages and Spring Integration Messages.
 void setMessageConverter(org.springframework.jms.support.converter.MessageConverter messageConverter)
          Provide a MessageConverter implementation to use when converting between JMS Messages and Spring Integration Messages.
 void setReplyTimeout(long replyTimeout)
          Specify the maximum time to wait for reply Messages.
 void setRequestChannel(MessageChannel requestChannel)
          Specify the channel to which request Messages should be sent.
 void setRequestTimeout(long requestTimeout)
          Specify the maximum time to wait when sending a request message to the request channel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChannelPublishingJmsMessageListener

public ChannelPublishingJmsMessageListener()
Method Detail

setRequestChannel

public void setRequestChannel(MessageChannel requestChannel)
Specify the channel to which request Messages should be sent.


setExpectReply

public void setExpectReply(boolean expectReply)
Specify whether a JMS reply Message is expected.


setRequestTimeout

public void setRequestTimeout(long requestTimeout)
Specify the maximum time to wait when sending a request message to the request channel. The default value will be that of MessageChannelTemplate.


setReplyTimeout

public void setReplyTimeout(long replyTimeout)
Specify the maximum time to wait for reply Messages. This value is only relevant if expectReply is true. The default value will be that of MessageChannelTemplate.


setDefaultReplyDestination

public void setDefaultReplyDestination(javax.jms.Destination defaultReplyDestination)
Set the default reply destination to send reply messages to. This will be applied in case of a request message that does not carry a "JMSReplyTo" field.


setDefaultReplyQueueName

public void setDefaultReplyQueueName(java.lang.String destinationName)
Set the name of the default reply queue to send reply messages to. This will be applied in case of a request message that does not carry a "JMSReplyTo" field.

Alternatively, specify a JMS Destination object as "defaultReplyDestination".

See Also:
setDestinationResolver(org.springframework.jms.support.destination.DestinationResolver), setDefaultReplyDestination(javax.jms.Destination)

setDefaultReplyTopicName

public void setDefaultReplyTopicName(java.lang.String destinationName)
Set the name of the default reply topic to send reply messages to. This will be applied in case of a request message that does not carry a "JMSReplyTo" field.

Alternatively, specify a JMS Destination object as "defaultReplyDestination".

See Also:
setDestinationResolver(org.springframework.jms.support.destination.DestinationResolver), setDefaultReplyDestination(javax.jms.Destination)

setDestinationResolver

public void setDestinationResolver(org.springframework.jms.support.destination.DestinationResolver destinationResolver)
Set the DestinationResolver that should be used to resolve reply destination names for this listener.

The default resolver is a DynamicDestinationResolver. Specify a JndiDestinationResolver for resolving destination names as JNDI locations.

See Also:
DynamicDestinationResolver, JndiDestinationResolver

setMessageConverter

public void setMessageConverter(org.springframework.jms.support.converter.MessageConverter messageConverter)
Provide a MessageConverter implementation to use when converting between JMS Messages and Spring Integration Messages. If none is provided, a HeaderMappingMessageConverter will be used and the JmsHeaderMapper instance provided to the setHeaderMapper(JmsHeaderMapper) method will be included in the conversion process.


setHeaderMapper

public void setHeaderMapper(JmsHeaderMapper headerMapper)
Provide a JmsHeaderMapper implementation to use when converting between JMS Messages and Spring Integration Messages. If none is provided, a DefaultJmsHeaderMapper will be used.

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 HeaderMappingMessageConverter implementation.


setExtractRequestPayload

public void setExtractRequestPayload(boolean extractRequestPayload)
Specify whether the JMS request Message's body should be extracted prior to converting into a Spring Integration Message. This value is set to true by default. To send the JMS Message itself as a Spring Integration Message payload, set this to false.


setExtractReplyPayload

public void setExtractReplyPayload(boolean extractReplyPayload)
Specify whether the Spring Integration reply Message's payload should be extracted prior to converting into a JMS Message. This value is set to true by default. To send the Spring Integration Message itself as the JMS Message's body, set this to false.


afterPropertiesSet

public final void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean

onMessage

public void onMessage(javax.jms.Message jmsMessage,
                      javax.jms.Session session)
               throws javax.jms.JMSException
Specified by:
onMessage in interface org.springframework.jms.listener.SessionAwareMessageListener
Throws:
javax.jms.JMSException