Spring Integration

org.springframework.integration.jms
Class JmsDestinationBackedMessageChannel

java.lang.Object
  extended by org.springframework.integration.jms.JmsDestinationBackedMessageChannel
All Implemented Interfaces:
javax.jms.MessageListener, BeanNameAware, InitializingBean, Lifecycle, Phased, SmartLifecycle, MessageChannel, SubscribableChannel

public class JmsDestinationBackedMessageChannel
extends Object
implements SubscribableChannel, javax.jms.MessageListener, BeanNameAware, SmartLifecycle, InitializingBean

A MessageChannel implementation that is actually backed by a JMS Destination. This class is useful as a drop-in replacement for any Spring Integration channel. The benefit of using this channel is that the full power of any JMS provider is available with only minimal configuration changes and without requiring any code changes. The most obvious benefit is the ability to delegate message persistence to the JMS provider.

Since:
2.0
Author:
Mark Fisher

Constructor Summary
JmsDestinationBackedMessageChannel(javax.jms.ConnectionFactory connectionFactory, javax.jms.Destination destination)
           
JmsDestinationBackedMessageChannel(javax.jms.ConnectionFactory connectionFactory, String destinationName, boolean isPubSub)
           
 
Method Summary
 void afterPropertiesSet()
           
 String getName()
           
 int getPhase()
           
 boolean isAutoStartup()
           
 boolean isRunning()
           
 void onMessage(javax.jms.Message message)
           
 boolean send(Message<?> message)
          Send a Message to this channel.
 boolean send(Message<?> message, long timeout)
          Send a message, blocking until either the message is accepted or the specified timeout period elapses.
 void setAcceptMessagesWhileStopping(boolean acceptMessagesWhileStopping)
           
 void setAutoStartup(boolean autoStartup)
           
 void setBeanName(String beanName)
           
 void setCacheLevelName(String cacheLevelName)
           
 void setClientId(String clientId)
           
 void setConcurrentConsumers(int concurrentConsumers)
           
 void setConnectionFactory(javax.jms.ConnectionFactory connectionFactory)
           
 void setContainerType(Class<? extends AbstractMessageListenerContainer> containerType)
           
 void setDeliveryPersistent(boolean deliveryPersistent)
           
 void setDestination(javax.jms.Destination destination)
           
 void setDestinationName(String destinationName)
           
 void setDestinationResolver(DestinationResolver destinationResolver)
           
 void setDurableSubscriptionName(String durableSubscriptionName)
           
 void setErrorHandler(ErrorHandler errorHandler)
           
 void setExceptionListener(javax.jms.ExceptionListener exceptionListener)
           
 void setExplicitQosEnabled(boolean explicitQosEnabled)
           
 void setExposeListenerSession(boolean exposeListenerSession)
           
 void setIdleTaskExecutionLimit(int idleTaskExecutionLimit)
           
 void setMaxConcurrentConsumers(int maxConcurrentConsumers)
           
 void setMaxMessagesPerTask(int maxMessagesPerTask)
           
 void setMessageConverter(MessageConverter messageConverter)
           
 void setMessageIdEnabled(boolean messageIdEnabled)
           
 void setMessageSelector(String messageSelector)
           
 void setMessageTimestampEnabled(boolean messageTimestampEnabled)
           
 void setPhase(int phase)
           
 void setPriority(int priority)
           
 void setPubSubDomain(boolean pubSubDomain)
           
 void setPubSubNoLocal(boolean pubSubNoLocal)
           
 void setReceiveTimeout(long receiveTimeout)
           
 void setRecoveryInterval(long recoveryInterval)
           
 void setSessionAcknowledgeMode(int sessionAcknowledgeMode)
           
 void setSessionTransacted(boolean sessionTransacted)
           
 void setSubscriptionDurable(boolean subscriptionDurable)
           
 void setTaskExecutor(Executor taskExecutor)
           
 void setTimeToLive(long timeToLive)
           
 void setTransactionManager(PlatformTransactionManager transactionManager)
           
 void setTransactionName(String transactionName)
           
 void setTransactionTimeout(int transactionTimeout)
           
 void start()
           
 void stop()
           
 void stop(Runnable callback)
           
 boolean subscribe(MessageHandler handler)
          Register a MessageHandler as a subscriber to this channel.
 boolean unsubscribe(MessageHandler handler)
          Remove a MessageHandler from the subscribers of this channel.
 boolean waitRegisteredWithDestination(long timeout)
          Blocks until the listener container has subscribed; if the container does not support this test, or the caching mode is incompatible, true is returned.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.context.SmartLifecycle
isAutoStartup, stop
 
Methods inherited from interface org.springframework.context.Lifecycle
isRunning, start, stop
 
Methods inherited from interface org.springframework.context.Phased
getPhase
 

Constructor Detail

JmsDestinationBackedMessageChannel

public JmsDestinationBackedMessageChannel(javax.jms.ConnectionFactory connectionFactory,
                                          javax.jms.Destination destination)

JmsDestinationBackedMessageChannel

public JmsDestinationBackedMessageChannel(javax.jms.ConnectionFactory connectionFactory,
                                          String destinationName,
                                          boolean isPubSub)
Method Detail

setConnectionFactory

public void setConnectionFactory(javax.jms.ConnectionFactory connectionFactory)

setDestination

public void setDestination(javax.jms.Destination destination)

setDestinationName

public void setDestinationName(String destinationName)

setDestinationResolver

public void setDestinationResolver(DestinationResolver destinationResolver)

setPubSubDomain

public void setPubSubDomain(boolean pubSubDomain)

setDeliveryPersistent

public void setDeliveryPersistent(boolean deliveryPersistent)

setExplicitQosEnabled

public void setExplicitQosEnabled(boolean explicitQosEnabled)

setMessageConverter

public void setMessageConverter(MessageConverter messageConverter)

setMessageIdEnabled

public void setMessageIdEnabled(boolean messageIdEnabled)

setMessageTimestampEnabled

public void setMessageTimestampEnabled(boolean messageTimestampEnabled)

setPriority

public void setPriority(int priority)

setPubSubNoLocal

public void setPubSubNoLocal(boolean pubSubNoLocal)

setSessionAcknowledgeMode

public void setSessionAcknowledgeMode(int sessionAcknowledgeMode)

setSessionTransacted

public void setSessionTransacted(boolean sessionTransacted)

setTimeToLive

public void setTimeToLive(long timeToLive)

setBeanName

public void setBeanName(String beanName)
Specified by:
setBeanName in interface BeanNameAware

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

getName

public String getName()

subscribe

public boolean subscribe(MessageHandler handler)
Description copied from interface: SubscribableChannel
Register a MessageHandler as a subscriber to this channel.

Specified by:
subscribe in interface SubscribableChannel

unsubscribe

public boolean unsubscribe(MessageHandler handler)
Description copied from interface: SubscribableChannel
Remove a MessageHandler from the subscribers of this channel.

Specified by:
unsubscribe in interface SubscribableChannel

send

public boolean send(Message<?> message)
Description copied from interface: MessageChannel
Send a Message to this channel. May throw a RuntimeException for non-recoverable errors. Otherwise, if the Message cannot be sent for a non-fatal reason this method will return 'false', and if the Message is sent successfully, it will return 'true'.

Depending on the implementation, this method may block indefinitely. To provide a maximum wait time, use MessageChannel.send(Message, long).

Specified by:
send in interface MessageChannel
Parameters:
message - the Message to send
Returns:
whether the Message has been sent successfully

send

public boolean send(Message<?> message,
                    long timeout)
Description copied from interface: MessageChannel
Send a message, blocking until either the message is accepted or the specified timeout period elapses.

Specified by:
send in interface MessageChannel
Parameters:
message - the Message to send
timeout - the timeout in milliseconds
Returns:
true if the message is sent successfully, false if the specified timeout period elapses or the send is interrupted

onMessage

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

setAcceptMessagesWhileStopping

public void setAcceptMessagesWhileStopping(boolean acceptMessagesWhileStopping)

setAutoStartup

public void setAutoStartup(boolean autoStartup)

setCacheLevelName

public void setCacheLevelName(String cacheLevelName)

setClientId

public void setClientId(String clientId)

setConcurrentConsumers

public void setConcurrentConsumers(int concurrentConsumers)

setContainerType

public void setContainerType(Class<? extends AbstractMessageListenerContainer> containerType)

setDurableSubscriptionName

public void setDurableSubscriptionName(String durableSubscriptionName)

setErrorHandler

public void setErrorHandler(ErrorHandler errorHandler)

setExceptionListener

public void setExceptionListener(javax.jms.ExceptionListener exceptionListener)

setExposeListenerSession

public void setExposeListenerSession(boolean exposeListenerSession)

setIdleTaskExecutionLimit

public void setIdleTaskExecutionLimit(int idleTaskExecutionLimit)

setMaxConcurrentConsumers

public void setMaxConcurrentConsumers(int maxConcurrentConsumers)

setMaxMessagesPerTask

public void setMaxMessagesPerTask(int maxMessagesPerTask)

setMessageSelector

public void setMessageSelector(String messageSelector)

setPhase

public void setPhase(int phase)

setReceiveTimeout

public void setReceiveTimeout(long receiveTimeout)

setRecoveryInterval

public void setRecoveryInterval(long recoveryInterval)

setSubscriptionDurable

public void setSubscriptionDurable(boolean subscriptionDurable)

setTaskExecutor

public void setTaskExecutor(Executor taskExecutor)

setTransactionManager

public void setTransactionManager(PlatformTransactionManager transactionManager)

setTransactionName

public void setTransactionName(String transactionName)

setTransactionTimeout

public void setTransactionTimeout(int transactionTimeout)

getPhase

public int getPhase()

isAutoStartup

public boolean isAutoStartup()

isRunning

public boolean isRunning()

waitRegisteredWithDestination

public boolean waitRegisteredWithDestination(long timeout)
Blocks until the listener container has subscribed; if the container does not support this test, or the caching mode is incompatible, true is returned. Otherwise blocks until timeout milliseconds have passed, or the consumer has registered.

Parameters:
timeout - Timeout in milliseconds.
Returns:
True if a subscriber has connected or the container/attributes does not support the test. False if a valid container does not have a registered consumer within timeout milliseconds.
See Also:
DefaultMessageListenerContainer.isRegisteredWithDestination()

start

public void start()

stop

public void stop()

stop

public void stop(Runnable callback)

Spring Integration

Copyright © 2010. All Rights Reserved.