juglr
Class Message

java.lang.Object
  extended by juglr.Message
Direct Known Subclasses:
Box, HTTPRequest, HTTPResponse

public class Message
extends java.lang.Object

Abstract base class for all message types. It is recommended to use the Box class to transfer messages between actors since it guarantees "shared nothing" which is important in highly parallel computation.

If you need to send specialized messages that can not be seriliazed to simple Java types, or serialization is too expensive you can subclass this class to get what you need.

See Also:
Actor, Box, MessageBus

Constructor Summary
Message()
           
 
Method Summary
 Address getReplyTo()
          Get the address the message recipient should reply to in case that is relevant.
 Address getSender()
          Get the Address of the Actor responsible for sending this message.
 Message setReplyTo(Address replyTo)
          Set the address that the message recipient should reply to in case that is relevant.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Message

public Message()
Method Detail

getSender

public Address getSender()
Get the Address of the Actor responsible for sending this message. Useful for responding to messages from otherwise unknown parties. The sender address is guaranteed to be set when receiving a message in Actor.react(juglr.Message) or Actor#awaitMessage(). Note that it is generally advised to use getReplyTo() instead of this method, unless you understand what you are doing.

Returns:
the address of the sender or null if this message has not been send

setReplyTo

public Message setReplyTo(Address replyTo)
Set the address that the message recipient should reply to in case that is relevant. This is useful if you route a message through several actors and want the last one to reply to the original sender.

The DelegatingActor and MulticastActor will set the reply-to address to that of the original sender when passing messages on to delegates.

Parameters:
replyTo - the address the message recipient should send replies to
Returns:
always returns this

getReplyTo

public Address getReplyTo()
Get the address the message recipient should reply to in case that is relevant. Note that this might not always be the same as the message sender in case the message was routed through intermediate actors like a DelegatingActor or MulticastActor.

Returns:
the address that replies should be sent to