Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
The MicroMessage is the unified message structure for social interaction in µ². It extends Java's native HashMap implementation and provides numerous setters and getters for predefined fields used by the micro-agent framework. However, the developer is free to define custom fields (using a dedicated setter and getter). The use of the message entries is largely left to the developer.
Message fields and according setters/getters
- Sender - setSender()/getSender()
- Specifies the message sender. It is automatically set by the platform upon sending. So in most cases the developer will not need to deal with setting the sender manually. For a recipient the getSender() functionality might be of central concern to figure out the eventual sender. To override the setting of the sender field by the platform (e.g. in case of forwarding messages or any case where the sender field should remain unchanged), set the instance variable sendUnchanged to true (see further information below).
- Recipient - setRecipient()/getRecipient()
- Performative - setPerformative()/getPerformative()
- Specifies the performative of a message.
- Content - setContent()/getContent()
- Specifies potential String content. No further special meaning.
- Intent - setIntent()/getIntent()
- Specifies the intent request sent for processing by another agent via dynamic binding.
- The method containsIntent() indicates if a message contains an intent (without directly retrieving it).
- Event - setEvent()/getEvent()
- Specifies an event in a message, be it either for subscription or raising. For event subscription management ensure to use the according agent methods (subscribe()/unsubscribe()/clearSubscriptions()). Events are raised by simply setting an event and sending the message.
- The method containsEvent() indicates if a message contains an event (without directly retrieving it).
- ExecutionEnvironment - setExecutionEnvironment()/getExecutionEnvironment()
- Specifies the execution environment which should receive the message (if useful in an application). Currently this mainly refers to the decision whether to dispatch a message to a Clojure role implementation or a Java role implementation. It is particularly useful if the message (e.g. the content field) holds executable code.
- ConversationID - setConversationID()/getConversationID()
- Specifies the conversation ID for a message. This is particularly useful when considering long-running and managed conversations (e.g. by conversation policy)
- MessageID - setMessageID()/getMessageID()
- Specifies the message ID in a conversation to keep track of a message order. Similar to the conversation ID the use of the message ID is entirely optional.
- CustomField - setCustomField()/getCustomField()
- Specifies a custom field. The application developer can use these methods to implement further fields as the setter both takes key and value for the according field. Extension of a message structure should always be undertaken using this function in order to ensure unified use.
Special methods of the MicroMessage
- This helper method resets conversation ID and message ID field. When passing an existing MicroMessage as parameter its fields are copied into the new message (where applicable (e.g. not the conversation ID, ...)).
- This helper method returns a MicroMessage instance which is a reply to the instance this method is called on. Operations include the exchange of sender and receiver and incrementing the message ID if applicable
- This method returns the node (in case of distributed execution) the message is sent from to allow distinct addressing of a particular agent. (Agent names must be unique on a single platform but can be redundant (at least the short name) across several platform instances.)
Special (boolean) variables of the MicroMessage
- Indicates if MicroMessages should be globally validated using the specified Message Validator.
- Indicates if this particular MicroMessage instance should be validated with the Message Validator. Malformed messages are indicated in console but processed.
- Indicates if the platform should take severe actions upon detecting invalid messages (e.g. stop the system). The actual action is implemented in the according Message Validator.
- As mentioned above this indicates that the sender field of the message is not to be changed by the platform upon sending.
Apart from the default constructor (MicroMessage()) the MicroMessage class has three further constructors
- Creates a MicroMessage with an intent. It equals an instantiation of the default constructor followed by a setIntent() call.
- Creates a MicroMessage with an event. It equals an instantiation of the default constructor followed by a setEvent() call.
- Creates a MicroMessage with a performative. It equals an instantiation of the default constructor followed by a setPerformative() call.
In order to be successfully sent MicroMessages at least need to provide either of those:
The sender field is automatically filled by the platform upon sending. If only an intent is provided, the recipient is resolved and the message field in fact filled with this. However, from the sender point of view only the intent is provided. The same is the case for messages only containing an event.