Package io.dapr.workflows.runtime
Class WorkflowRuntime
java.lang.Object
io.dapr.workflows.runtime.WorkflowRuntime
- All Implemented Interfaces:
AutoCloseable
Contains methods to register workflows and activities.
-
Constructor Summary
ConstructorsConstructorDescriptionWorkflowRuntime(DurableTaskGrpcWorker worker, io.grpc.ManagedChannel managedChannel, ExecutorService executorService) Constructor.WorkflowRuntime(DurableTaskGrpcWorker worker, io.grpc.ManagedChannel managedChannel, ExecutorService executorService, GrpcChannelKeepalive keepalive) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Stops the runtime and releases its resources.booleanisClosed()Whetherclose()has been called on this runtime.voidstart()Start the Workflow runtime processing items and block.voidstart(boolean block) Start the Workflow runtime processing items.
-
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 withstart()and stopped onclose(). 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:
closein interfaceAutoCloseable
-
isClosed
public boolean isClosed()Whetherclose()has been called on this runtime.- Returns:
- true once the runtime has been closed.
-