Open Spikhalskiy opened 2 years ago
fun signalWorkflow(workflowId: String, signalName: String, vararg args: Any) { try { Workflow.newUntypedExternalWorkflowStub(workflowId).signal(signalName, args) } catch (ex: ApplicationFailure) { if (ex.type == "SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_EXTERNAL_WORKFLOW_EXECUTION_NOT_FOUND") { logger.info { it.message("Workflow not found while attempting to send signal to it.") .value("workflowId", workflowId).value("signal", signalName) } } } }
The code above shouldn't work and ApplicationFailure is an incorrect exception to be thrown here.
ApplicationFailure
There is already an exception for this situation: SignalExternalWorkflowException that is currently not created anywhere.
SignalExternalWorkflowException
There is also a todo to implement exactly this that never was done: https://github.com/temporalio/sdk-java/blob/37a0e463fae2312882b5c946f423a0dbf85f9666/temporal-sdk/src/main/java/io/temporal/internal/statemachines/SignalExternalStateMachine.java#L152
Another alternative exception to consider here may be WorkflowNotFoundException
WorkflowNotFoundException
@Spikhalskiy @Quinn-With-Two-Ns This would be a backwards incompatible change for users who have implemented their code by catching ApplicationFailure type right?
Actual Behavior
The code above shouldn't work and
ApplicationFailure
is an incorrect exception to be thrown here.Additional context
There is already an exception for this situation:
SignalExternalWorkflowException
that is currently not created anywhere.There is also a todo to implement exactly this that never was done: https://github.com/temporalio/sdk-java/blob/37a0e463fae2312882b5c946f423a0dbf85f9666/temporal-sdk/src/main/java/io/temporal/internal/statemachines/SignalExternalStateMachine.java#L152
Another alternative exception to consider here may be
WorkflowNotFoundException