Class WorkflowWorker

    • Constructor Summary

      Constructors 
      Constructor Description
      WorkflowWorker​(io.temporal.serviceclient.WorkflowServiceStubs service, java.lang.String namespace, java.lang.String taskQueue, java.lang.String stickyTaskQueueName, SingleWorkerOptions options, WorkflowTaskHandler handler)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void apply​(io.temporal.api.workflowservice.v1.PollWorkflowTaskQueueResponse pollWorkflowTaskQueueResponse)  
      void awaitTermination​(long timeout, java.util.concurrent.TimeUnit unit)  
      boolean isShutdown()  
      boolean isStarted()  
      boolean isSuspended()  
      boolean isTerminated()  
      void resumePolling()
      Allow new poll requests.
      java.util.concurrent.CompletableFuture<java.lang.Void> shutdown​(ShutdownManager shutdownManager, boolean interruptTasks)  
      void start()  
      void suspendPolling()
      Do not make new poll requests.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • WorkflowWorker

        public WorkflowWorker​(@Nonnull
                              io.temporal.serviceclient.WorkflowServiceStubs service,
                              @Nonnull
                              java.lang.String namespace,
                              @Nonnull
                              java.lang.String taskQueue,
                              @Nullable
                              java.lang.String stickyTaskQueueName,
                              @Nonnull
                              SingleWorkerOptions options,
                              @Nonnull
                              WorkflowTaskHandler handler)
    • Method Detail

      • start

        public void start()
        Specified by:
        start in interface Startable
      • shutdown

        public java.util.concurrent.CompletableFuture<java.lang.Void> shutdown​(ShutdownManager shutdownManager,
                                                                               boolean interruptTasks)
        Specified by:
        shutdown in interface Shutdownable
        Parameters:
        shutdownManager - provides toolset to get a Future for a shutdown of instances that have both non-blocking and not returning a Future on a completion shutdown methods (like ExecutorService.shutdown())
        interruptTasks - if the threads processing user code (like workflows, workflow tasks or activities) should be interrupted, or we want to wait for their full graceful completion
        Returns:
        CompletableFuture which should be completed when awaiting downstream dependencies can proceed with their own shutdown. Should never be completed exceptionally CompletableFuture.exceptionally(Function) as downstream dependencies have no use of this information (they need to perform a shutdown anyway), and it complicates the shutdown flow.
      • awaitTermination

        public void awaitTermination​(long timeout,
                                     java.util.concurrent.TimeUnit unit)
        Specified by:
        awaitTermination in interface Shutdownable
      • suspendPolling

        public void suspendPolling()
        Description copied from interface: Suspendable
        Do not make new poll requests. Outstanding long polls still can return tasks after this method was called.
        Specified by:
        suspendPolling in interface Suspendable
      • apply

        public void apply​(io.temporal.api.workflowservice.v1.PollWorkflowTaskQueueResponse pollWorkflowTaskQueueResponse)
        Specified by:
        apply in interface Functions.Proc1<io.temporal.api.workflowservice.v1.PollWorkflowTaskQueueResponse>