org.exolab.jms.messagemgr
Class AbstractMessageHandle

java.lang.Object
  |
  +--org.exolab.jms.messagemgr.AbstractMessageHandle
All Implemented Interfaces:
MessageHandle
Direct Known Subclasses:
PersistentMessageHandle

public abstract class AbstractMessageHandle
extends java.lang.Object
implements MessageHandle

Abstract implementation of the MessageHandle interface.

Version:
$Revision: 1.2 $ $Date: 2005/08/30 07:26:49 $
Author:
Tim Anderson

Constructor Summary
AbstractMessageHandle(DestinationCache cache, MessageRef reference, MessageImpl message)
          Construct a new AbstractMessageHandle.
AbstractMessageHandle(java.lang.String messageId, int priority, long acceptedTime, long sequenceNumber, long expiryTime, JmsDestination destination)
          Construct a new AbstractMessageHandle.
 
Method Summary
 void destroy()
          Destroy this handle.
 boolean equals(java.lang.Object object)
          Indicates whether some other object is "equal to" this one.
 long getAcceptedTime()
          Returns the time that the corresponding message was accepted, in milliseconds.
 long getConnectionId()
          Returns the connection identity associated with this handle.
 long getConsumerId()
          Returns the consumer identity associated with the message.
 java.lang.String getConsumerPersistentId()
          Returns the persistent identity of the the consumer endpoint that owns this handle.
 boolean getDelivered()
          Returns if an attempt has already been made to deliver the message.
 JmsDestination getDestination()
          Returns the message destination.
 long getExpiryTime()
          Returns the time that the message expires.
 MessageImpl getMessage()
          Returns the message associated with this handle.
 java.lang.String getMessageId()
          Returns the message identifier.
 MessageRef getMessageRef()
          Returns the message reference.
 int getPriority()
          Returns the priority of the message.
 long getSequenceNumber()
          Returns the handle's sequence number.
 boolean hasExpired()
          Determines if the message has expired.
 int hashCode()
          Returns a hash code value for the object.
 boolean isPersistent()
          Determines if the handle is persistent.
 void release()
          Release the message handle back to the cache, to recover an unsent or unacknowledged message.
protected  void release(MessageHandle handle)
          Release the message handle back to the cache, to recover an unsent or unacknowledged message.
 void setDelivered(boolean delivered)
          Indicates if a message has been delivered to a MessageConsumer, but not acknowledged.
protected  void setDestinationCache(DestinationCache cache)
          Sets the destination cache.
protected  void setMessageRef(MessageRef reference)
          Sets the message reference.
 java.lang.String toString()
          Return a stringified version of the handle.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.exolab.jms.messagemgr.MessageHandle
add, update
 

Constructor Detail

AbstractMessageHandle

public AbstractMessageHandle(DestinationCache cache,
                             MessageRef reference,
                             MessageImpl message)
                      throws javax.jms.JMSException
Construct a new AbstractMessageHandle.
Parameters:
cache - the destination cache that owns this
reference - the reference to the message
message - the message for which the handle is created
Throws:
javax.jms.JMSException - if the handle cannot be constructed

AbstractMessageHandle

public AbstractMessageHandle(java.lang.String messageId,
                             int priority,
                             long acceptedTime,
                             long sequenceNumber,
                             long expiryTime,
                             JmsDestination destination)
Construct a new AbstractMessageHandle.
Parameters:
messageId - the message identifier
priority - the message priority
acceptedTime - the time the message was accepted by the server
sequenceNumber - the message sequence number
expiryTime - the time that the message will expire
Method Detail

getMessageId

public java.lang.String getMessageId()
Returns the message identifier.
Specified by:
getMessageId in interface MessageHandle
Returns:
the message identifier

getMessage

public MessageImpl getMessage()
                       throws javax.jms.JMSException
Returns the message associated with this handle.
Specified by:
getMessage in interface MessageHandle
Returns:
the associated message, or null if the handle is no longer valid
Throws:
javax.jms.JMSException - for any error

setDelivered

public void setDelivered(boolean delivered)
Indicates if a message has been delivered to a MessageConsumer, but not acknowledged.
Specified by:
setDelivered in interface MessageHandle
Parameters:
delivered - if true indicates that an attempt has been made to deliver the message

getDelivered

public boolean getDelivered()
Returns if an attempt has already been made to deliver the message.
Specified by:
getDelivered in interface MessageHandle
Returns:
true if delivery has been attempted

getPriority

public int getPriority()
Returns the priority of the message.
Specified by:
getPriority in interface MessageHandle
Returns:
the message priority

getAcceptedTime

public long getAcceptedTime()
Returns the time that the corresponding message was accepted, in milliseconds.
Specified by:
getAcceptedTime in interface MessageHandle
Returns:
the time that the corresponding message was accepted

getExpiryTime

public long getExpiryTime()
Returns the time that the message expires.
Specified by:
getExpiryTime in interface MessageHandle
Returns:
the expiry time

hasExpired

public boolean hasExpired()
Determines if the message has expired.
Specified by:
hasExpired in interface MessageHandle
Returns:
true if the message has expired, otherwise false

getSequenceNumber

public long getSequenceNumber()
Returns the handle's sequence number.
Specified by:
getSequenceNumber in interface MessageHandle
Returns:
the sequence number

getDestination

public JmsDestination getDestination()
Returns the message destination.
Specified by:
getDestination in interface MessageHandle
Returns:
the message destination

getConsumerId

public long getConsumerId()
Returns the consumer identity associated with the message.
Specified by:
getConsumerId in interface MessageHandle
Returns:
the consumer identity associated with the message, or * -1 if the message isn't associated with a consumer

getConsumerPersistentId

public java.lang.String getConsumerPersistentId()
Returns the persistent identity of the the consumer endpoint that owns this handle. If it is set, then a consumer owns it exclusively, otherwise the handle may be shared across a number of consumers.
Specified by:
getConsumerPersistentId in interface MessageHandle
Returns:
null

getConnectionId

public long getConnectionId()
Returns the connection identity associated with this handle.
Specified by:
getConnectionId in interface MessageHandle
Returns:
the connection identity associated with this handle, or -1 if this isn't associated with a connection

isPersistent

public boolean isPersistent()
Determines if the handle is persistent.
Specified by:
isPersistent in interface MessageHandle
Returns:
false

equals

public boolean equals(java.lang.Object object)
Indicates whether some other object is "equal to" this one.
Overrides:
equals in class java.lang.Object
Parameters:
object - the reference object with which to compare.
Returns:
true if object is a MessageHandle, and has the same #getMessageId()

hashCode

public int hashCode()
Returns a hash code value for the object.
Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object

toString

public java.lang.String toString()
Return a stringified version of the handle.
Overrides:
toString in class java.lang.Object
Returns:
a stringified version of the handle

destroy

public void destroy()
             throws javax.jms.JMSException
Destroy this handle. If this is the last handle to reference the message, also destroys the message.
Specified by:
destroy in interface MessageHandle
Throws:
javax.jms.JMSException - for any error

release

public void release()
             throws javax.jms.JMSException
Release the message handle back to the cache, to recover an unsent or unacknowledged message.
Specified by:
release in interface MessageHandle
Throws:
javax.jms.JMSException - for any error

getMessageRef

public MessageRef getMessageRef()
Returns the message reference.
Specified by:
getMessageRef in interface MessageHandle
Returns:
the message reference, or null if none has been set

setMessageRef

protected void setMessageRef(MessageRef reference)
Sets the message reference.
Parameters:
reference - the reference to the message

setDestinationCache

protected void setDestinationCache(DestinationCache cache)
Sets the destination cache.
Parameters:
cache - the destination cache

release

protected void release(MessageHandle handle)
                throws javax.jms.JMSException
Release the message handle back to the cache, to recover an unsent or unacknowledged message.

This should be used when the parent in a chain of handles needs to be released.

Parameters:
handle - the handle to release
Throws:
javax.jms.JMSException - for any error


Copyright © 1999-2007 The OpenJMS Group. All Rights Reserved.