Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions core/src/main/java/io/temporal/samples/hello/HelloUpdate.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@

import com.google.common.base.Throwables;
import io.temporal.activity.ActivityOptions;
import io.temporal.client.UpdateHandle;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
import io.temporal.client.WorkflowStub;
import io.temporal.client.WorkflowUpdateException;
import io.temporal.client.WorkflowUpdateStage;
import io.temporal.failure.ApplicationFailure;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
Expand Down Expand Up @@ -250,6 +252,17 @@ public static void main(String[] args) throws Exception {
WorkflowStub greetingStub = client.newUntypedWorkflowStub(WORKFLOW_ID);
greetingStub.update("addGreeting", int.class, "Temporal");

/*
* Use the untyped stub to start an update, but wait only until it's
* accepted, receiving an update handle in return. Then use the update
* handle to get the result.
*/
UpdateHandle<Integer> updateHandle =
greetingStub.startUpdate(
"addGreeting", WorkflowUpdateStage.ACCEPTED, int.class, "Started asynchronously");

updateHandle.getResultAsync().get();

try {
// The update request will fail on a empty name and the exception will be thrown here.
workflowById.addGreeting("");
Expand Down