Client Usage
Send A Signal To A Workflow
It is possible to send a signal to running workflows. Sending signals is done through channels that must be described in the workflow interface, for example:
public interface HelloWorkflow {
SendChannel<String> getNotificationChannel();
String greet(String name);
}
interface HelloWorkflow {
val notificationChannel: SendChannel<String>
fun greet(name: String): String
}
This signal can be any serializable object of the type described in the workflow interface.
We can send an object to a running instance targeted by id:
// stub targeting a running HelloWorkflow workflow with a specific id
HelloWorkflow w =
client.getWorkflowById(HelloWorkflow.class, "05694902-5aa4-469f-824c-7015b0df906c");
// send a signal to this instance through a channnel
w.getNotificationChannel().send("foobar");
// stub targeting a running HelloWorkflow workflow with a specific id
val w : HelloWorkflow =
client.getWorkflowById(HelloWorkflow::class.java, "05694902-5aa4-469f-824c-7015b0df906c")
// send a signal to this instance through a channnel
w.notificationChannel.send("foobar")
or running instances targeted by tag:
// stub targeting running HelloWorkflow workflows with a specific tag
HelloWorkflow w =
client.getWorkflowByTag(HelloWorkflow.class, "foo");
// send a signal to those instances through a channnel
w.getNotificationChannel().send("foobar");
// stub targeting running HelloWorkflow workflows with a specific tag
val w : HelloWorkflow =
client.getWorkflowByTag(HelloWorkflow::class.java, "tag")
// send a signal to those instances through a channnel
w.notificationChannel.send("foobar")