Fail fast mechanism when to send a task to non-exist workflow/activity queue

Hello!

I’m curious does temporal have a fail fast mechanism to prevent sending tasks to non-exist queue?

The reason to ask the question is when queue is incorrectly specified (due to refactoring for example) in Workflow/Activity options there is no exception or warning/error.

Let’s consider an example which relates to java sdk + spring boot (it’s a modified example from samples):

@WorkflowImpl(taskQueues = "HelloSampleTaskQueue")
public class HelloWorkflowImpl implements HelloWorkflow {
...
...
...
}


ResponseEntity<String> helloSample(@RequestBody Person person) {
    HelloWorkflow workflow = client.newWorkflowStub(HelloWorkflow.class,
            WorkflowOptions.newBuilder()
                .setTaskQueue("HelloSampleQueue") <------------------ queue name doesn't match
                .setWorkflowId("HelloSample")
                .build());
...
...
...
}

In that case workflow is just running

For activities you can rely on ActivityOptions->ScheduleToStart timeout, for example:

      private final MyActivities activities =
              Workflow.newActivityStub(
                  MyActivities.class,
                  ActivityOptions.newBuilder().setStartToCloseTimeout(Duration.ofSeconds(5))
                          .setScheduleToStartTimeout(Duration.ofSeconds(3))
                          .setTaskQueue("invalid_name")
                          .build());
     // ...

      try {
        activities.doSomething(input);
      } catch (ActivityFailure af) {
        if(af.getCause() instanceof TimeoutFailure) {
          TimeoutFailure tf = (TimeoutFailure) af.getCause();
          if(tf.getTimeoutType() == TimeoutType.TIMEOUT_TYPE_SCHEDULE_TO_START) {
            // route activity (schedule it again) on correct task queue if needed  
            // ...
          }
        }

@tihomir thank you very much for the quick answer!

ScheduleToStart could be a solution for my case.

But am I right that Temporal does not support any validation mechanisms for task queues because queues declaration happens only on worker registration step?

Correct, task queues configured in worker options are dynamically created if not already exist when worker starts polling.

1 Like