Skip to content

Commit cec7aa7

Browse files
committed
removed executeTaskAsync method
1 parent 8749cb5 commit cec7aa7

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

core/src/main/java/io/temporal/samples/taskinteraction/TaskService.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import com.fasterxml.jackson.annotation.JsonIgnore;
2323
import io.temporal.workflow.CompletablePromise;
24-
import io.temporal.workflow.Promise;
2524
import io.temporal.workflow.Workflow;
2625
import java.util.Collections;
2726
import java.util.HashMap;
@@ -74,10 +73,6 @@ public TaskService() {
7473
private final Logger logger = Workflow.getLogger(TaskService.class);
7574

7675
public R executeTask(Callback<R> callback, String token) {
77-
return executeTaskAsync(callback, token).get();
78-
}
79-
80-
public Promise<R> executeTaskAsync(Callback<R> callback, String token) {
8176

8277
final Task task = new Task(token);
8378
logger.info("Before creating task : " + task);
@@ -88,7 +83,7 @@ public Promise<R> executeTaskAsync(Callback<R> callback, String token) {
8883
final CompletablePromise<R> promise = Workflow.newPromise();
8984
pendingPromises.put(token, promise);
9085

91-
return promise;
86+
return promise.get();
9287
}
9388

9489
public List<Task> getOpenTasks() {

core/src/main/java/io/temporal/samples/taskinteraction/TaskWorkflowImpl.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package io.temporal.samples.taskinteraction;
2121

2222
import io.temporal.activity.ActivityOptions;
23+
import io.temporal.workflow.Async;
2324
import io.temporal.workflow.Promise;
2425
import io.temporal.workflow.Workflow;
2526
import java.time.Duration;
@@ -45,9 +46,14 @@ public void execute() {
4546
// to change the task state, and ultimately to complete the task
4647
logger.info("About to create async tasks");
4748
final Promise<String> task1 =
48-
taskService.executeTaskAsync(() -> activity.createTask("TODO 1"), taskToken.getNext());
49+
Async.function(
50+
() ->
51+
taskService.executeTask(() -> activity.createTask("TODO 1"), taskToken.getNext()));
52+
4953
final Promise<String> task2 =
50-
taskService.executeTaskAsync(() -> activity.createTask("TODO 2"), taskToken.getNext());
54+
Async.function(
55+
() ->
56+
taskService.executeTask(() -> activity.createTask("TODO 2"), taskToken.getNext()));
5157

5258
logger.info("Awaiting for two tasks to get completed");
5359
// Block execution until both tasks complete

0 commit comments

Comments
 (0)