samples-java icon indicating copy to clipboard operation
samples-java copied to clipboard

WIP Background heartbeating and activity management utility

Open mnichols opened this issue 7 months ago • 0 comments

When an activity implementation has some call that might "hang" or take a very long time to complete, we want to be able to cancel that due to a ActivityCompletionException that was received by our activityContext.heartbeat(null) invocation.

This utility manages two threads, one for the heartbeat and the other for the Callable<T> which is the "actual" activity work that might take a while.

If the heartbeat detects the activity should be canceled, the user can provide a Predicate<Callable<T>> to answer whether to ignore the cancellation or not. If the cancellation moves forward then a non-retryable ApplicationFailure is thrown allowing the main Activity body to handle that and either ignore it or rethrow it to fail the activity.

mnichols avatar Jul 17 '24 21:07 mnichols