-
Notifications
You must be signed in to change notification settings - Fork 29
Communication Framework
##Description Agents can communicate with other agents using MessageBus. Two kinds of communication exist in Message Bus: Event and Message. An agent can register for an event and, whenever this event occurs, the subscribed agent is informed. Moreover, an agent can directly send messages to the other agents whom reference is known.
More details about the implementation of Message Bus are described in the following page : Message Bus
##1 Communication via Messages The Message Bus in SimMobility provides a global pipeline between different active agents. The Message Bus can transfer two kinds of messages: instantaneous messages and messages with one frame-tick delay. More on the implementation of messaging can be found in the page : Messaging.
###1.1 Instantaneous Message without any delay This kind of message can be sent to others as soon as possible, without any delay. This is possible only when the sender and the receiver are within the same thread apartment.
###1.2 Global Message with one frame-tick delay This kind of message can be post to the global messages queue and will be delivered to the target agent in the next frame. For example, if the frame tick is 5 seconds, the message will arrive at the target agent after 5 seconds delay. This kind of message can be used when the sender and receiver are without the same thread apartment.
##2 Communication via Events The Message Bus in SimMobility also provide the mechanism of registering or triggering any kinds of event between different active agents. An agent can subscribe to a given event and will get notified when this given event is triggered by the publisher. More details about the implementation of events are described in the page: Event
###2.1 Instantaneous Event (Local Event) An instantaneous event is a event which is meant to be received by other subscribers instantaneously (without any delay). This is possible only when the publisher and the subscriber are within the same thread apartment. When instantaneous events are triggered, the publishers and subscribers must be in the same thread context. This event message will not be put into message queues for subsequent distribution and processing.
When an agent triggers this kind of event, it can be notified to other agents that exist in different thread apartments. An global event is used to trigger events between active agents no matter with different thread contexts. Normally, when an event message is triggered, this event message is first put into message queue for subsequent distribution and secondly delivered to the target subscribers in different thread context.
This kind of event can be notified in other time instants in the future. A time-based event includes a temporal time-window which will expire at a given target time. This event message will be delayed to be notified only when the duration time inside time-based event expires.