org.codehaus.activemq.service.impl
Class DurableQueueMessageContainer

java.lang.Object
  extended byorg.codehaus.activemq.service.impl.DurableQueueMessageContainer
All Implemented Interfaces:
MessageContainer, QueueMessageContainer, Service

public class DurableQueueMessageContainer
extends Object
implements QueueMessageContainer

A default implemenation of a Durable Queue based MessageContainer which acts as an adapter between the MessageContainerManager requirements and those of the persistent MessageStore implementations.

Version:
$Revision: 1.19 $

Constructor Summary
DurableQueueMessageContainer(PersistenceAdapter persistenceAdapter, MessageStore messageStore, String destinationName)
           
DurableQueueMessageContainer(PersistenceAdapter persistenceAdapter, MessageStore messageStore, String destinationName, QueueList messagesToBeDelivered, QueueList deliveredMessages)
           
 
Method Summary
 MessageIdentity addMessage(ActiveMQMessage message)
          Add an ActiveMQMessage to the message container
 boolean containsMessage(MessageIdentity messageIdentity)
          Returns whether or not this container contains the given message identity which provides an optimisation over getMessage() where the message does not need to be loaded.
 void delete(MessageIdentity messageID, MessageAck ack)
          Delete a message - if no
 String getDestinationName()
           
 ActiveMQMessage getMessage(MessageIdentity messageID)
          Return the ActiveMQMessage that matches the Id
 ActiveMQMessage peekNext(MessageIdentity messageID)
          Used for browsing a MessageContainer this returns the next message in the container after the messageId
 ActiveMQMessage poll()
          Some implementations may need to poll to fill subscriptions this returns the next message in the container
 void recoverMessageToBeDelivered(MessageIdentity messageIdentity)
          Invoked during the recovery to add the given message to the end of the messages to be delivered.
 void registerMessageInterest(MessageIdentity messageIdentity)
          Does nothing since when we receive an acknowledgement on a queue we can delete the message
 void reset()
          called to reset dispatch pointers if a new Message Consumer joins
 void returnMessage(MessageIdentity messageIdentity)
          After a poll() on the Container, if a message can't be dispatched, it is returned
 void start()
          This container has just been loaded from disk and so it needs to be recovered, that is iterate through all the message IDs in the persistent store and add them to the in memory list of message IDs to be dispatched by consumers
 void stop()
          Called to shutdown the service
 void unregisterMessageInterest(MessageIdentity messageIdentity, MessageAck ack)
          Does nothing since when we receive an acknowledgement on a queue we can delete the message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DurableQueueMessageContainer

public DurableQueueMessageContainer(PersistenceAdapter persistenceAdapter,
                                    MessageStore messageStore,
                                    String destinationName)

DurableQueueMessageContainer

public DurableQueueMessageContainer(PersistenceAdapter persistenceAdapter,
                                    MessageStore messageStore,
                                    String destinationName,
                                    QueueList messagesToBeDelivered,
                                    QueueList deliveredMessages)
Method Detail

getDestinationName

public String getDestinationName()
Specified by:
getDestinationName in interface MessageContainer
Returns:
the destinationName of the Container

addMessage

public MessageIdentity addMessage(ActiveMQMessage message)
                           throws JMSException
Description copied from interface: MessageContainer
Add an ActiveMQMessage to the message container

Specified by:
addMessage in interface MessageContainer
Parameters:
message -
Throws:
JMSException

delete

public void delete(MessageIdentity messageID,
                   MessageAck ack)
            throws JMSException
Description copied from interface: MessageContainer
Delete a message - if no

Specified by:
delete in interface MessageContainer
Parameters:
messageID -
ack -
Throws:
JMSException

getMessage

public ActiveMQMessage getMessage(MessageIdentity messageID)
                           throws JMSException
Description copied from interface: MessageContainer
Return the ActiveMQMessage that matches the Id

Specified by:
getMessage in interface MessageContainer
Parameters:
messageID -
Returns:
the message or null
Throws:
JMSException

containsMessage

public boolean containsMessage(MessageIdentity messageIdentity)
                        throws JMSException
Description copied from interface: MessageContainer
Returns whether or not this container contains the given message identity which provides an optimisation over getMessage() where the message does not need to be loaded.

Specified by:
containsMessage in interface MessageContainer
Parameters:
messageIdentity -
Returns:
true if the container contains the given message
Throws:
JMSException

registerMessageInterest

public void registerMessageInterest(MessageIdentity messageIdentity)
Does nothing since when we receive an acknowledgement on a queue we can delete the message

Specified by:
registerMessageInterest in interface MessageContainer
Parameters:
messageIdentity -

unregisterMessageInterest

public void unregisterMessageInterest(MessageIdentity messageIdentity,
                                      MessageAck ack)
Does nothing since when we receive an acknowledgement on a queue we can delete the message

Specified by:
unregisterMessageInterest in interface MessageContainer
Parameters:
messageIdentity -
ack -

poll

public ActiveMQMessage poll()
                     throws JMSException
Description copied from interface: QueueMessageContainer
Some implementations may need to poll to fill subscriptions this returns the next message in the container

Specified by:
poll in interface QueueMessageContainer
Returns:
the next message
Throws:
JMSException

peekNext

public ActiveMQMessage peekNext(MessageIdentity messageID)
                         throws JMSException
Description copied from interface: QueueMessageContainer
Used for browsing a MessageContainer this returns the next message in the container after the messageId

Specified by:
peekNext in interface QueueMessageContainer
Parameters:
messageID - the id if the message. If this is null, the first message will be retrieved
Returns:
the next message without updating it's state to being dispatched
Throws:
JMSException

returnMessage

public void returnMessage(MessageIdentity messageIdentity)
                   throws JMSException
Description copied from interface: QueueMessageContainer
After a poll() on the Container, if a message can't be dispatched, it is returned

Specified by:
returnMessage in interface QueueMessageContainer
Parameters:
messageIdentity -
Throws:
JMSException

reset

public void reset()
           throws JMSException
called to reset dispatch pointers if a new Message Consumer joins

Specified by:
reset in interface QueueMessageContainer
Throws:
JMSException

start

public void start()
           throws JMSException
Description copied from interface: QueueMessageContainer
This container has just been loaded from disk and so it needs to be recovered, that is iterate through all the message IDs in the persistent store and add them to the in memory list of message IDs to be dispatched by consumers

Specified by:
start in interface QueueMessageContainer
Throws:
JMSException

recoverMessageToBeDelivered

public void recoverMessageToBeDelivered(MessageIdentity messageIdentity)
                                 throws JMSException
Description copied from interface: QueueMessageContainer
Invoked during the recovery to add the given message to the end of the messages to be delivered.

Specified by:
recoverMessageToBeDelivered in interface QueueMessageContainer
Throws:
JMSException

stop

public void stop()
          throws JMSException
Description copied from interface: Service
Called to shutdown the service

Specified by:
stop in interface Service
Throws:
JMSException


Copyright © 2004 Protique, Ltd.. All Rights Reserved.