8000 Provide ActivityExecutionContext#isCancelled · Issue #1005 · temporalio/sdk-java · GitHub
[go: up one dir, main page]

Skip to content
Provide ActivityExecutionContext#isCancelled #1005
Open
@Spikhalskiy

Description

@Spikhalskiy

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.

  1. Not all activities need to heartbeat and making them do it just to check for cancelation is ugly.
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0