org.apache.qpid.server.message
Class AMQMessage

java.lang.Object
  extended by org.apache.qpid.server.message.AMQMessage
All Implemented Interfaces:
EnqueableMessage, MessageContentSource, ServerMessage

public class AMQMessage
extends Object
implements ServerMessage

A deliverable message.


Field Summary
(package private)  WeakReference<AMQChannel> _channelRef
           
 
Constructor Summary
AMQMessage(StoredMessage<MessageMetaData> handle)
           
AMQMessage(StoredMessage<MessageMetaData> handle, WeakReference<AMQChannel> channelRef)
           
 
Method Summary
 String debugIdentity()
           
 void decrementReference()
          Threadsafe.
 boolean expired(AMQQueue queue)
          Checks to see if the message has expired.
 long getArrivalTime()
           
 int getContent(ByteBuffer buf, int offset)
           
 org.apache.qpid.framing.ContentHeaderBody getContentHeaderBody()
           
 boolean getDeliveredToConsumer()
          Called selectors to determin if the message has already been sent
 long getExpiration()
           
 AMQMessageHeader getMessageHeader()
           
 Long getMessageId()
           
 MessageMetaData getMessageMetaData()
           
 Long getMessageNumber()
           
 org.apache.qpid.framing.abstraction.MessagePublishInfo getMessagePublishInfo()
           
 Object getPublisherIdentifier()
           
 String getRoutingKey()
           
 SessionConfig getSessionConfig()
           
 long getSize()
           
 StoredMessage<MessageMetaData> getStoredMessage()
           
 boolean immediateAndNotDelivered()
          Called to enforce the 'immediate' flag.
 boolean incrementReference()
           
 boolean incrementReference(int count)
           
 boolean isImmediate()
           
 boolean isPersistent()
           
 boolean isReferenced()
           
 MessageReference newReference()
           
 void setClientIdentifier(Object sessionIdentifier)
           
 void setDeliveredToConsumer()
          Called when this message is delivered to a consumer.
 void setExpiration(long expiration)
           
 AMQMessage takeReference()
          Creates a long-lived reference to this message, and increments the count of such references, as an atomic operation.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_channelRef

WeakReference<AMQChannel> _channelRef
Constructor Detail

AMQMessage

public AMQMessage(StoredMessage<MessageMetaData> handle)

AMQMessage

public AMQMessage(StoredMessage<MessageMetaData> handle,
                  WeakReference<AMQChannel> channelRef)
Method Detail

debugIdentity

public String debugIdentity()

setExpiration

public void setExpiration(long expiration)

isReferenced

public boolean isReferenced()

getMessageMetaData

public MessageMetaData getMessageMetaData()

getContentHeaderBody

public org.apache.qpid.framing.ContentHeaderBody getContentHeaderBody()
                                                               throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException

getMessageId

public Long getMessageId()

takeReference

public AMQMessage takeReference()
Creates a long-lived reference to this message, and increments the count of such references, as an atomic operation.


incrementReference

public boolean incrementReference()

incrementReference

public boolean incrementReference(int count)

decrementReference

public void decrementReference()
Threadsafe. This will decrement the reference count and when it reaches zero will remove the message from the message store.

Throws:
MessageCleanupException - when an attempt was made to remove the message from the message store and that failed

getDeliveredToConsumer

public boolean getDeliveredToConsumer()
Called selectors to determin if the message has already been sent

Returns:
_deliveredToConsumer

getRoutingKey

public String getRoutingKey()
Specified by:
getRoutingKey in interface ServerMessage

getMessageHeader

public AMQMessageHeader getMessageHeader()
Specified by:
getMessageHeader in interface ServerMessage

isPersistent

public boolean isPersistent()
Specified by:
isPersistent in interface EnqueableMessage
Specified by:
isPersistent in interface ServerMessage

immediateAndNotDelivered

public boolean immediateAndNotDelivered()
Called to enforce the 'immediate' flag.


getMessagePublishInfo

public org.apache.qpid.framing.abstraction.MessagePublishInfo getMessagePublishInfo()
                                                                             throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException

getArrivalTime

public long getArrivalTime()
Specified by:
getArrivalTime in interface ServerMessage

expired

public boolean expired(AMQQueue queue)
                throws org.apache.qpid.AMQException
Checks to see if the message has expired. If it has the message is dequeued.

Parameters:
queue - The queue to check the expiration against. (Currently not used)
Returns:
true if the message has expire
Throws:
org.apache.qpid.AMQException

setDeliveredToConsumer

public void setDeliveredToConsumer()
Called when this message is delivered to a consumer. (used to implement the 'immediate' flag functionality). And for selector efficiency.


getSize

public long getSize()
Specified by:
getSize in interface MessageContentSource
Specified by:
getSize in interface ServerMessage

isImmediate

public boolean isImmediate()
Specified by:
isImmediate in interface ServerMessage

getExpiration

public long getExpiration()
Specified by:
getExpiration in interface ServerMessage

newReference

public MessageReference newReference()
Specified by:
newReference in interface ServerMessage

getMessageNumber

public Long getMessageNumber()
Specified by:
getMessageNumber in interface EnqueableMessage
Specified by:
getMessageNumber in interface ServerMessage

getPublisherIdentifier

public Object getPublisherIdentifier()

setClientIdentifier

public void setClientIdentifier(Object sessionIdentifier)

toString

public String toString()
Overrides:
toString in class Object

getContent

public int getContent(ByteBuffer buf,
                      int offset)
Specified by:
getContent in interface MessageContentSource
Specified by:
getContent in interface ServerMessage

getStoredMessage

public StoredMessage<MessageMetaData> getStoredMessage()

getSessionConfig

public SessionConfig getSessionConfig()
Specified by:
getSessionConfig in interface ServerMessage


Licensed to the Apache Software Foundation