Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.aendvari.hermes.broker
Class Message  view Message download Message.java

java.lang.Object
  extended bycom.aendvari.hermes.broker.Message

public class Message
extends java.lang.Object

Represents a single message. Messages are sent to listeners using a publish/subscribe model. The MessageBroker class handles the dispatching and listener registration.

A message may have several properties. The properties are stored in a (com.aendvari.common.properties.Properties) object. This allows the properties to be stored in a hierarchy.

Every message may have an optional "reply to" value set. The value is the MessageTopic to send a response message to. Typically, the sender of the original message has subscribed to this topic. Other listeners may subscribe with the same topic. The content of the message is expected to be known by all parties.

While a message is being sent to the listeners, any listener may choose to cancel the message. When cancelled, the message is not sent to any other listeners. Typically a listener higher in the topic hierarchy will cancel a message so that listeners lower do not receive it.

Messages are independant of the topics they are published to. A listener receiving a message may send the same message instance to another topic, typically after adding information.

Every message may be given a MessageBrokerContext to provide broker specific information that a receiver may need.


Field Summary
protected  boolean cancelled
          Specifies whether the message has been cancelled.
protected  MessageBrokerContext context
          The MessageBrokerContext of this message.
protected  int correlationId
          An identifier to correlate replies with the requestor.
protected  MessageTopic destination
          The destination topic of the message.
protected  MessageTopic location
          The topic the message is currently being processed by.
protected  com.aendvari.common.properties.Properties properties
          The (com.aendvari.common.properties.Properties) object that properties are stored in.
protected  MessageTopic replyToTopic
          The topic that the sender wishes the receiver to send a response message to.
 
Constructor Summary
protected Message()
          Constructs a Message.
protected Message(Message message)
          Constructs a Message as a copy of another Message.
 
Method Summary
 void cancel()
          Cancels this message.
 void clear()
          Clears this message.
 MessageBrokerContext getContext()
          Returns the MessageBrokerContext for this message.
 int getCorrelationId()
          Returns the correlation identifier of this message.
 MessageTopic getDestination()
          Returns the destination MessageTopic of this message.
 MessageTopic getLocation()
          Returns the MessageTopic that is currently processing this message.
 com.aendvari.common.properties.Properties getProperties()
          Returns the com.aendvari.common.properties.Properties object for the storage and retrieval of message properties.
 MessageTopic getReplyTo()
          Returns the topic that the sender has requested that a reply be sent to.
 boolean isCancelled()
          Returns whether this message has been cancelled.
 void setContext(MessageBrokerContext setContext)
          Sets the MessageBrokerContext for this message.
 void setCorrelationId(int setCorrelationId)
          Sets the correlation identifier of this message.
protected  void setDestination(MessageTopic setDestination)
          Sets the destination MessageTopic of this message.
protected  void setLocation(MessageTopic setLocation)
          Sets the MessageTopic currently processing this message.
 void setReplyTo(MessageTopic topic)
          Sets the topic that the sender wishes a reply to be sent to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected MessageBrokerContext context
The MessageBrokerContext of this message.


properties

protected com.aendvari.common.properties.Properties properties
The (com.aendvari.common.properties.Properties) object that properties are stored in.


destination

protected MessageTopic destination
The destination topic of the message.


location

protected MessageTopic location
The topic the message is currently being processed by.


replyToTopic

protected MessageTopic replyToTopic
The topic that the sender wishes the receiver to send a response message to.


correlationId

protected int correlationId
An identifier to correlate replies with the requestor.


cancelled

protected boolean cancelled
Specifies whether the message has been cancelled.

Constructor Detail

Message

protected Message()
Constructs a Message.


Message

protected Message(Message message)
Constructs a Message as a copy of another Message.

Method Detail

getContext

public MessageBrokerContext getContext()
Returns the MessageBrokerContext for this message.


setContext

public void setContext(MessageBrokerContext setContext)
Sets the MessageBrokerContext for this message.


getProperties

public com.aendvari.common.properties.Properties getProperties()
Returns the com.aendvari.common.properties.Properties object for the storage and retrieval of message properties.


getDestination

public MessageTopic getDestination()
Returns the destination MessageTopic of this message.


setDestination

protected void setDestination(MessageTopic setDestination)
Sets the destination MessageTopic of this message.


getLocation

public MessageTopic getLocation()
Returns the MessageTopic that is currently processing this message.


setLocation

protected void setLocation(MessageTopic setLocation)
Sets the MessageTopic currently processing this message.


getReplyTo

public MessageTopic getReplyTo()
Returns the topic that the sender has requested that a reply be sent to.


setReplyTo

public void setReplyTo(MessageTopic topic)
Sets the topic that the sender wishes a reply to be sent to.


getCorrelationId

public int getCorrelationId()
Returns the correlation identifier of this message.


setCorrelationId

public void setCorrelationId(int setCorrelationId)
Sets the correlation identifier of this message.


isCancelled

public boolean isCancelled()
Returns whether this message has been cancelled.


clear

public void clear()
Clears this message. This allows the same instance to be reused.


cancel

public void cancel()
Cancels this message.