org.mule.providers.jms
Class JmsConnector

java.lang.Object
  extended by org.mule.providers.AbstractConnector
      extended by org.mule.providers.jms.JmsConnector
All Implemented Interfaces:
ExceptionListener, EventListener, javax.resource.spi.work.WorkListener, ConnectionNotificationListener, Disposable, Initialisable, UMOServerNotificationListener, UMOConnectable, UMOConnector
Direct Known Subclasses:
AbstractOracleJmsConnector, ActiveMqJmsConnector, WeblogicJmsConnector, WebsphereJmsConnector

public class JmsConnector
extends AbstractConnector
implements ConnectionNotificationListener

JmsConnector is a JMS 1.0.2b compliant connector that can be used by a Mule endpoint. The connector supports all JMS functionality including topics and queues, durable subscribers, acknowledgement modes and local transactions.


Field Summary
 String password
           
 String username
           
 
Fields inherited from class org.mule.providers.AbstractConnector
connected, connecting, connectionStrategy, createMultipleTransactedReceivers, DEFAULT_NUM_CONCURRENT_TX_RECEIVERS, defaultInboundTransformer, defaultOutboundTransformer, defaultResponseTransformer, dispatcherFactory, dispatchers, disposed, disposing, exceptionListener, initialised, logger, name, numberOfConcurrentTransactedReceivers, receivers, serviceDescriptor, serviceOverrides, sessionHandler, started, startOnConnect
 
Fields inherited from interface org.mule.umo.provider.UMOConnector
INT_VALUE_NOT_SET
 
Constructor Summary
JmsConnector()
           
 
Method Summary
protected  void applyVendorSpecificConnectionFactoryProperties()
           
 void close(MessageConsumer consumer)
          Closes the MessageConsumer
 void close(MessageProducer producer)
          Closes the MessageProducer
 void close(Session session)
          Closes the Session
 void close(TemporaryQueue tempQueue)
          Closes the TemporaryQueue
 void close(TemporaryTopic tempTopic)
          Closes the TemporaryTopic
 void closeQuietly(MessageConsumer consumer)
          Closes the MessageConsumer without throwing an exception (an error message is logged instead).
 void closeQuietly(MessageProducer producer)
          Closes the MessageProducer without throwing an exception (an error message is logged instead).
 void closeQuietly(Session session)
          Closes the Session without throwing an exception (an error message is logged instead).
 void closeQuietly(TemporaryQueue tempQueue)
          Closes the TemporaryQueue without throwing an exception (an error message is logged instead).
 void closeQuietly(TemporaryTopic tempTopic)
          Closes the TemporaryTopic without throwing an exception (an error message is logged instead).
protected  Connection createConnection()
           
protected  ConnectionFactory createConnectionFactory()
           
protected  RedeliveryHandler createRedeliveryHandler()
           
protected  void doConnect()
          Template method where any connections should be made for the connector
protected  void doDisconnect()
          Template method where any connected resources used by the connector should be disconnected
protected  void doDispose()
          Template method to perform any work when destroying the connectoe
protected  void doInitialise()
           
protected  void doStart()
          Template method to perform any work when starting the connectoe
protected  void doStop()
          Template method to perform any work when stopping the connectoe
 int getAcknowledgementMode()
           
 String getClientId()
           
 Connection getConnection()
           
 ConnectionFactory getConnectionFactory()
           
 String getConnectionFactoryClass()
           
 String getConnectionFactoryJndiName()
           
 Map getConnectionFactoryProperties()
           
 JmsSupport getJmsSupport()
           
 Context getJndiContext()
           
 String getJndiInitialFactory()
           
 Map getJndiProviderProperties()
           
 String getJndiProviderUrl()
           
 int getMaxRedelivery()
           
 UMOMessageAdapter getMessageAdapter(Object message)
          Gets a UMOMessageAdapter for the endpoint for the given message (data)
 String getPassword()
           
 String getProtocol()
           
protected  Object getReceiverKey(UMOComponent component, UMOEndpoint endpoint)
          The method determines the key used to store the receiver against.
 String getRedeliveryHandler()
           
 ReplyToHandler getReplyToHandler()
          Getter for property 'replyToHandler'.
 Session getSession(boolean transacted, boolean topic)
           
 Session getSession(UMOImmutableEndpoint endpoint)
           
 Session getSessionFromTransaction()
           
 String getSpecification()
           
 JmsTopicResolver getTopicResolver()
          Getter for property 'topicResolver'.
 String getUsername()
           
protected  void initJndiContext()
           
 boolean isCacheJmsSessions()
           
 boolean isDurable()
           
 boolean isEagerConsumer()
          Getter for property 'eagerConsumer'.
 boolean isForceJndiDestinations()
           
 boolean isHonorQosHeaders()
          Gets the value of honorQosHeaders property.
 boolean isJndiDestinations()
           
 boolean isNoLocal()
           
 boolean isPersistentDelivery()
           
 boolean isRecoverJmsConnections()
           
 boolean isRemoteSyncEnabled()
          
 void onNotification(UMOServerNotification notification)
           
 Message preProcessMessage(Message message, Session session)
          This method may be overridden in order to apply pre-processing to the message as soon as it arrives.
 void setAcknowledgementMode(int acknowledgementMode)
           
 void setCacheJmsSessions(boolean cacheJmsSessions)
           
 void setClientId(String clientId)
           
protected  void setConnection(Connection connection)
           
 void setConnectionFactory(ConnectionFactory connectionFactory)
           
 void setConnectionFactoryClass(String connectionFactoryClass)
           
 void setConnectionFactoryJndiName(String connectionFactoryJndiName)
           
 void setConnectionFactoryProperties(Map connectionFactoryProperties)
           
 void setDurable(boolean durable)
           
 void setEagerConsumer(boolean eagerConsumer)
          A value of true will create a consumer on connect, in contrast to lazy instantiation in the poll loop.
 void setForceJndiDestinations(boolean forceJndiDestinations)
           
 void setHonorQosHeaders(boolean honorQosHeaders)
          Sets honorQosHeaders property, which determines whether JmsMessageDispatcher should honor incoming message's QoS headers (JMSPriority, JMSDeliveryMode).
 void setJmsSupport(JmsSupport jmsSupport)
           
 void setJndiContext(Context jndiContext)
           
 void setJndiDestinations(boolean jndiDestinations)
           
 void setJndiInitialFactory(String jndiInitialFactory)
           
 void setJndiProviderProperties(Map jndiProviderProperties)
           
 void setJndiProviderUrl(String jndiProviderUrl)
           
 void setMaxRedelivery(int maxRedelivery)
           
 void setNoLocal(boolean noLocal)
           
 void setPassword(String password)
           
 void setPersistentDelivery(boolean persistentDelivery)
           
 void setRecoverJmsConnections(boolean recover)
           
 void setRedeliveryHandler(String redeliveryHandler)
           
 void setSpecification(String specification)
           
 void setTopicResolver(JmsTopicResolver topicResolver)
          Setter for property 'topicResolver'.
 void setUsername(String username)
           
 boolean supportsProperty(String property)
          This method may be overridden in case a certain JMS implementation does not support all the standard JMS properties.
 
Methods inherited from class org.mule.providers.AbstractConnector
checkDisposed, connect, createReceiver, destroyReceiver, disconnect, dispatch, dispose, disposeDispatchers, disposeReceivers, disposeWorkManagers, exceptionThrown, fireNotification, getConnectEventId, getConnectionDescription, getConnectionStrategy, getDefaultInboundTransformer, getDefaultOutboundTransformer, getDefaultResponseTransformer, getDispatcherFactory, getDispatcherThreadingProfile, getDispatcherWorkManager, getExceptionListener, getMaxDispatchersActive, getName, getNumberOfConcurrentTransactedReceivers, getOutputStream, getReceiver, getReceivers, getReceivers, getReceiverThreadingProfile, getReceiverWorkManager, getScheduler, getServiceDescriptor, getServiceOverrides, getSessionHandler, getStreamMessageAdapter, getSupportedProtocols, handleException, handleWorkException, initFromServiceDescriptor, initialise, initialiseFromUrl, isConnected, isCreateMultipleTransactedReceivers, isDisposed, isDisposing, isEnableMessageEvents, isStarted, lookupReceiver, receive, receive, registerListener, registerSupportedProtocol, registerSupportedProtocolWithoutPrefix, send, setConnectionStrategy, setCreateMultipleTransactedReceivers, setDefaultInboundTransformer, setDefaultOutboundTransformer, setDefaultResponseTransformer, setDispatcherFactory, setDispatcherThreadingProfile, setEnableMessageEvents, setExceptionListener, setMaxDispatchersActive, setName, setNumberOfConcurrentTransactedReceivers, setReceiverThreadingProfile, setServiceOverrides, setSessionHandler, setSupportedProtocols, startConnector, stopConnector, supportsProtocol, toString, unregisterListener, unregisterSupportedProtocol, workAccepted, workCompleted, workRejected, workStarted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

username

public String username

password

public String password
Constructor Detail

JmsConnector

public JmsConnector()
Method Detail

doInitialise

protected void doInitialise()
                     throws InitialisationException
Specified by:
doInitialise in class AbstractConnector
Throws:
InitialisationException

doDispose

protected void doDispose()
Description copied from class: AbstractConnector
Template method to perform any work when destroying the connectoe

Specified by:
doDispose in class AbstractConnector

initJndiContext

protected void initJndiContext()
                        throws NamingException,
                               InitialisationException
Throws:
NamingException
InitialisationException

setConnection

protected void setConnection(Connection connection)

createConnectionFactory

protected ConnectionFactory createConnectionFactory()
                                             throws InitialisationException,
                                                    NamingException
Throws:
InitialisationException
NamingException

createConnection

protected Connection createConnection()
                               throws NamingException,
                                      JMSException,
                                      InitialisationException
Throws:
NamingException
JMSException
InitialisationException

doConnect

protected void doConnect()
                  throws ConnectException
Description copied from class: AbstractConnector
Template method where any connections should be made for the connector

Specified by:
doConnect in class AbstractConnector
Throws:
ConnectException

applyVendorSpecificConnectionFactoryProperties

protected void applyVendorSpecificConnectionFactoryProperties()

doDisconnect

protected void doDisconnect()
                     throws ConnectException
Description copied from class: AbstractConnector
Template method where any connected resources used by the connector should be disconnected

Specified by:
doDisconnect in class AbstractConnector
Throws:
ConnectException

getMessageAdapter

public UMOMessageAdapter getMessageAdapter(Object message)
                                    throws MessagingException
Description copied from class: AbstractConnector
Gets a UMOMessageAdapter for the endpoint for the given message (data)

Specified by:
getMessageAdapter in interface UMOConnector
Overrides:
getMessageAdapter in class AbstractConnector
Parameters:
message - the data with which to initialise the UMOMessageAdapter
Returns:
the UMOMessageAdapter for the endpoint
Throws:
MessagingException - if the message parameter is not supported
See Also:
UMOMessageAdapter

getReceiverKey

protected Object getReceiverKey(UMOComponent component,
                                UMOEndpoint endpoint)
Description copied from class: AbstractConnector
The method determines the key used to store the receiver against.

Overrides:
getReceiverKey in class AbstractConnector
Parameters:
component - the component for which the endpoint is being registered
endpoint - the endpoint being registered for the component
Returns:
the key to store the newly created receiver against

getSessionFromTransaction

public Session getSessionFromTransaction()

getSession

public Session getSession(UMOImmutableEndpoint endpoint)
                   throws JMSException
Throws:
JMSException

getSession

public Session getSession(boolean transacted,
                          boolean topic)
                   throws JMSException
Throws:
JMSException

doStart

protected void doStart()
                throws UMOException
Description copied from class: AbstractConnector
Template method to perform any work when starting the connectoe

Specified by:
doStart in class AbstractConnector
Throws:
UMOException - if the method fails

doStop

protected void doStop()
               throws UMOException
Description copied from class: AbstractConnector
Template method to perform any work when stopping the connectoe

Specified by:
doStop in class AbstractConnector
Throws:
UMOException - if the method fails

getProtocol

public String getProtocol()
Specified by:
getProtocol in interface UMOConnector
Returns:
the primary protocol name for endpoints of this connector

getAcknowledgementMode

public int getAcknowledgementMode()
Returns:
Returns the acknowledgeMode.

setAcknowledgementMode

public void setAcknowledgementMode(int acknowledgementMode)
Parameters:
acknowledgementMode - The acknowledgementMode to set.

getConnectionFactoryJndiName

public String getConnectionFactoryJndiName()
Returns:
Returns the connectionFactoryJndiName.

setConnectionFactoryJndiName

public void setConnectionFactoryJndiName(String connectionFactoryJndiName)
Parameters:
connectionFactoryJndiName - The connectionFactoryJndiName to set.

isDurable

public boolean isDurable()
Returns:
Returns the durable.

setDurable

public void setDurable(boolean durable)
Parameters:
durable - The durable to set.

isNoLocal

public boolean isNoLocal()
Returns:
Returns the noLocal.

setNoLocal

public void setNoLocal(boolean noLocal)
Parameters:
noLocal - The noLocal to set.

isPersistentDelivery

public boolean isPersistentDelivery()
Returns:
Returns the persistentDelivery.

setPersistentDelivery

public void setPersistentDelivery(boolean persistentDelivery)
Parameters:
persistentDelivery - The persistentDelivery to set.

setHonorQosHeaders

public void setHonorQosHeaders(boolean honorQosHeaders)
Sets honorQosHeaders property, which determines whether JmsMessageDispatcher should honor incoming message's QoS headers (JMSPriority, JMSDeliveryMode).

Parameters:
honorQosHeaders - true if JmsMessageDispatcher should honor incoming message's QoS headers; otherwise false Default is false, meaning that connector settings will override message headers.

isHonorQosHeaders

public boolean isHonorQosHeaders()
Gets the value of honorQosHeaders property.

Returns:
true if JmsMessageDispatcher should honor incoming message's QoS headers; otherwise false Default is false, meaning that connector settings will override message headers.

getJndiProviderProperties

public Map getJndiProviderProperties()
Returns:
Returns the JNDI providerProperties.
Since:
1.1

setJndiProviderProperties

public void setJndiProviderProperties(Map jndiProviderProperties)
Parameters:
jndiProviderProperties - The JNDI providerProperties to set.
Since:
1.1

getConnectionFactoryProperties

public Map getConnectionFactoryProperties()
Returns:
Returns underlying connection factory properties.

setConnectionFactoryProperties

public void setConnectionFactoryProperties(Map connectionFactoryProperties)
Parameters:
connectionFactoryProperties - properties to be set on the underlying ConnectionFactory.

getJndiInitialFactory

public String getJndiInitialFactory()

setJndiInitialFactory

public void setJndiInitialFactory(String jndiInitialFactory)

getJndiProviderUrl

public String getJndiProviderUrl()

setJndiProviderUrl

public void setJndiProviderUrl(String jndiProviderUrl)

getConnectionFactory

public ConnectionFactory getConnectionFactory()

setConnectionFactory

public void setConnectionFactory(ConnectionFactory connectionFactory)

getConnectionFactoryClass

public String getConnectionFactoryClass()

setConnectionFactoryClass

public void setConnectionFactoryClass(String connectionFactoryClass)

getJmsSupport

public JmsSupport getJmsSupport()

setJmsSupport

public void setJmsSupport(JmsSupport jmsSupport)

getSpecification

public String getSpecification()

setSpecification

public void setSpecification(String specification)

isJndiDestinations

public boolean isJndiDestinations()

setJndiDestinations

public void setJndiDestinations(boolean jndiDestinations)

isForceJndiDestinations

public boolean isForceJndiDestinations()

setForceJndiDestinations

public void setForceJndiDestinations(boolean forceJndiDestinations)

getJndiContext

public Context getJndiContext()

setJndiContext

public void setJndiContext(Context jndiContext)

setRecoverJmsConnections

public void setRecoverJmsConnections(boolean recover)

isRecoverJmsConnections

public boolean isRecoverJmsConnections()

createRedeliveryHandler

protected RedeliveryHandler createRedeliveryHandler()
                                             throws IllegalAccessException,
                                                    NoSuchMethodException,
                                                    InvocationTargetException,
                                                    InstantiationException,
                                                    ClassNotFoundException
Throws:
IllegalAccessException
NoSuchMethodException
InvocationTargetException
InstantiationException
ClassNotFoundException

getReplyToHandler

public ReplyToHandler getReplyToHandler()
Description copied from class: AbstractConnector
Getter for property 'replyToHandler'.

Overrides:
getReplyToHandler in class AbstractConnector
Returns:
Value for property 'replyToHandler'.

getUsername

public String getUsername()

setUsername

public void setUsername(String username)

getPassword

public String getPassword()

setPassword

public void setPassword(String password)

getConnection

public Connection getConnection()
Returns:
Returns the connection.

getClientId

public String getClientId()

setClientId

public void setClientId(String clientId)

getMaxRedelivery

public int getMaxRedelivery()

setMaxRedelivery

public void setMaxRedelivery(int maxRedelivery)

getRedeliveryHandler

public String getRedeliveryHandler()

setRedeliveryHandler

public void setRedeliveryHandler(String redeliveryHandler)

isRemoteSyncEnabled

public boolean isRemoteSyncEnabled()
Description copied from class: AbstractConnector

Specified by:
isRemoteSyncEnabled in interface UMOConnector
Overrides:
isRemoteSyncEnabled in class AbstractConnector

getTopicResolver

public JmsTopicResolver getTopicResolver()
Getter for property 'topicResolver'.

Returns:
Value for property 'topicResolver'.

setTopicResolver

public void setTopicResolver(JmsTopicResolver topicResolver)
Setter for property 'topicResolver'.

Parameters:
topicResolver - Value to set for property 'topicResolver'.

isEagerConsumer

public boolean isEagerConsumer()
Getter for property 'eagerConsumer'. Default is true.

Returns:
Value for property 'eagerConsumer'.
See Also:
eagerConsumer

setEagerConsumer

public void setEagerConsumer(boolean eagerConsumer)
A value of true will create a consumer on connect, in contrast to lazy instantiation in the poll loop. This setting very much depends on the JMS vendor. Affects transactional receivers, typical symptoms are:

Parameters:
eagerConsumer - Value to set for property 'eagerConsumer'.
See Also:
eagerConsumer, XaTransactedJmsMessageReceiver

onNotification

public void onNotification(UMOServerNotification notification)
Specified by:
onNotification in interface UMOServerNotificationListener

isCacheJmsSessions

public boolean isCacheJmsSessions()

setCacheJmsSessions

public void setCacheJmsSessions(boolean cacheJmsSessions)

supportsProperty

public boolean supportsProperty(String property)
This method may be overridden in case a certain JMS implementation does not support all the standard JMS properties.


preProcessMessage

public Message preProcessMessage(Message message,
                                 Session session)
                          throws Exception
This method may be overridden in order to apply pre-processing to the message as soon as it arrives.

Parameters:
message - - the incoming message
session - - the JMS session
Returns:
the preprocessed message
Throws:
Exception

close

public void close(MessageProducer producer)
           throws JMSException
Closes the MessageProducer

Parameters:
producer -
Throws:
JMSException

closeQuietly

public void closeQuietly(MessageProducer producer)
Closes the MessageProducer without throwing an exception (an error message is logged instead).

Parameters:
producer -

close

public void close(MessageConsumer consumer)
           throws JMSException
Closes the MessageConsumer

Parameters:
consumer -
Throws:
JMSException

closeQuietly

public void closeQuietly(MessageConsumer consumer)
Closes the MessageConsumer without throwing an exception (an error message is logged instead).

Parameters:
consumer -

close

public void close(Session session)
           throws JMSException
Closes the Session

Parameters:
session -
Throws:
JMSException

closeQuietly

public void closeQuietly(Session session)
Closes the Session without throwing an exception (an error message is logged instead).

Parameters:
session -

close

public void close(TemporaryQueue tempQueue)
           throws JMSException
Closes the TemporaryQueue

Parameters:
tempQueue -
Throws:
JMSException

closeQuietly

public void closeQuietly(TemporaryQueue tempQueue)
Closes the TemporaryQueue without throwing an exception (an error message is logged instead).

Parameters:
tempQueue -

close

public void close(TemporaryTopic tempTopic)
           throws JMSException
Closes the TemporaryTopic

Parameters:
tempTopic -
Throws:
JMSException

closeQuietly

public void closeQuietly(TemporaryTopic tempTopic)
Closes the TemporaryTopic without throwing an exception (an error message is logged instead).

Parameters:
tempTopic -


Copyright © 2003-2008 MuleSource, Inc.. All Rights Reserved.