|
The printer example is a simple client-server system where information flows in one direction only, from client to server.
The client reads lines of text from standard input and sends each line as a separate message to the server. The client finishes when end-of-file condition is detected. The server receives messages, extracts the line of text from each message and prints it on its standard output.
This is a natural use-case for one-way messages and these are used in the basic client version.
As an exercise, the user can run the client with piped input of some bigger text file. This should expose the asynchronous nature of the communication in YAMI4, and the problem described earlier of shutting down the agent while some messages are still in its outgoing message queue. The not-yet-transmitted messages are abandoned and never delivered to the server.
Another version of the client synchronizes each message separately. This ensures that all messages are transmitted to the server, but does not benefit from the buffering capability of the message queue (there is never more than one outgoing message in the queue). Combining the advantages of asynchronous posting with reliability guarantees of the synchronous example is left as an exercise to the user.
The easiest way to try this example is to perform the following actions:
tcp://*:*
. The server will print its resolved target on the screen.