public final class SimpleWithUnicastCommunication extends java.lang.Object implements java.lang.Runnable, UnicastMessageListener<java.lang.String>
This example shows how the compute level can communicate between nodes using unicast messages.
Unicast messaging is performed in regards of the topology defined in the platform level and the messages cane be sent only to neighbours of the current node.
Sent messages can have any serializable payload.
To receive messages, the runnable must register a UnicastMessageListener
using UnicastMessenger.registerListener(pl.edu.agh.age.compute.api.UnicastMessageListener<T>)
.
TopologyService
Modifier and Type | Field and Description |
---|---|
private static org.slf4j.Logger |
logger |
private UnicastMessenger |
messenger |
Constructor and Description |
---|
SimpleWithUnicastCommunication(UnicastMessenger messenger) |
Modifier and Type | Method and Description |
---|---|
void |
onUnicastMessage(@NonNull java.lang.String message,
@NonNull WorkerAddress sender) |
void |
run() |
java.lang.String |
toString() |
private static final org.slf4j.Logger logger
private final UnicastMessenger messenger
@Inject public SimpleWithUnicastCommunication(UnicastMessenger messenger)
public void run()
run
in interface java.lang.Runnable
public java.lang.String toString()
toString
in class java.lang.Object
public void onUnicastMessage(@NonNull java.lang.String message, @NonNull WorkerAddress sender)
onUnicastMessage
in interface UnicastMessageListener<java.lang.String>