Examples
The source package comes up with examples in the different languages. The current page is showing how to run them in Linux.
The end of the page shows rapidly how to run on Windows.
Setup
Linux
The Java, C++ and Python examples can be run using either jzmq or jeromq.
Open a shell and go to the CAMEO root directory.
Set the PATH variable so that the C++ programs are found:
If necessary, set the PYTHONPATH variable so that the cameopy module is found e.g.:
You may have to verify that python is defined (install python-is-python3 package on Ubuntu).Select jzmq or jeromq Java library.
Case jzmq:
You shall define the variable LD_LIBRARY_PATH so that libjzmq.so is found:
Start the cameo server with the examples configuration:In each new shell, create the alias for cmo:
Case jeromq:
In each new shell, create the alias for cmo:
Windows
Open a standard prompt and go to the CAMEO root directory. Then set the PATH:
Set the CLASSPATH to use jeromq:
If necessary, set the PYTHONPATH variable so that the cameopy module is found e.g.:
Run the server:
In each new prompt or shell, create the alias for cmo:
Requester/Responder
Java
The requester/responder in Java can be tested.
Start the responder app in a new shell:
The requester app is sending 10 requests to the responder, receives the responses and then stops. Notice that the responder app also stops. Indeed the requester app stops itself the responder app.
Now relaunch the requester app without relaunching the responder app. The requester app is also sending and receiving messages from the responder app. Indeed the responder app has been started by the requester app because it was not running.
This example shows that by a single entry point (the console), the requester and responder apps start and communicate without losing any request and terminate synchronously.
Code is available:
C++
The requester/responder in C++ can be tested in the same way by replacing java with cpp.
Start the responder in a shell:
Same comments as for Java.
Code is available:
Python
The requester/responder in Python can be tested in the same way by replacing cpp with python.
Start the responder in a shell:
Same comments as for Java.
Code is available:
Mixing languages
You can mix the languages e.g. cpp with python:
Remote execution
You can also execute the last example in three different computers:
The console cmo application is executing requester-python on computer-a which interacts with responder-cpp executing on computer-b.
Here again, this example shows that by a single entry point (the console), the requester and responder apps start and communicate on two computers without losing any request and terminate synchronously.
Publisher/Subscriber
Java
The publisher/subscriber in Java can be tested.
Start the publisher app in a new shell:
The publisher app is waiting for 1 subscriber before starting to send messages. The subscriber app connects to the publisher app which triggers the sending of the messages. The subscriber app is killed with ctl-c but the publisher app is still running so that you have to kill it also with ctl-c.
Now relaunch the subscriber app without relaunching the publisher app. The publisher is started in background and the messages are sent from the publisher to the requester. If you kill the subscriber app with ctl-c then the publisher is also killed. That is because the publisher app is linked to its starter. You can also properly stop the subscriber app. To do it type shift+s in the console and press enter. In that case the subscriber app is stopping the publisher app which terminates properly.
This example shows that by a single entry point (the console), the subscriber and publisher apps start and communicate without losing any message and terminate synchronously.
Code is available:
C++
The publisher/subscriber in C++ can be tested in the same way by replacing java with cpp.
Start the publisher in a shell:
Same comments as for Java.
Code is available:
Python
The publisher/subscriber in Python can be tested in the same way by replacing java with python.
Start the publisher in a shell:
Same comments as for Java.
Code is available:
Mixing languages
You can mix the langagues e.g. cpp with python:
Remote execution
You can also execute the last example in three different computers:
The console cmo application is executing subscriber-python on computer-a which interacts with publisher-cpp executing on computer-b.
Here again, this example shows that by a single entry point (the console), the subscriber and publisher apps start and communicate on two computers without losing any request and terminate synchronously.