Caused by: java.lang.IllegalArgumentException: No worker for taskQueue

Hi temporal,

I was running worker in one instance and it says:
13:16:00.827 [main] INFO i.t.s.b.a.template.WorkersTemplate - Creating configured worker for a task queue ACT-TXN-TASK-QUEUE
13:16:00.864 [main] INFO i.t.s.b.a.template.WorkersTemplate - Registering auto-discovered workflow class class helloworldapp.versioning_strategy.workflow.impl.ClientTxnWorkflowImpl on a worker ‘transactionWorker’ with a task queue ‘WORK-TXN-TASK-QUEUE’

I was trying to get the worker in another instance
@Autowired
WorkflowClient workflowClient;

*//My method: *
WorkerFactory factory = WorkerFactory.newInstance(workflowClient);
factory.getWorker(“ACT-TXN-TASK-QUEUE”).suspendPolling();

This workflowClient can be autowired successfully, but getWorker throws exception: Caused by: java.lang.IllegalArgumentException: No worker for taskQueue. May i know how should I properly get worker?

Best regards,
Jx

Hi @jxwang

I guess WorkerFactory.newInstance returns a different instance from the one used to create the workers.

Could you try injecting the workerFactory directly?

@Autowired WorkerFactory workerFactory;

Antonio

Hi Antonio,

Our worker is running in one micro service. The Stop command will be triggering from another service controlled by ops team.
So in ops service this will be the config, the start workers will be set to false and no worker will be registered there.
spring:
application:
name: application
temporal:
connection:
target: 127.0.0.1:7233
namespace: default
start-workers: false
So it failed to autowire worker factory.
Any solution to stop a particular worker from another service?

Best regards,
Jx

Hi @jxwang

Any solution to stop a particular worker from another service?

Could you expose an endpoint in your worker service?

Antonio