org.bss.esb
Class EsbRouter

java.lang.Object
  extended byorg.bss.esb.EsbRouter
All Implemented Interfaces:
javax.ejb.EnterpriseBean, javax.ejb.MessageDrivenBean, javax.jms.MessageListener, java.io.Serializable

public class EsbRouter
extends java.lang.Object
implements javax.ejb.MessageDrivenBean, javax.jms.MessageListener

This MDB is the starting point in the ESB flow. It listens for the messages on the ESB input queue and routes them to the appropriate destination. The inbound message is expected to supply some "key" as a message property. This key is used to lookup a route from the routing table. The message is then sent to that route. In case of any failures, the message is sent to either the redelivery queue, deadletter queue or error queue depending upon the type of failure. The startup configuration for ESB is specified in an XML file whose URL has to be given in the environment entry named "EnvConfigUrl" in this MDB's deployment descriptor.

Version:
1.0
Author:
Balwinder Sodhi
See Also:
EsbConfigManager, TransportHandler, Serialized Form

Field Summary
protected  javax.ejb.MessageDrivenContext ctx
           
 
Constructor Summary
EsbRouter()
           
 
Method Summary
 void ejbCreate()
          This method performs the intialization tasks for this MDB:
 void ejbRemove()
          Unregisters the EsbRouterMonitorMBean instance.
 long getHighestTime()
          Returns the timestamp of the latest message received by this MDB instance since the last call to resetTimings().
 long getLowestTime()
          Returns the timestamp of the first message received by this MDB instance since the last call to resetTimings().
 int getMessageCount()
          Returns the total number of messages received by this MDB instance since the last call to resetTimings().
 java.lang.String getRoutingTableLocation()
          Returns the URL string of the routing table xml file location.
 void onMessage(javax.jms.Message msg)
          Processes the messages received by the ESB on its configured input queue.
 void resetTimings()
          Resets the values of count, timeHigh and timeLow members.
 void setMessageDrivenContext(javax.ejb.MessageDrivenContext ctx)
           
 void setRoutingTableLocation(java.lang.String urlString)
          Sets the location URL from where the routing table xml file will be loaded.
 void updateRoutingTable()
          Updates the EsbConfigurationDocument instance of this MDB by reloading the EsbRoutingTable.xml file from the configured location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ctx

protected javax.ejb.MessageDrivenContext ctx
Constructor Detail

EsbRouter

public EsbRouter()
Method Detail

setMessageDrivenContext

public void setMessageDrivenContext(javax.ejb.MessageDrivenContext ctx)
Specified by:
setMessageDrivenContext in interface javax.ejb.MessageDrivenBean

ejbCreate

public void ejbCreate()
               throws javax.ejb.CreateException
This method performs the intialization tasks for this MDB:
 1) The config.xml is read and parsed into an XmlBean in this method.
 

2) From this XmlBean, the rest of the confiuration parameters are read.

3) The EsbConfiguration XML is read and used to initialize the EsbConfigManager instance.

4) The EsbRouterMonitorMBean is created and registered.

Throws:
javax.ejb.CreateException

ejbRemove

public void ejbRemove()
Unregisters the EsbRouterMonitorMBean instance.

Specified by:
ejbRemove in interface javax.ejb.MessageDrivenBean

onMessage

public void onMessage(javax.jms.Message msg)
Processes the messages received by the ESB on its configured input queue. Based on the routing key spepcified in the message, it tries to send the message to appropriate route. Any irrecoverable failue causes the transaction to be rolled back.

Specified by:
onMessage in interface javax.jms.MessageListener
Parameters:
msg - The input message received on the ESB's input queue.

getMessageCount

public int getMessageCount()
Returns the total number of messages received by this MDB instance since the last call to resetTimings().

Returns:
message count

getLowestTime

public long getLowestTime()
Returns the timestamp of the first message received by this MDB instance since the last call to resetTimings().


getHighestTime

public long getHighestTime()
Returns the timestamp of the latest message received by this MDB instance since the last call to resetTimings().


resetTimings

public void resetTimings()
Resets the values of count, timeHigh and timeLow members.


updateRoutingTable

public void updateRoutingTable()
                        throws javax.management.MBeanException
Updates the EsbConfigurationDocument instance of this MDB by reloading the EsbRoutingTable.xml file from the configured location. It then recreates the EsbConfigManager instance of this MDB to refltect the configuration changes found in the reloaded routing table file.

Throws:
javax.management.MBeanException

getRoutingTableLocation

public java.lang.String getRoutingTableLocation()
Returns the URL string of the routing table xml file location.

Returns:
URL string for the routing table xml file location.

setRoutingTableLocation

public void setRoutingTableLocation(java.lang.String urlString)
Sets the location URL from where the routing table xml file will be loaded.

Parameters:
urlString - URL string for the routing table xml file location.


Copyright © 2005 Balwinder Sodhi. All Rights Reserved.