Inspirel banner

Programming Distributed Systems with YAMI4

5.2 One-Way Messages

In addition to the idiomatic processing presented in the previous section, outgoing messages can be also sent as one-way, which means that the sender is not interested in the progress feedback and does not intend to ever obtain the state, reply or rejection reason for that message.

For such a message there is no need for the outgoing message object to physically exist in the user space and the internal management of resources can be also simplified.

One-way messages are a common way to implement notifications that flow in one direction only and since their management is simpler, they can have some performance advantage over regular messages with progress feedback. On the other hand, one-way messages do not provide any means of checking whether they were handled successfully - not even in terms of their transmission. This means that one-way messages should not be used when some form of handshake or confirmation is expected at the sender side.

The Send_One_Way procedure can be used to post one-way messages in Ada instead of the Send operation that is used for regular outgoing messages.

In C++ and Python such messages are posted with the send_one_way() function.

In Java the equivalent function is sendOneWay(), whereas .NET uses SendOneWay().

Even though these operations do not return anything and do not initialize any object provided by the user, they can still throw an exception if it can be early detected that the communication channel cannot be established.


As all messages, one-way messages are posted and processed asynchronously, which means that some time might be needed for them to be actually transmitted and that time is not known to the user code. Since there is no feedback on the message progress, special care should be taken in order to avoid unintentional abandoning of the message if the channel or the whole agent is closed or destroyed with some messages still in the outgoing queue. It is guaranteed, however, that messages with the same priority are sent in the FIFO order, so a single outgoing message with progress feedback (wait on transmission) can be used to ensure that one-way messages that were previously posted to the same target were also transmitted.