org.objectweb.joram.mom.dest
Class QueueImpl

java.lang.Object
  extended byorg.objectweb.joram.mom.dest.DestinationImpl
      extended byorg.objectweb.joram.mom.dest.QueueImpl
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
BridgeQueueImpl, ClusterQueueImpl, DeadMQueueImpl

public class QueueImpl
extends DestinationImpl

The QueueImpl class implements the MOM queue behaviour, basically storing messages and delivering them upon clients requests.

See Also:
Serialized Form

Field Summary
protected  long arrivalsCounter
          Counter of messages arrivals.
protected  java.util.Hashtable consumers
          Table keeping the messages' consumers identifiers.
protected  java.util.Hashtable contexts
          Table keeping the messages' consumers contexts.
protected  java.util.Hashtable deliveredMsgs
          Table holding the delivered messages before acknowledgement.
protected  java.util.Vector messages
          Vector holding the messages before delivery.
protected  MessagePersistenceModule persistenceModule
          The persistence module used for managing the messages' persistence.
protected  boolean receiving
          true if the queue is currently receiving messages.
protected  java.util.Vector requests
          Vector holding the requests before reply or expiry.
 
Fields inherited from class org.objectweb.joram.mom.dest.DestinationImpl
adminId, clients, destId, dmqId, freeReading, freeWriting, READ, READWRITE, WRITE
 
Constructor Summary
QueueImpl(AgentId destId, AgentId adminId)
          Constructs a QueueImpl instance.
 
Method Summary
protected  void deliverMessages(int index)
          Actually tries to answer the pending "receive" requests.
protected  void doProcess(ClientMessages not)
          Method specifically processing a ClientMessages instance.
protected  void doProcess(DeleteNot not)
          Method specifically processing a fr.dyade.aaa.agent.DeleteNot instance.
protected  void doProcess(SetRightRequest not)
          Method specifically processing a SetRightRequest instance.
protected  void doProcess(UnknownAgent uA)
          Method specifically processing an UnknownAgent instance.
protected  void doReact(AgentId from, AcknowledgeRequest not)
          Method implementing the reaction to an AcknowledgeRequest instance, requesting messages to be acknowledged.
protected  void doReact(AgentId from, BrowseRequest not)
          Method implementing the queue reaction to a BrowseRequest instance, requesting an enumeration of the messages on the queue.
protected  void doReact(AgentId from, DenyRequest not)
          Method implementing the reaction to a DenyRequest instance, requesting messages to be denied.
protected  void doReact(AgentId from, Monit_GetDMQSettings not)
          Overrides this DestinationImpl method for sending back the threshold along with the DMQ id.
protected  void doReact(AgentId from, Monit_GetPendingMessages not)
          Method implementing the reaction to a Monit_GetPendingMessages notification requesting the number of pending messages.
protected  void doReact(AgentId from, Monit_GetPendingRequests not)
          Method implementing the reaction to a Monit_GetPendingRequests notification requesting the number of pending requests.
protected  void doReact(AgentId from, ReceiveRequest not)
          Method implementing the reaction to a ReceiveRequest instance, requesting a message.
protected  void doReact(AgentId from, SetThreshRequest req)
          Method implementing the reaction to a SetThreshRequest instance setting the threshold value for this queue.
protected  boolean isUndeliverable(Message message)
          Returns true if a given message is considered as undeliverable, because its delivery count matches the queue's threshold, if any, or the server's default threshold value (if any).
protected  void messageDelivered(java.lang.String msgId)
          call in deliverMessages just after channel.sendTo(msg), overload this methode to process a specific treatment.
protected  void messageRemoved(java.lang.String msgId)
          call in deliverMessages just after a remove message (invalid), overload this methode to process a specific treatment.
 void react(AgentId from, Notification not)
          Distributes the received notifications to the appropriate reactions.
protected  void specialProcess(Notification not)
          The DestinationImpl class calls this method for passing notifications which have been partly processed, so that they are specifically processed by the QueueImpl class.
protected  void storeMessage(Message message)
          Actually stores a message in the deliverables vector.
 java.lang.String toString()
           
 
Methods inherited from class org.objectweb.joram.mom.dest.DestinationImpl
canBeDeleted, doReact, doReact, doReact, doReact, doReact, doReact, doReact, doReact, doReact, isAdministrator, isReader, isWriter, processSetRight, sendToDMQ, specialAdminProcess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

consumers

protected java.util.Hashtable consumers
Table keeping the messages' consumers identifiers.


contexts

protected java.util.Hashtable contexts
Table keeping the messages' consumers contexts.


arrivalsCounter

protected long arrivalsCounter
Counter of messages arrivals.


requests

protected java.util.Vector requests
Vector holding the requests before reply or expiry.


persistenceModule

protected MessagePersistenceModule persistenceModule
The persistence module used for managing the messages' persistence.


receiving

protected transient boolean receiving
true if the queue is currently receiving messages.


messages

protected transient java.util.Vector messages
Vector holding the messages before delivery.


deliveredMsgs

protected transient java.util.Hashtable deliveredMsgs
Table holding the delivered messages before acknowledgement.

Constructor Detail

QueueImpl

public QueueImpl(AgentId destId,
                 AgentId adminId)
Constructs a QueueImpl instance.

Parameters:
destId - Identifier of the agent hosting the queue.
adminId - Identifier of the administrator of the queue.
Method Detail

toString

public java.lang.String toString()

react

public void react(AgentId from,
                  Notification not)
           throws UnknownNotificationException
Distributes the received notifications to the appropriate reactions.

Overrides:
react in class DestinationImpl
Throws:
UnknownNotificationException - When receiving an unexpected notification.

doReact

protected void doReact(AgentId from,
                       SetThreshRequest req)
                throws AccessException
Method implementing the reaction to a SetThreshRequest instance setting the threshold value for this queue.

Throws:
AccessException - If the requester is not the administrator.

doReact

protected void doReact(AgentId from,
                       Monit_GetDMQSettings not)
                throws AccessException
Overrides this DestinationImpl method for sending back the threshold along with the DMQ id.

Overrides:
doReact in class DestinationImpl
Throws:
AccessException - If the requester is not the administrator.

doReact

protected void doReact(AgentId from,
                       Monit_GetPendingMessages not)
                throws AccessException
Method implementing the reaction to a Monit_GetPendingMessages notification requesting the number of pending messages.

Throws:
AccessException - If the requester is not the administrator.

doReact

protected void doReact(AgentId from,
                       Monit_GetPendingRequests not)
                throws AccessException
Method implementing the reaction to a Monit_GetPendingRequests notification requesting the number of pending requests.

Throws:
AccessException - If the requester is not the administrator.

doReact

protected void doReact(AgentId from,
                       ReceiveRequest not)
                throws AccessException
Method implementing the reaction to a ReceiveRequest instance, requesting a message.

This method stores the request and launches a delivery sequence.

Throws:
AccessException - If the sender is not a reader.

doReact

protected void doReact(AgentId from,
                       BrowseRequest not)
                throws AccessException
Method implementing the queue reaction to a BrowseRequest instance, requesting an enumeration of the messages on the queue.

The method sends a BrowseReply back to the client. Expired messages are sent to the DMQ.

Throws:
AccessException - If the requester is not a reader.

doReact

protected void doReact(AgentId from,
                       AcknowledgeRequest not)
Method implementing the reaction to an AcknowledgeRequest instance, requesting messages to be acknowledged.


doReact

protected void doReact(AgentId from,
                       DenyRequest not)
Method implementing the reaction to a DenyRequest instance, requesting messages to be denied.

This method denies the messages and launches a delivery sequence. Messages considered as undeliverable are sent to the DMQ.


specialProcess

protected void specialProcess(Notification not)
The DestinationImpl class calls this method for passing notifications which have been partly processed, so that they are specifically processed by the QueueImpl class.

Specified by:
specialProcess in class DestinationImpl

doProcess

protected void doProcess(SetRightRequest not)
Method specifically processing a SetRightRequest instance.

When a reader is removed, and receive requests of this reader are still on the queue, they are replied to by an ExceptionReply.


doProcess

protected void doProcess(ClientMessages not)
Method specifically processing a ClientMessages instance.

This method stores the messages and launches a delivery sequence.


doProcess

protected void doProcess(UnknownAgent uA)
Method specifically processing an UnknownAgent instance.

The specific processing is done when a QueueMsgReply was sent to a requester which does not exist anymore. In that case, the messages sent to this requester and not yet acknowledged are marked as "denied" for delivery to an other requester, and a new delivery sequence is launched. Messages considered as undeliverable are removed and sent to the DMQ.


doProcess

protected void doProcess(DeleteNot not)
Method specifically processing a fr.dyade.aaa.agent.DeleteNot instance.

ExceptionReply replies are sent to the pending receivers, and the remaining messages are sent to the DMQ and deleted.


storeMessage

protected void storeMessage(Message message)
Actually stores a message in the deliverables vector.

Parameters:
message - The message to store.

deliverMessages

protected void deliverMessages(int index)
Actually tries to answer the pending "receive" requests.

The method may send QueueMsgReply replies to clients.

Parameters:
index - Index where starting to "browse" the requests.

messageDelivered

protected void messageDelivered(java.lang.String msgId)
call in deliverMessages just after channel.sendTo(msg), overload this methode to process a specific treatment.


messageRemoved

protected void messageRemoved(java.lang.String msgId)
call in deliverMessages just after a remove message (invalid), overload this methode to process a specific treatment.


isUndeliverable

protected boolean isUndeliverable(Message message)
Returns true if a given message is considered as undeliverable, because its delivery count matches the queue's threshold, if any, or the server's default threshold value (if any).



Copyright ? 2004 Scalagent - All rights reserved