-
Notifications
You must be signed in to change notification settings - Fork 175
Update Java SDK #705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Java SDK #705
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
|
|
||
| package io.temporal.samples.earlyreturn; | ||
|
|
||
| import io.temporal.api.enums.v1.WorkflowIdConflictPolicy; | ||
| import io.temporal.client.*; | ||
| import io.temporal.serviceclient.WorkflowServiceStubs; | ||
|
|
||
|
|
@@ -49,17 +50,13 @@ private static void runWorkflowWithUpdateWithStart(WorkflowClient client) { | |
|
|
||
| System.out.println("Starting workflow with UpdateWithStart"); | ||
|
|
||
| UpdateWithStartWorkflowOperation<TxResult> updateOp = | ||
| UpdateWithStartWorkflowOperation.newBuilder(workflow::returnInitResult) | ||
| .setWaitForStage(WorkflowUpdateStage.COMPLETED) // Wait for update to complete | ||
| .build(); | ||
|
|
||
| TxResult updateResult = null; | ||
| try { | ||
| WorkflowUpdateHandle<TxResult> updateHandle = | ||
| WorkflowClient.updateWithStart(workflow::processTransaction, txRequest, updateOp); | ||
|
|
||
| updateResult = updateHandle.getResultAsync().get(); | ||
| updateResult = | ||
| WorkflowClient.executeUpdateWithStart( | ||
| workflow::returnInitResult, | ||
| UpdateOptions.<TxResult>newBuilder().build(), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Much cleaner implementation! |
||
| new WithStartWorkflowOperation<>(workflow::processTransaction, txRequest)); | ||
|
|
||
| System.out.println( | ||
| "Workflow initialized with result: " | ||
|
|
@@ -84,6 +81,7 @@ private static void runWorkflowWithUpdateWithStart(WorkflowClient client) { | |
| private static WorkflowOptions buildWorkflowOptions() { | ||
| return WorkflowOptions.newBuilder() | ||
| .setTaskQueue(TASK_QUEUE) | ||
| .setWorkflowIdConflictPolicy(WorkflowIdConflictPolicy.WORKFLOW_ID_CONFLICT_POLICY_FAIL) | ||
| .setWorkflowId(WORKFLOW_ID_PREFIX + System.currentTimeMillis()) | ||
| .build(); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,9 +105,8 @@ public void testUpdateIdempotency() { | |
| .newWorkflowStub( | ||
| ClusterManagerWorkflow.class, | ||
| WorkflowOptions.newBuilder().setTaskQueue(testWorkflowRule.getTaskQueue()).build()); | ||
| CompletableFuture<ClusterManagerWorkflow.ClusterManagerResult> result = | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got an error for an unused variable 🤷 |
||
| WorkflowClient.execute( | ||
| cluster::run, new ClusterManagerWorkflow.ClusterManagerInput(Optional.empty(), false)); | ||
| WorkflowClient.execute( | ||
| cluster::run, new ClusterManagerWorkflow.ClusterManagerInput(Optional.empty(), false)); | ||
|
|
||
| cluster.startCluster(); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To provide a base implementation for Nexus.