... | ... | @@ -3,8 +3,8 @@ Controlling the CAMEO apps is already a form of communication between the apps. |
|
|
|
|
|
The following examples will only show string messages however any kind of serialization can be used: binary serialization with *Protobuf* or ascii serialization with *JSON*.
|
|
|
|
|
|
# Return value
|
|
|
First and easiest way to pass data from an app to another is to use the return value. When an app terminates it is possible to set a return value that will be published to all the instance references. We can extend the Java application of *App2*:
|
|
|
# Function pattern
|
|
|
First and easiest way to pass data from an app to another is to use the function pattern. When an app terminates it is possible to set a return value that will be published to all the instance references. We can extend the Java application of *App2*:
|
|
|
|
|
|
```java
|
|
|
import fr.ill.ics.cameo.base.This;
|
... | ... | @@ -73,7 +73,7 @@ Use the return value can be very helpful to use an app as a function. However it |
|
|
|
|
|
Indeed in that case it is better to setup a requester/responder communication to avoid too many creation and destruction of processes and to avoid a network overload.
|
|
|
|
|
|
# Requester/Responder
|
|
|
# Requester/Responder pattern
|
|
|
|
|
|
If you need to setup a request/response mechanism between different apps then use the provided requester/responder communication pattern.
|
|
|
|
... | ... | @@ -229,7 +229,7 @@ catch (InitException e) { |
|
|
Once the router is receiving a request from a requester, it forwards it to a multi responder (round-robin distribution) that can process it in its **own thread**. It can also reply multiple times. The router run() call is **blocking** and the router must be canceled to return.
|
|
|
|
|
|
|
|
|
# Publisher/Subscriber
|
|
|
# Publisher/Subscriber pattern
|
|
|
|
|
|
Another useful communication pattern is the publish/subscribe pattern. It allows asynchronous messages from one application to other ones. Let's define a Java application *PubJava* which defines a publisher:
|
|
|
```java
|
... | ... | |