jrun.jms.core.messagemgr
Interface MessageManager

All Superinterfaces:
GarbageCollectable, JMSServicePartitionMBean, MessageManagerServiceMBean, QueueWorker, java.io.Serializable, Service, ServiceMBean, ServicePartitionMBean
All Known Implementing Classes:
MessageManagerService

public interface MessageManager
extends MessageManagerServiceMBean, QueueWorker, GarbageCollectable


Fields inherited from interface jrunx.kernel.Service
INITIALIZED, STARTED, STARTING, STOPPED, STOPPING, UNINITIALIZED
 
Method Summary
 void add(MessageImpl message)
          Add a message to the message manager for the specified destination.
 void addDestination(JmsDestination destination)
          Create the specified Destination.
 void addEventListener(JmsDestination destination, MessageManagerEventListener listener)
          Add a message listener for a specific destination to be informed when messages, for the destination are added or removed from the queue.
 boolean exists(JmsDestination destination)
          Return true if the specified destination exists.
 java.util.Iterator getConsumers(JmsDestination destination)
          Returns an iterator of active consumers registered to a given destination
 java.util.Iterator getDestinations()
          Returns a list of active destinations
 javax.jms.Message getMessage(MessageHandle handle)
          Resolve the message for the specified handle.
 int getOutstanding(JmsDestination destination)
          Returns the number of outstanding messages for this destination.
 boolean hasMessages(ConsumerEndpoint consumer)
          Returns true if there are any messages for the specified consumer
 void removeDestination(JmsDestination destination)
          Remove this destination and all attached consumers.
 void removeEventListener(JmsDestination destination, MessageManagerEventListener listener)
          Remove the listener for the specified destination.
 javax.jms.Message removeMessage(MessageId id)
          Remove the specified message from the system.
 JmsDestination resolve(java.lang.String name)
          Resolves a destination given its name
 ConsumerEndpoint resolveConsumer(JmsDestination destination, java.lang.String id)
          Resolves a consumer given its destination and an identity.
 
Methods inherited from interface jrunx.kernel.ServicePartitionMBean
addService, addService, iterator, removeService, removeService
 
Methods inherited from interface jrunx.kernel.ServiceMBean
bind, getBindToJNDI, getDeactivated, getDomainName, getJRunService, getLogger, getName, getParentService, getServerName, requestServer, setBindToJNDI, setDeactivated, setDomainName, setName, setParentService, unbind
 
Methods inherited from interface jrunx.kernel.Service
destroy, getStatus, init, start, stop, updateStatus
 
Methods inherited from interface jrun.jms.core.util.QueueWorker
execute
 
Methods inherited from interface jrun.jms.core.gc.GarbageCollectable
collectGarbage, getGarbageCollectionEvent
 

Method Detail

addDestination

public void addDestination(JmsDestination destination)
                    throws javax.jms.JMSException
Create the specified Destination. The destination is a container for messages and consumers. Consumers listen for messages posted on a particular desitnation.

This can be called multiple times without any side effects. If the destination is null then it throws a JMSException

Parameters:
destination - - create this destination
Throws:
JMSException - - if the params is null

removeDestination

public void removeDestination(JmsDestination destination)
                       throws javax.jms.JMSException
Remove this destination and all attached consumers. If the destination is null then throw an exception.
Parameters:
destination - - the destination to remove
Throws:
JMSException -  

exists

public boolean exists(JmsDestination destination)
Return true if the specified destination exists.
Parameters:
destination - - destination to check
Returns:
boolean - true if a it exists

getDestinations

public java.util.Iterator getDestinations()
Returns a list of active destinations
Returns:
List a list of JmsDestination objects

add

public void add(MessageImpl message)
         throws javax.jms.JMSException
Add a message to the message manager for the specified destination. If the message or the destination are null then throw a JMSException

If the destination, specified in the message, dos not exist then create it. destinations

Parameters:
message - the message to add
Throws:
JMSException - if the message cannot be added

getOutstanding

public int getOutstanding(JmsDestination destination)
                   throws javax.jms.JMSException
Returns the number of outstanding messages for this destination. This is only relevant to JMSQueue destination objects. If a client supplied a <@link JMSTopic} destination then a JMSException exception will be raised.
Parameters:
destination - - the destination to query
Returns:
int - the number of outstanding messages
Throws:
JMSException - - if destination is null or of type JMSQueue

hasMessages

public boolean hasMessages(ConsumerEndpoint consumer)
                    throws javax.jms.JMSException
Returns true if there are any messages for the specified consumer
Parameters:
consumer - - the consumer to check
Returns:
boolean - true if messages are queued
Throws:
JMSException - - if the consumer can't be checked

addEventListener

public void addEventListener(JmsDestination destination,
                             MessageManagerEventListener listener)
Add a message listener for a specific destination to be informed when messages, for the destination are added or removed from the queue. More than one listener can be registered per desitnation and the same listener can be registered for multiple destinations.

If a listener is already registered for a particuler destination then it fails silently.

Parameters:
destination - - what messgaes to listen for
listener - - a JmsMessageListener instance

getConsumers

public java.util.Iterator getConsumers(JmsDestination destination)
                                throws javax.jms.JMSException
Returns an iterator of active consumers registered to a given destination
Returns:
Iterator - iterator of Consumer objects.
Throws:
JMSException -  

getMessage

public javax.jms.Message getMessage(MessageHandle handle)
Resolve the message for the specified handle. If the handle is a PersistentMessageHandle then we need to also attempt to resolve it from the persistent store.
Parameters:
id - - message identity
Returns:
Message - messaage corresponding to id or null

removeEventListener

public void removeEventListener(JmsDestination destination,
                                MessageManagerEventListener listener)
Remove the listener for the specified destination. If one is not registered then ignore it.
Parameters:
destination - - destination that it listens for
listener - - listener for that destination.

removeMessage

public javax.jms.Message removeMessage(MessageId id)
Remove the specified message from the system. This will remove the message from the cache and inform any message listeners of the event
Parameters:
id - - identity of the message
Returns:
Message - removed message

resolveConsumer

public ConsumerEndpoint resolveConsumer(JmsDestination destination,
                                        java.lang.String id)
Resolves a consumer given its destination and an identity.
Parameters:
destination - the destination
name - the name of the consumer
Returns:
ConsumerIfc if an active consumer exists for the given name, else it returns null

resolve

public JmsDestination resolve(java.lang.String name)
Resolves a destination given its name
Parameters:
name - the name of the destination
Returns:
JmsDestination if an active destination exists for the given name, else it returns null


Copyright � 2002 Macromedia Corporation. All Rights Reserved.