Interface ActivityCompletionClient
ActivityExecutionContext.doNotCompleteOnReturn().
Use WorkflowClient.newActivityCompletionClient() to create an instance.
-
Method Summary
Modifier and TypeMethodDescription<R> voidcomplete(byte[] taskToken, R result) Completes an activity execution successfully using a task token.<R> voidCompletes a workflow activity execution successfully using workflow and activity IDs.voidcompleteExceptionally(byte[] taskToken, Exception result) Completes an activity execution with failure using a task token.voidcompleteExceptionally(String workflowId, Optional<String> runId, String activityId, Exception result) Completes a workflow activity execution with failure using workflow and activity IDs.voidcompleteExceptionallyStandalone(String activityId, Optional<String> activityRunId, Exception result) Completes a standalone activity execution with failure using activity ID.<R> voidcompleteStandalone(String activityId, Optional<String> activityRunId, R result) Completes a standalone activity execution successfully using activity ID.<V> voidheartbeat(byte[] taskToken, V details) Records a heartbeat for an activity using a task token.<V> voidRecords a heartbeat for a workflow activity using workflow and activity IDs.<V> voidheartbeatStandalone(String activityId, Optional<String> activityRunId, V details) Records a heartbeat for a standalone activity using activity ID.<V> voidreportCancellation(byte[] taskToken, V details) Confirms successful cancellation to the server using a task token.<V> voidreportCancellation(String workflowId, Optional<String> runId, String activityId, V details) Confirms successful cancellation of a workflow activity to the server using workflow and activity IDs.<V> voidreportCancellationStandalone(String activityId, Optional<String> activityRunId, V details) Confirms successful cancellation of a standalone activity to the server using activity ID.withContext(ActivitySerializationContext context) Supply this context if correct serialization of activity heartbeats, results or other payloads requiresDataConverter,PayloadConverterorPayloadCodecto be aware ofActivitySerializationContext.withContext(NexusSerializationContext context) Supply this context when completing a standalone activity started by a Nexus operation handler, so its result, failure and heartbeat details are encoded with the context the Nexus caller decodes them with.
-
Method Details
-
complete
Completes an activity execution successfully using a task token.This overload works with both workflow activities and standalone activities.
- Parameters:
taskToken- token of the activity attempt to completeresult- of the activity execution- Throws:
ActivityCompletionException
-
complete
<R> void complete(String workflowId, Optional<String> runId, String activityId, R result) throws ActivityCompletionException Completes a workflow activity execution successfully using workflow and activity IDs.This overload is only for workflow activities. To complete a standalone activity by ID, use
completeStandalone(String, Optional, Object).- Parameters:
workflowId- id of the workflow that started the activityrunId- optional run id of the workflow that started the activityactivityId- id of the activityresult- of the activity execution- Throws:
ActivityCompletionException
-
completeStandalone
<R> void completeStandalone(String activityId, Optional<String> activityRunId, R result) throws ActivityCompletionException Completes a standalone activity execution successfully using activity ID.This method is only for standalone activities. To complete a workflow activity by ID, use
complete(String, Optional, String, Object).- Parameters:
activityId- id of the standalone activityactivityRunId- optional run id of the standalone activity, orOptional.empty()result- of the activity execution- Throws:
ActivityCompletionException
-
completeExceptionally
Completes an activity execution with failure using a task token.This overload works with both workflow activities and standalone activities.
- Parameters:
taskToken- token of the activity attempt to completeresult- the exception to be used as a failure details object- Throws:
ActivityCompletionException
-
completeExceptionally
void completeExceptionally(String workflowId, Optional<String> runId, String activityId, Exception result) throws ActivityCompletionException Completes a workflow activity execution with failure using workflow and activity IDs.This overload is only for workflow activities. To complete a standalone activity by ID, use
completeExceptionallyStandalone(String, Optional, Exception).- Parameters:
workflowId- id of the workflow that started the activityrunId- optional run id of the workflow that started the activityactivityId- id of the activityresult- the exception to be used as a failure details object- Throws:
ActivityCompletionException
-
completeExceptionallyStandalone
void completeExceptionallyStandalone(String activityId, Optional<String> activityRunId, Exception result) throws ActivityCompletionException Completes a standalone activity execution with failure using activity ID.This method is only for standalone activities. To complete a workflow activity by ID, use
completeExceptionally(String, Optional, String, Exception).- Parameters:
activityId- id of the standalone activityactivityRunId- optional run id of the standalone activity, orOptional.empty()result- the exception to be used as a failure details object- Throws:
ActivityCompletionException
-
reportCancellation
Confirms successful cancellation to the server using a task token.This overload works with both workflow activities and standalone activities.
- Parameters:
taskToken- token of the activity attemptdetails- details to record with the cancellation- Throws:
ActivityCompletionException
-
reportCancellation
<V> void reportCancellation(String workflowId, Optional<String> runId, String activityId, V details) throws ActivityCompletionException Confirms successful cancellation of a workflow activity to the server using workflow and activity IDs.This overload is only for workflow activities. To cancel a standalone activity by ID, use
reportCancellationStandalone(String, Optional, Object).- Parameters:
workflowId- id of the workflow that started the activityrunId- optional run id of the workflow that started the activityactivityId- id of the activitydetails- details to record with the cancellation- Throws:
ActivityCompletionException
-
reportCancellationStandalone
<V> void reportCancellationStandalone(String activityId, Optional<String> activityRunId, V details) throws ActivityCompletionException Confirms successful cancellation of a standalone activity to the server using activity ID.This method is only for standalone activities. To cancel a workflow activity by ID, use
reportCancellation(String, Optional, String, Object).- Parameters:
activityId- id of the standalone activityactivityRunId- optional run id of the standalone activity, orOptional.empty()details- details to record with the cancellation- Throws:
ActivityCompletionException
-
heartbeat
Records a heartbeat for an activity using a task token.This overload works with both workflow activities and standalone activities.
- Parameters:
taskToken- token of the activity attemptdetails- details to record with the heartbeat- Throws:
ActivityCompletionException- if activity should stop executing
-
heartbeat
<V> void heartbeat(String workflowId, Optional<String> runId, String activityId, V details) throws ActivityCompletionException Records a heartbeat for a workflow activity using workflow and activity IDs.This overload is only for workflow activities. To heartbeat a standalone activity by ID, use
heartbeatStandalone(String, Optional, Object).- Parameters:
workflowId- id of the workflow that started the activityrunId- optional run id of the workflow that started the activityactivityId- id of the activitydetails- details to record with the heartbeat- Throws:
ActivityCompletionException- if activity should stop executing
-
heartbeatStandalone
<V> void heartbeatStandalone(String activityId, Optional<String> activityRunId, V details) throws ActivityCompletionException Records a heartbeat for a standalone activity using activity ID.This method is only for standalone activities. To heartbeat a workflow activity by ID, use
heartbeat(String, Optional, String, Object).- Parameters:
activityId- id of the standalone activityactivityRunId- optional run id of the standalone activity, orOptional.empty()details- details to record with the heartbeat- Throws:
ActivityCompletionException- if activity should stop executing
-
withContext
@Experimental @Nonnull ActivityCompletionClient withContext(@Nonnull ActivitySerializationContext context) Supply this context if correct serialization of activity heartbeats, results or other payloads requiresDataConverter,PayloadConverterorPayloadCodecto be aware ofActivitySerializationContext.- Parameters:
context- provides information to the data converter about the abstraction the data belongs to- Returns:
- an instance of DataConverter that may use the provided
contextfor serialization - See Also:
-
withContext
@Experimental @Nonnull ActivityCompletionClient withContext(@Nonnull NexusSerializationContext context) Supply this context when completing a standalone activity started by a Nexus operation handler, so its result, failure and heartbeat details are encoded with the context the Nexus caller decodes them with. Get it fromActivityInfo.getNexusSerializationContext()and store it together with the task token.- Parameters:
context- the Nexus context of the operation handler that started the activity- Returns:
- an instance of ActivityCompletionClient that uses the provided
contextfor serialization - See Also:
-