samples-java
samples-java copied to clipboard
WIP Background heartbeating and activity management utility
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.