org.apache.servicemix.jbi.nmr.flow.jms
Class AbstractJMSFlow

java.lang.Object
  extended by org.apache.servicemix.jbi.management.BaseLifeCycle
      extended by org.apache.servicemix.jbi.nmr.flow.AbstractFlow
          extended by org.apache.servicemix.jbi.nmr.flow.jms.AbstractJMSFlow
All Implemented Interfaces:
javax.jbi.management.LifeCycleMBean, MessageListener, MBeanInfoProvider, Flow
Direct Known Subclasses:
JMSFlow, JMSFlowTibco

public abstract class AbstractJMSFlow
extends AbstractFlow
implements MessageListener

Use for message routing among a network of containers. All routing/registration happens automatically.


Field Summary
protected  Connection connection
           
protected  ConnectionFactory connectionFactory
           
protected  MessageConsumer monitorMessageConsumer
           
protected  AtomicBoolean started
           
protected  Set<String> subscriberSet
           
 
Fields inherited from class org.apache.servicemix.jbi.nmr.flow.AbstractFlow
broker, executorFactory, log
 
Fields inherited from class org.apache.servicemix.jbi.management.BaseLifeCycle
currentState, INITIALIZED, listener
 
Fields inherited from interface javax.jbi.management.LifeCycleMBean
SHUTDOWN, STARTED, STOPPED, UNKNOWN
 
Constructor Summary
AbstractJMSFlow()
           
 
Method Summary
protected  void addClusterNode(String connectionId)
          A new cluster node is announced.
protected  void broadcast(EndpointEvent event)
           
 boolean canHandle(javax.jbi.messaging.MessageExchange me)
          Check if the flow can support the requested QoS for this exchange
protected abstract  ConnectionFactory createConnectionFactoryFromUrl(String url)
           
 void doRouting(MessageExchangeImpl me)
          Distribute an ExchangePacket
protected  void doSend(MessageExchangeImpl me)
          Distribute an ExchangePacket
 String getBroadcastDestinationName()
           
 ConnectionFactory getConnectionFactory()
           
 String getDescription()
          The type of Flow
 String getJmsURL()
           
 String getPassword()
           
 String getUserName()
           
 void init(Broker broker)
          Initialize the Region
 int numberInNetwork()
          useful for testing
 void onComponentStarted(ComponentEvent event)
           
 void onComponentStopped(ComponentEvent event)
           
protected abstract  void onConsumerMonitorMessage(Message message)
           
 void onInternalEndpointRegistered(EndpointEvent event, boolean broadcast)
           
 void onInternalEndpointUnregistered(EndpointEvent event, boolean broadcast)
           
 void onMessage(Message message)
          MessageListener implementation
 void onRemoteEndpointRegistered(EndpointEvent event)
           
 void onRemoteEndpointUnregistered(EndpointEvent event)
           
protected  void removeAllPackets(String containerName)
           
protected  void removeClusterNode(String connectionId)
          A cluster node leaves the cluster.
 void setBroadcastDestinationName(String broadcastDestinationName)
           
 void setConnectionFactory(ConnectionFactory connectionFactory)
           
 void setJmsURL(String jmsURL)
           
 void setPassword(String password)
           
 void setUserName(String userName)
           
 void shutDown()
          shutDown the flow
 void start()
          start the flow
abstract  void startConsumerMonitor()
           
 void stop()
          stop the flow
 void stopConsumerMonitor()
           
 
Methods inherited from class org.apache.servicemix.jbi.nmr.flow.AbstractFlow
getAttributeInfos, getBroker, getExecutorFactory, getName, getType, isClustered, isPersistent, isSynchronous, isTransacted, resume, send, setName, suspend
 
Methods inherited from class org.apache.servicemix.jbi.management.BaseLifeCycle
firePropertyChanged, getCurrentState, getObjectToManage, getOperationInfos, getSubType, init, isInitialized, isShutDown, isStarted, isStopped, isUnknown, setCurrentState, setPropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.jbi.management.LifeCycleMBean
getCurrentState
 

Field Detail

connectionFactory

protected ConnectionFactory connectionFactory

connection

protected Connection connection

started

protected AtomicBoolean started

monitorMessageConsumer

protected MessageConsumer monitorMessageConsumer

subscriberSet

protected Set<String> subscriberSet
Constructor Detail

AbstractJMSFlow

public AbstractJMSFlow()
Method Detail

getDescription

public String getDescription()
The type of Flow

Specified by:
getDescription in interface MBeanInfoProvider
Specified by:
getDescription in interface Flow
Returns:
the type

getPassword

public String getPassword()
Returns:
Returns the password.

setPassword

public void setPassword(String password)
Parameters:
password - The password to set.

getUserName

public String getUserName()
Returns:
Returns the userName.

setUserName

public void setUserName(String userName)
Parameters:
userName - The userName to set.

getConnectionFactory

public ConnectionFactory getConnectionFactory()
Returns:
Returns the connectionFactory.

setConnectionFactory

public void setConnectionFactory(ConnectionFactory connectionFactory)
Parameters:
connectionFactory - The connectionFactory to set.

getBroadcastDestinationName

public String getBroadcastDestinationName()
Returns:
Returns the broadcastDestinationName.

setBroadcastDestinationName

public void setBroadcastDestinationName(String broadcastDestinationName)
Parameters:
broadcastDestinationName - The broadcastDestinationName to set.

canHandle

public boolean canHandle(javax.jbi.messaging.MessageExchange me)
Check if the flow can support the requested QoS for this exchange

Specified by:
canHandle in interface Flow
Parameters:
me - the exchange to check
Returns:
true if this flow can handle the given exchange

init

public void init(Broker broker)
          throws javax.jbi.JBIException
Initialize the Region

Specified by:
init in interface Flow
Overrides:
init in class AbstractFlow
Parameters:
broker -
Throws:
javax.jbi.JBIException

createConnectionFactoryFromUrl

protected abstract ConnectionFactory createConnectionFactoryFromUrl(String url)

onConsumerMonitorMessage

protected abstract void onConsumerMonitorMessage(Message message)

startConsumerMonitor

public abstract void startConsumerMonitor()
                                   throws JMSException
Throws:
JMSException

stopConsumerMonitor

public void stopConsumerMonitor()
                         throws JMSException
Throws:
JMSException

start

public void start()
           throws javax.jbi.JBIException
start the flow

Specified by:
start in interface javax.jbi.management.LifeCycleMBean
Overrides:
start in class AbstractFlow
Throws:
javax.jbi.JBIException

stop

public void stop()
          throws javax.jbi.JBIException
stop the flow

Specified by:
stop in interface javax.jbi.management.LifeCycleMBean
Overrides:
stop in class AbstractFlow
Throws:
javax.jbi.JBIException

shutDown

public void shutDown()
              throws javax.jbi.JBIException
Description copied from class: AbstractFlow
shutDown the flow

Specified by:
shutDown in interface javax.jbi.management.LifeCycleMBean
Overrides:
shutDown in class AbstractFlow
Throws:
javax.jbi.JBIException - if the item fails to shut down.

numberInNetwork

public int numberInNetwork()
useful for testing

Returns:
number of containers in the network

onInternalEndpointRegistered

public void onInternalEndpointRegistered(EndpointEvent event,
                                         boolean broadcast)

onInternalEndpointUnregistered

public void onInternalEndpointUnregistered(EndpointEvent event,
                                           boolean broadcast)

broadcast

protected void broadcast(EndpointEvent event)
                  throws Exception
Throws:
Exception

onComponentStarted

public void onComponentStarted(ComponentEvent event)

onComponentStopped

public void onComponentStopped(ComponentEvent event)

onRemoteEndpointRegistered

public void onRemoteEndpointRegistered(EndpointEvent event)

onRemoteEndpointUnregistered

public void onRemoteEndpointUnregistered(EndpointEvent event)

doSend

protected void doSend(MessageExchangeImpl me)
               throws javax.jbi.messaging.MessagingException
Distribute an ExchangePacket

Specified by:
doSend in class AbstractFlow
Parameters:
me -
Throws:
javax.jbi.messaging.MessagingException

doRouting

public void doRouting(MessageExchangeImpl me)
               throws javax.jbi.messaging.MessagingException
Distribute an ExchangePacket

Overrides:
doRouting in class AbstractFlow
Parameters:
me -
Throws:
javax.jbi.messaging.MessagingException

onMessage

public void onMessage(Message message)
MessageListener implementation

Specified by:
onMessage in interface MessageListener
Parameters:
message -

addClusterNode

protected void addClusterNode(String connectionId)
A new cluster node is announced. Add this node to the subscriber set and send all our local internal endpoints to this node.

Parameters:
connectionId -

removeClusterNode

protected void removeClusterNode(String connectionId)
A cluster node leaves the cluster. Remove this node from the subscriber set and remove all packets waiting to be delivered to this node

Parameters:
connectionId -

removeAllPackets

protected void removeAllPackets(String containerName)

getJmsURL

public String getJmsURL()

setJmsURL

public void setJmsURL(String jmsURL)


Copyright © 2005-2010 The Apache Software Foundation. All Rights Reserved.