Skip to content

Conversation

@tsurdilo
Copy link
Contributor

sample that shows use of workflow timer instead of using workflow run/exec timeouts

Signed-off-by: Tihomir Surdilovic <tihomir@temporal.io>
@tsurdilo tsurdilo requested review from a team and antmendoza as code owners December 30, 2024 22:30
Copy link
Member

@antmendoza antmendoza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tsurdilo

Comment on lines +74 to +88
Workflow.newTimer(
Duration.ofSeconds(TIME_SECS),
TimerOptions.newBuilder().setSummary("Workflow Timer").build())
// We can use thenApply here to cancel our cancelation scope when this timer
// fires. Note we cannot complete the execution from here, see
// https://github.com/temporalio/sdk-java/issues/87
.thenApply(
ignore -> {
// Cancel the workflow cancellation scope allowing us to react to this
// timer firing
if (workflowCancellationScope != null) {
workflowCancellationScope.cancel("Workflow timer fired");
}
return null;
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if having this block inside workflowCancellationScope would produce the same output, so we might not need two cencellationScopes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you could. having separate maybe cleaner as then we dont cancel scope within itself. wdyt?

@tsurdilo tsurdilo merged commit 30db7db into main Dec 31, 2024
8 checks passed
@tsurdilo tsurdilo deleted the workflowtimer branch December 31, 2024 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants