The general pattern is that methods that belong to Workflow class can be called only from workflow code. Methods that belong to WorkflowClient class can be called only by non workflow code.
new…WorkflowStub methods have two variants. The first one takes options and creates stub that can be used to start workflow execution. The second takes workflowId and optional runId and can be used to signal and query an existing workflow.
How can one find the exact runId to send a signal?
When a workflow is started a runId is returned to the caller.
WorkflowExecution execution = WorkflowClient.start(transferWorkflow::transfer, from, to, reference, amountCents);
System.out.println(execution.getRunId());
runId is optional when calling SignalWorkflowExecution. If you don’t specify it the client is going to signal whatever run is currently running with the given WorkflowId.
@maxim
I’m trying to send a signal to Go workflow from a java activity. But I get
“trace”: "java.lang.Error: Called from non workflow or workflow callback thread\n\tat io.temporal.internal.sync.DeterministicRunnerImpl.currentThreadInternal(DeterministicRunnerImpl.java...
I am able to send a signal from Go to Java, but I’m not able to do the reverse.
@maxim but a workflow client’s method needs the class name of the workflow to which it has to send a signal, right? The workflow I want to send a signal to is a Go workflow. How can I do this?
GreetingWorkflow workflow = client.newWorkflowStub(GreetingWorkflow.class, workflowOptions);//need class, suppose GreetingWorkFlow is in Go