Open
Description
Is your feature request related to a problem? Please describe.
Currently, the only way for an activity to know that it's canceled is heartbeating and getting a CancellationException from the heartbeat.
- Not all activities need to heartbeat and making them do it just to check for cancelation is ugly.
- Local Activities don't heartbeat, so now there is no way to notify them that they should cancel (for example, because there is a timeout). GoSDK has go context for it, Java has nothing. Using Interruption here is not right, because we need to distinguish it from a thread interruption during the shutdown to keep things clean.
Describe the solution you'd like
ActivityExecutionContext#isCancelled method that activity can periodically check as an alternative to listening cancelations through heart beating. This solution will be close to the native Interruption design in Java: We will have an exception if Activity calls a heartbeat and a flag otherwise.
Additional context
This is related to #1004. There is no way to notify Local Activity about the cancelation.