How to handle Poller exceptions

I have this up and running:

WorkerFactory factory = WorkerFactory.newInstance(client);
WorkerOptions o = WorkerOptions.newBuilder()
                .setXXX()
                ...
                .build();
 Worker worker = factory.newWorker(temporalConfiguration.getTaskQueue(), o);

Now I want to handle exceptions thrown by the ThreadPoolExecutor backed by Poller class.

PollerOptions pollerOptions = PollerOptions.newBuilder()
                .setUncaughtExceptionHandler(handler)
                .build();

My question is, how can I set that PollerOptions while creating the Worker?
On WorkerOptions builder I can’t see any setter for PollerOptions.
I have tried on Temporal versions 1.17.0 and 1.19.0.

Regards,

Hi, can you help me please?

I don’t think it is exposed. What is the problem you are trying to solve?

When starting my WORKER, depending on the error condition, I can receive an stacktrace like this:

2023-05-22 20:33:22,151 WARN  [worker] [Workflow Poller taskQueue="tq1234", namespace="default": 2] [] io.temporal.internal.worker.Poller: Failure in poller thread Workflow Poller taskQueue="tq1234", namespace="default": 2
io.grpc.StatusRuntimeException: UNIMPLEMENTED: unknown service temporal.api.workflowservice.v1.WorkflowService
	at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:271)
	at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:252)
	at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:165)
	at io.temporal.api.workflowservice.v1.WorkflowServiceGrpc$WorkflowServiceBlockingStub.pollWorkflowTaskQueue(WorkflowServiceGrpc.java:3750)
	at io.temporal.internal.worker.WorkflowPollTask.doPoll(WorkflowPollTask.java:140)
	at io.temporal.internal.worker.WorkflowPollTask.poll(WorkflowPollTask.java:122)
	at io.temporal.internal.worker.WorkflowPollTask.poll(WorkflowPollTask.java:43)
	at io.temporal.internal.worker.Poller$PollExecutionTask.run(Poller.java:274)
	at io.temporal.internal.worker.Poller$PollLoopTask.run(Poller.java:237)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

It would be useful for me to handle those Poller exceptions and for example report them to my monitoring platform. That’s why I want to set the exception handler.

Would you file a feature request against the SDK?

1 Like