while (lvIter.hasNext())
{
String lvProcessorName = (String)lvIter.next();
try
{
int lvLen = getQueueLength(lvProcessorName);
lvQueueLenMap.put(lvProcessorName, new Integer(lvLen));
}
catch (Exception lvException)
{}
}
return lvQueueLenMap;
}
/**
* Gets the number of priority queue
* @param pQueueName is the name of the message queue
* @return Returns the number of priority queue
*/
public int getMaximumPriorityQueueSize(String pQueueName) throws Exception
{
msqQueueElement lvQueue = (msqQueueElement)ivQueueTable.get(pQueueName);
// Check whether the request queue is registered or not
// if the queue is not registered, exception will be thrown
if (lvQueue == null)
throw new errQueueNotFoundException(pQueueName);
return lvQueue.getMaximumPriorityQueueSize();
}
/**
* Gets message from the message queue
* @param pQueueName is the name of the message queue
* @return Returns the message extracted from the message queue
*/
public Object getMessage(String pQueueName) throws Exception
{
msqQueueElement lvQueue = (msqQueueElement)ivQueueTable.get(pQueueName);
// Check whether the request queue is registered or not
// if the queue is not registered, exception will be thrown
if (lvQueue == null)
throw new errQueueNotFoundException(pQueueName);
return lvQueue.get();
}
/**
* Gets the current queue length of the message queue
* @param pQueueName is the name of the message queue
* @return Returns the total number of message queued in the message queues
*/
public int getQueueLength(String pQueueName) throws errQueueNotFoundException
{
msqQueueElement lvQueue = (msqQueueElement)ivQueueTable.get(pQueueName);
// Check whether the request queue is registered or not
// if the queue is not registered, exception will be thrown
if (lvQueue == null)
throw new errQueueNotFoundException(pQueueName);
return lvQueue.getQueueLength();
}
/**
* Posts the message to the destination queue
* @param pQueueName is the name of the message queue
* @param pMessage is the message that needs to be queued
*/
public void postMessage(String pQueueName, Object pMessage) throws errQueueNotFoundException
{
msqQueueElement lvQueueElement = (msqQueueElement)ivQueueTable.get(pQueueName);
if (lvQueueElement != null)
lvQueueElement.put(pMessage);
else
throw new errQueueNotFoundException(pQueueName);
}
/**
* Posts the message to the destination queue with priority
* @param pQueueName is the name of the message queue
* @param pMessage is the message that needs to be queued
* @param pPriority is the priority of the queue
*/
public void postMessage(String pQueueName, Object pMessage, int pPriority) throws errQueueNotFoundException
{
msqQueueElement lvQueueElement = (msqQueueElement)ivQueueTable.get(pQueueName);
if (lvQueueElement != null)
lvQueueElement.put(pMessage, pPriority);
else
throw new errQueueNotFoundException(pQueueName);
}
/**
* Insert the method's description here.
* Creation date: (2000/06/13 11:20:17 AM)
* @return java.lang.String
*/
public void printAllQueueLen()
{
String lvResult = "";
TreeMap lvQueueLenMap = new TreeMap(getAllQueueLen());
System.out.println(lvResult);
}
/**
* Creates a message queue with default number of priority and registers it
* @param pQueueName is the name of the message queue
*/
public synchronized void registerQueue(String pQueueName) throws errQueueSizeException, errQueueAlreadyRegisteredException
{
if (ivQueueTable.containsKey(pQueueName))
throw new errQueueAlreadyRegisteredException(pQueueName);
msqQueueElement lvQueueElement = new msqQueueElement();
ivQueueTable.put(pQueueName, lvQueueElement);
}
/**
* Creates a message queue with user defined number of priority and registers it
* @param pQueueName is the name of the message queue
* @param pPriorityQueueSize is the size of the priority queue
*/
public synchronized void registerQueue(String pQueueName, int pPriorityQueueSize) throws errQueueSizeException
{
msqQueueElement lvQueueElement = new msqQueueElement(pPriorityQueueSize);
ivQueueTable.put(pQueueName, lvQueueElement);
}
/**
* Destroys the specified message queue
* @param pQueueName is the name of the message queue
*/
public synchronized void unregisterQueue(String pQueueName)
{
if (ivQueueTable.containsKey(pQueueName))
ivQueueTable.remove(pQueueName);
}
}