User: chirino
Date: 01/09/25 22:02:28
Modified: src/main/org/jboss/mq/server JMSServer.java
Log:
Several modification to support the client connection sending ping messages
to the server and the server sending back pong messages. These messages
are used to determine if the connection has gone down.
This fixes the bug with the ExceptionListner not being notified of
the server failing when the client is only receiving messages.
Revision Changes Path
1.8 +175 -141 jbossmq/src/main/org/jboss/mq/server/JMSServer.java
Index: JMSServer.java
===================================================================
RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/server/JMSServer.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- JMSServer.java 2001/09/13 01:53:13 1.7
+++ JMSServer.java 2001/09/26 05:02:28 1.8
@@ -28,23 +28,28 @@
import org.jboss.mq.pm.*;
-
import org.jboss.mq.xml.XElement;
/**
- * This class implements the JMS provider
+ * This class implements the JMS provider
*
- * @author Norbert Lataille ([EMAIL PROTECTED])
- * @author Hiram Chirino ([EMAIL PROTECTED])
- * @author David Maplesden ([EMAIL PROTECTED])
- * @version $Revision: 1.7 $
+ * @author Norbert Lataille ([EMAIL PROTECTED])
+ * @author Hiram Chirino ([EMAIL PROTECTED])
+ * @author David Maplesden ([EMAIL PROTECTED])
+ * @version $Revision: 1.8 $
*/
public class JMSServer
{
+ /**
+ * Description of the Field
+ */
public final static String JBOSS_VESION = "JBossMQ ver. 0.9b";
//provide static reference to the server for JVMIL to work.
//It would be nice if there was another way of doing this.
+ /**
+ * Description of the Field
+ */
protected static JMSServer theInstance = null;
static org.apache.log4j.Category cat =
org.apache.log4j.Category.getInstance(JMSServer.class);
@@ -54,8 +59,14 @@
/////////////////////////////////////////////////////////////////////
//messages pending for a Destination ( HashMap of JMSServerQueue objects )
+ /**
+ * Description of the Field
+ */
public HashMap destinations = new HashMap();
//Thread group for server side threads.
+ /**
+ * Description of the Field
+ */
public ThreadGroup threadGroup = new ThreadGroup("JBossMQ Server Threads");
//The list of ClientConsumers hased by ConnectionTokens
@@ -75,61 +86,65 @@
private Object stateLock = new Object();
/**
- * <code>true</code> when the server is running. <code>false</code> when the
- * server should stop running.
+ * <code>true</code> when the server is running. <code>false</code> when the
+ * server should stop running.
*/
private boolean alive = true;
/**
- * Because there can be a delay between killing the JMS service and the
- * service actually dying, this field is used to tell external classes that
- * that server has actually stopped.
+ * Because there can be a delay between killing the JMS service and the
+ * service actually dying, this field is used to tell external classes that
+ * that server has actually stopped.
*/
private boolean stopped = true;
/////////////////////////////////////////////////////////////////////
// Constructors
/////////////////////////////////////////////////////////////////////
+ /**
+ * Constructor for the JMSServer object
+ */
protected JMSServer()
{
}
+ /**
+ * Gets the Instance of the JMSServer. Will return null if called before the
+ * initServer method has been called.
+ *
+ * @return The instance value
+ */
+ public static JMSServer getInstance()
+ {
+ return theInstance;
+ }
+
/**
- * Creates a new instance of the JMSServer if one has not already been created.
+ * Creates a new instance of the JMSServer if one has not already been
+ * created.
*/
public static void initServer()
{
- if(JMSServer.theInstance == null)
+ if (JMSServer.theInstance == null)
{
JMSServer.theInstance = new JMSServer();
}
}
-
+
/**
- * Destroys the current instance of the JMSServer if one exists.
+ * Destroys the current instance of the JMSServer if one exists.
*/
public static void destroyServer()
{
JMSServer.theInstance = null;
}
-
- /**
- * Gets the Instance of the JMSServer. Will return null if called before the
- * initServer method has been called.
- *
- * @return The instance value
- */
- public static JMSServer getInstance()
- {
- return theInstance;
- }
/**
- * Sets the Enabled attribute of the JMSServer object
+ * Sets the Enabled attribute of the JMSServer object
*
- * @param dc The new Enabled value
- * @param enabled The new Enabled value
- * @exception JMSException Description of Exception
+ * @param dc The new Enabled value
+ * @param enabled The new Enabled value
+ * @exception JMSException Description of Exception
*/
public void setEnabled(ConnectionToken dc, boolean enabled) throws JMSException
{
@@ -138,11 +153,10 @@
}
-
/**
- * Sets the StateManager attribute of the JMSServer object
+ * Sets the StateManager attribute of the JMSServer object
*
- * @param newStateManager The new StateManager value
+ * @param newStateManager The new StateManager value
*/
public void setStateManager(StateManager newStateManager)
{
@@ -150,9 +164,9 @@
}
/**
- * Sets the PersistenceManager attribute of the JMSServer object
+ * Sets the PersistenceManager attribute of the JMSServer object
*
- * @param newPersistenceManager The new PersistenceManager value
+ * @param newPersistenceManager The new PersistenceManager value
*/
public void setPersistenceManager(org.jboss.mq.pm.PersistenceManager
newPersistenceManager)
{
@@ -164,10 +178,10 @@
/////////////////////////////////////////////////////////////////////
/**
- * Returns <code>false</code> if the JMS server is currently running and
- * handling requests, <code>true</code> otherwise.
+ * Returns <code>false</code> if the JMS server is currently running and
+ * handling requests, <code>true</code> otherwise.
*
- * @return <code>false</code> if the JMS server is currently running and
+ * @return <code>false</code> if the JMS server is currently running and
* handling requests, <code>true</code> otherwise.
*/
public boolean isStopped()
@@ -180,9 +194,9 @@
//Get a new ClientID for a connection
/**
- * Gets the ID attribute of the JMSServer object
+ * Gets the ID attribute of the JMSServer object
*
- * @return The ID value
+ * @return The ID value
*/
public String getID()
{
@@ -208,11 +222,11 @@
}
/**
- * Gets the TemporaryTopic attribute of the JMSServer object
+ * Gets the TemporaryTopic attribute of the JMSServer object
*
- * @param dc Description of Parameter
- * @return The TemporaryTopic value
- * @exception JMSException Description of Exception
+ * @param dc Description of Parameter
+ * @return The TemporaryTopic value
+ * @exception JMSException Description of Exception
*/
public synchronized TemporaryTopic getTemporaryTopic(ConnectionToken dc) throws
JMSException
{
@@ -233,11 +247,11 @@
}
/**
- * Gets the TemporaryQueue attribute of the JMSServer object
+ * Gets the TemporaryQueue attribute of the JMSServer object
*
- * @param dc Description of Parameter
- * @return The TemporaryQueue value
- * @exception JMSException Description of Exception
+ * @param dc Description of Parameter
+ * @return The TemporaryQueue value
+ * @exception JMSException Description of Exception
*/
public synchronized TemporaryQueue getTemporaryQueue(ConnectionToken dc) throws
JMSException
{
@@ -261,11 +275,11 @@
// Gets the ClientConsumers mapped the the connection
// If the connection is not mapped, a new ClientConsumer is created
/**
- * Gets the ClientConsumer attribute of the JMSServer object
+ * Gets the ClientConsumer attribute of the JMSServer object
*
- * @param dc Description of Parameter
- * @return The ClientConsumer value
- * @exception JMSException Description of Exception
+ * @param dc Description of Parameter
+ * @return The ClientConsumer value
+ * @exception JMSException Description of Exception
*/
public ClientConsumer getClientConsumer(ConnectionToken dc) throws JMSException
{
@@ -279,10 +293,10 @@
}
/**
- * Gets the JMSDestination attribute of the JMSServer object
+ * Gets the JMSDestination attribute of the JMSServer object
*
- * @param dest Description of Parameter
- * @return The JMSDestination value
+ * @param dest Description of Parameter
+ * @return The JMSDestination value
*/
public JMSDestination getJMSDestination(SpyDestination dest)
{
@@ -290,9 +304,9 @@
}
/**
- * Gets the StateManager attribute of the JMSServer object
+ * Gets the StateManager attribute of the JMSServer object
*
- * @return The StateManager value
+ * @return The StateManager value
*/
public StateManager getStateManager()
{
@@ -300,9 +314,9 @@
}
/**
- * Gets the PersistenceManager attribute of the JMSServer object
+ * Gets the PersistenceManager attribute of the JMSServer object
*
- * @return The PersistenceManager value
+ * @return The PersistenceManager value
*/
public org.jboss.mq.pm.PersistenceManager getPersistenceManager()
{
@@ -310,7 +324,7 @@
}
/**
- * #Description of the Method
+ * #Description of the Method
*/
public void startServer()
{
@@ -321,7 +335,7 @@
}
/**
- * #Description of the Method
+ * #Description of the Method
*/
public void stopServer()
{
@@ -342,10 +356,10 @@
}
/**
- * #Description of the Method
+ * #Description of the Method
*
- * @param ID Description of Parameter
- * @exception JMSException Description of Exception
+ * @param ID Description of Parameter
+ * @exception JMSException Description of Exception
*/
public void checkID(String ID) throws JMSException
{
@@ -354,11 +368,11 @@
//A connection has sent a new message
/**
- * Adds a feature to the Message attribute of the JMSServer object
+ * Adds a feature to the Message attribute of the JMSServer object
*
- * @param dc The feature to be added to the Message attribute
- * @param val The feature to be added to the Message attribute
- * @exception JMSException Description of Exception
+ * @param dc The feature to be added to the Message attribute
+ * @param val The feature to be added to the Message attribute
+ * @exception JMSException Description of Exception
*/
public void addMessage(ConnectionToken dc, SpyMessage val) throws JMSException
{
@@ -367,12 +381,12 @@
//A connection has sent a new message
/**
- * Adds a feature to the Message attribute of the JMSServer object
+ * Adds a feature to the Message attribute of the JMSServer object
*
- * @param dc The feature to be added to the Message attribute
- * @param val The feature to be added to the Message attribute
- * @param txId The feature to be added to the Message attribute
- * @exception JMSException Description of Exception
+ * @param dc The feature to be added to the Message attribute
+ * @param val The feature to be added to the Message attribute
+ * @param txId The feature to be added to the Message attribute
+ * @exception JMSException Description of Exception
*/
public void addMessage(ConnectionToken dc, SpyMessage val, Tx txId) throws
JMSException
{
@@ -388,11 +402,11 @@
}
/**
- * The following function performs a Unit Of Work.
+ * The following function performs a Unit Of Work.
*
- * @param dc Description of Parameter
- * @param t Description of Parameter
- * @exception JMSException Description of Exception
+ * @param dc Description of Parameter
+ * @param t Description of Parameter
+ * @exception JMSException Description of Exception
*/
public void transact(ConnectionToken dc, TransactionRequest t) throws
JMSException
{
@@ -484,11 +498,11 @@
//Sent by a client to Ack or Nack a message.
/**
- * #Description of the Method
+ * #Description of the Method
*
- * @param dc Description of Parameter
- * @param item Description of Parameter
- * @exception JMSException Description of Exception
+ * @param dc Description of Parameter
+ * @param item Description of Parameter
+ * @exception JMSException Description of Exception
*/
public void acknowledge(ConnectionToken dc, AcknowledgementRequest item) throws
JMSException
{
@@ -497,12 +511,12 @@
//Sent by a client to Ack or Nack a message.
/**
- * #Description of the Method
+ * #Description of the Method
*
- * @param dc Description of Parameter
- * @param item Description of Parameter
- * @param txId Description of Parameter
- * @exception JMSException Description of Exception
+ * @param dc Description of Parameter
+ * @param item Description of Parameter
+ * @param txId Description of Parameter
+ * @exception JMSException Description of Exception
*/
public void acknowledge(ConnectionToken dc, AcknowledgementRequest item, Tx
txId) throws JMSException
{
@@ -514,10 +528,10 @@
//A connection is closing [error or notification]
/**
- * #Description of the Method
+ * #Description of the Method
*
- * @param dc Description of Parameter
- * @exception JMSException Description of Exception
+ * @param dc Description of Parameter
+ * @exception JMSException Description of Exception
*/
public synchronized void connectionClosing(ConnectionToken dc) throws
JMSException
{
@@ -560,10 +574,10 @@
}
/**
- * #Description of the Method
+ * #Description of the Method
*
- * @param dc Description of Parameter
- * @exception JMSException Description of Exception
+ * @param dc Description of Parameter
+ * @exception JMSException Description of Exception
*/
public void connectionFailure(ConnectionToken dc) throws JMSException
{
@@ -577,11 +591,11 @@
//A connection object wants to subscribe to a Destination
/**
- * #Description of the Method
+ * #Description of the Method
*
- * @param dc Description of Parameter
- * @param sub Description of Parameter
- * @exception JMSException Description of Exception
+ * @param dc Description of Parameter
+ * @param sub Description of Parameter
+ * @exception JMSException Description of Exception
*/
public void subscribe(ConnectionToken dc, Subscription sub) throws JMSException
{
@@ -600,11 +614,11 @@
}
/**
- * #Description of the Method
+ * #Description of the Method
*
- * @param dc Description of Parameter
- * @param subscriptionId Description of Parameter
- * @exception JMSException Description of Exception
+ * @param dc Description of Parameter
+ * @param subscriptionId Description of Parameter
+ * @exception JMSException Description of Exception
*/
public void unsubscribe(ConnectionToken dc, int subscriptionId) throws
JMSException
{
@@ -614,10 +628,10 @@
}
/**
- * #Description of the Method
+ * #Description of the Method
*
- * @param id Description of Parameter
- * @exception JMSException Description of Exception
+ * @param id Description of Parameter
+ * @exception JMSException Description of Exception
*/
public void destroySubscription(DurableSubcriptionID id) throws JMSException
{
@@ -625,13 +639,13 @@
}
/**
- * #Description of the Method
+ * #Description of the Method
*
- * @param dc Description of Parameter
- * @param dest Description of Parameter
- * @param selector Description of Parameter
- * @return Description of the Returned Value
- * @exception JMSException Description of Exception
+ * @param dc Description of Parameter
+ * @param dest Description of Parameter
+ * @param selector Description of Parameter
+ * @return Description of the Returned Value
+ * @exception JMSException Description of Exception
*/
public SpyMessage[] browse(ConnectionToken dc, Destination dest, String
selector) throws JMSException
{
@@ -650,13 +664,13 @@
}
/**
- * #Description of the Method
+ * #Description of the Method
*
- * @param dc Description of Parameter
- * @param subscriberId Description of Parameter
- * @param wait Description of Parameter
- * @return Description of the Returned Value
- * @exception JMSException Description of Exception
+ * @param dc Description of Parameter
+ * @param subscriberId Description of Parameter
+ * @param wait Description of Parameter
+ * @return Description of the Returned Value
+ * @exception JMSException Description of Exception
*/
public SpyMessage receive(ConnectionToken dc, int subscriberId, long wait)
throws JMSException
{
@@ -665,12 +679,12 @@
}
/**
- * #Description of the Method
+ * #Description of the Method
*
- * @param dc Description of Parameter
- * @param name Description of Parameter
- * @return Description of the Returned Value
- * @exception JMSException Description of Exception
+ * @param dc Description of Parameter
+ * @param name Description of Parameter
+ * @return Description of the Returned Value
+ * @exception JMSException Description of Exception
*/
public synchronized Queue createQueue(ConnectionToken dc, String name) throws
JMSException
{
@@ -685,12 +699,12 @@
}
/**
- * #Description of the Method
+ * #Description of the Method
*
- * @param dc Description of Parameter
- * @param name Description of Parameter
- * @return Description of the Returned Value
- * @exception JMSException Description of Exception
+ * @param dc Description of Parameter
+ * @param name Description of Parameter
+ * @return Description of the Returned Value
+ * @exception JMSException Description of Exception
*/
public synchronized Topic createTopic(ConnectionToken dc, String name) throws
JMSException
{
@@ -705,10 +719,10 @@
}
/**
- * #Description of the Method
+ * #Description of the Method
*
- * @param dc Description of Parameter
- * @param dest Description of Parameter
+ * @param dc Description of Parameter
+ * @param dest Description of Parameter
*/
public synchronized void deleteTemporaryDestination(ConnectionToken dc,
SpyDestination dest)
{
@@ -724,12 +738,12 @@
}
/**
- * #Description of the Method
+ * #Description of the Method
*
- * @param userName Description of Parameter
- * @param password Description of Parameter
- * @return Description of the Returned Value
- * @exception JMSException Description of Exception
+ * @param userName Description of Parameter
+ * @param password Description of Parameter
+ * @return Description of the Returned Value
+ * @exception JMSException Description of Exception
*/
public String checkUser(String userName, String password) throws JMSException
{
@@ -738,13 +752,13 @@
// Administration calls
/**
- * Adds a feature to the Destination attribute of the JMSServer object
+ * Adds a feature to the Destination attribute of the JMSServer object
*
- * @param topic The feature to be added to the Destination
+ * @param topic The feature to be added to the Destination
* attribute
- * @param queue The feature to be added to the Destination
+ * @param queue The feature to be added to the Destination
* attribute
- * @exception JMSException Description of Exception
+ * @exception JMSException Description of Exception
*/
public void addDestination(SpyDestination topic, JMSDestination queue) throws
JMSException
{
@@ -764,9 +778,9 @@
}
/**
- * #Description of the Method
+ * #Description of the Method
*
- * @param message Description of Parameter
+ * @param message Description of Parameter
*/
public void restoreMessage(SpyMessage message)
{
@@ -780,12 +794,32 @@
}
/**
- * #Description of the Method
+ * #Description of the Method
*
- * @return Description of the Returned Value
+ * @return Description of the Returned Value
*/
public String toString()
{
return JBOSS_VESION;
+ }
+
+ /**
+ * #Description of the Method
+ *
+ * @param dc Description of Parameter
+ * @param clientTime Description of Parameter
+ * @exception JMSException Description of Exception
+ */
+ public synchronized void ping(ConnectionToken dc, long clientTime) throws
JMSException
+ {
+ try
+ {
+ cat.debug("PING");
+ dc.clientIL.pong(System.currentTimeMillis());
+ }
+ catch (Exception e)
+ {
+ throw new SpyJMSException("Could not pong", e);
+ }
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development