How do I send a signal to a workflow A which was started in Go from a workflow B started in Java?
I tried this: Workflow.newUntypedExternalWorkflowStub("GO_JAVA_WORK_ID").signal("sigName", true);
but I get an error: called from non workflow or workflow callback thread
This is Go for listening for the channel
var signalVal string
signalChan := workflow.GetSignalChannel(ctx, "sigName")
s := workflow.NewSelector(ctx)
s.AddReceive(signalChan, func(c workflow.ReceiveChannel, more bool) {
c.Receive(ctx, &signalVal)
fmt.Println("Received signal", signalVal)
})
s.Select(ctx)
Here is a little demo that does this: GitHub - tsurdilo/temporal-polyglot
Where are you creating the newUntypedExternalWorkflowStub and signalling?
Also, the second parameter of your . signal(…) in your Java code from what can tell should be a string type as that is the signal value type you are expecting in your Go workflow.
@tihomir I’m creating the newUntypedExternalWorkflowStub in the java activity.
Thanks for making the example. But, I still get the same error called from non workflow or workflow callback thread
"trace": "java.lang.Error: Called from non workflow or workflow callback thread\n\tat io.temporal.internal.sync.DeterministicRunnerImpl.currentThreadInternal(DeterministicRunnerImpl.java:135)\n\tSuppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: \nError has been observed at the following site(s):\n\t|_ checkpoint ⇢ springfox.boot.starter.autoconfigure.SwaggerUiWebFluxConfiguration$CustomWebFilter [DefaultWebFilterChain]\n\t|_ checkpoint ⇢ org.springframework.security.web.server.authorization.AuthorizationWebFilter [DefaultWebFilterChain]\n\t|_ checkpoint ⇢
@Abhilash_M Could you share your code or a test that reproduces the issue you are running into so we can take a look? Especially how you are starting the workflow execution would be good to see.
Don’t call functions on the Workflow class outside the workflow code. Use WorkflowClient APIs instead. Or better call these APIs from the workflow code without an activity.