Class WorkflowRuntime

java.lang.Object
io.dapr.workflows.runtime.WorkflowRuntime
All Implemented Interfaces:
AutoCloseable

public class WorkflowRuntime extends Object implements AutoCloseable
Contains methods to register workflows and activities.
  • Constructor Details

    • WorkflowRuntime

      public WorkflowRuntime(DurableTaskGrpcWorker worker, io.grpc.ManagedChannel managedChannel, ExecutorService executorService)
      Constructor.
      Parameters:
      worker - grpcWorker processing activities.
      managedChannel - grpc channel.
      executorService - executor service responsible for running the threads.
    • WorkflowRuntime

      public WorkflowRuntime(DurableTaskGrpcWorker worker, io.grpc.ManagedChannel managedChannel, ExecutorService executorService, @Nullable GrpcChannelKeepalive keepalive)
      Constructor.
      Parameters:
      worker - grpcWorker processing activities.
      managedChannel - grpc channel.
      executorService - executor service responsible for running the threads.
      keepalive - application-level keepalive on the worker's channel, started with start() and stopped on close(). May be null when no keepalive is wanted.
  • Method Details

    • start

      public void start()
      Start the Workflow runtime processing items and block.
    • start

      public void start(boolean block)
      Start the Workflow runtime processing items.
      Parameters:
      block - block the thread if true
    • close

      public void close()
      Stops the runtime and releases its resources. Calling it more than once has no further effect.

      Shutdown happens in dependency order: the keepalive and the worker are stopped first so the work-item stream is cancelled and no new work is accepted, then the executor drains any in-flight activities, and only then is the sidecar channel shut down. Shutting the channel down while the worker still holds the stream open would block until the channel's termination timeout elapsed.

      Once closed, a runtime cannot be restarted. WorkflowRuntimeBuilder.build() builds a fresh runtime when the previous one has been closed.

      Specified by:
      close in interface AutoCloseable
    • isClosed

      public boolean isClosed()
      Whether close() has been called on this runtime.
      Returns:
      true once the runtime has been closed.