Skip to content

Commit 8b880bc

Browse files
committed
Revert "chore: New task execution task id test (dapr#1352)"
This reverts commit 949584f.
1 parent 949584f commit 8b880bc

File tree

9 files changed

+7
-222
lines changed

9 files changed

+7
-222
lines changed

daprdocs/content/en/java-sdk-docs/java-workflow/java-workflow-howto.md

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ weight: 20000
66
description: How to get up and running with workflows using the Dapr Java SDK
77
---
88

9-
Let's create a Dapr workflow and invoke it using the console. With the [provided workflow example](https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples/workflows), you will:
9+
Lets create a Dapr workflow and invoke it using the console. With the [provided workflow example](https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples/workflows), you will:
1010

1111
- Execute the workflow instance using the [Java workflow worker](https://github.com/dapr/java-sdk/blob/master/examples/src/main/java/io/dapr/examples/workflows/DemoWorkflowWorker.java)
1212
- Utilize the Java workflow client and API calls to [start and terminate workflow instances](https://github.com/dapr/java-sdk/blob/master/examples/src/main/java/io/dapr/examples/workflows/DemoWorkflowClient.java)
@@ -85,10 +85,11 @@ You're up and running! Both Dapr and your app logs will appear here.
8585
== APP == INFO: Durable Task worker is connecting to sidecar at 127.0.0.1:50001.
8686
```
8787

88-
## Run the `DemoWorkflowClient`
88+
## Run the `DemoWorkflowClient
8989

9090
The `DemoWorkflowClient` starts instances of workflows that have been registered with Dapr.
9191

92+
9293
```java
9394
public class DemoWorkflowClient {
9495

@@ -245,40 +246,4 @@ Exiting DemoWorkflowClient.
245246

246247
## Next steps
247248
- [Learn more about Dapr workflow]({{< ref workflow-overview.md >}})
248-
- [Workflow API reference]({{< ref workflow_api.md >}})
249-
250-
## Advanced features
251-
252-
### Task Execution Keys
253-
254-
Task execution keys are unique identifiers generated by the durabletask-java library. They are stored in the `WorkflowActivityContext` and can be used to track and manage the execution of workflow activities. They are particularly useful for:
255-
256-
1. **Idempotency**: Ensuring activities are not executed multiple times for the same task
257-
2. **State Management**: Tracking the state of activity execution
258-
3. **Error Handling**: Managing retries and failures in a controlled manner
259-
260-
Here's an example of how to use task execution keys in your workflow activities:
261-
262-
```java
263-
public class TaskExecutionKeyActivity implements WorkflowActivity {
264-
@Override
265-
public Object run(WorkflowActivityContext ctx) {
266-
// Get the task execution key for this activity
267-
String taskExecutionKey = ctx.getTaskExecutionKey();
268-
269-
// Use the key to implement idempotency or state management
270-
// For example, check if this task has already been executed
271-
if (isTaskAlreadyExecuted(taskExecutionKey)) {
272-
return getPreviousResult(taskExecutionKey);
273-
}
274-
275-
// Execute the activity logic
276-
Object result = executeActivityLogic();
277-
278-
// Store the result with the task execution key
279-
storeResult(taskExecutionKey, result);
280-
281-
return result;
282-
}
283-
}
284-
```
249+
- [Workflow API reference]({{< ref workflow_api.md >}})

sdk-tests/src/test/java/io/dapr/it/testcontainers/DaprWorkflowsIT.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import com.fasterxml.jackson.core.JsonProcessingException;
1717
import com.fasterxml.jackson.databind.ObjectMapper;
18-
1918
import io.dapr.testcontainers.Component;
2019
import io.dapr.testcontainers.DaprContainer;
2120
import io.dapr.testcontainers.DaprLogLevel;
@@ -41,7 +40,6 @@
4140
import java.util.Map;
4241

4342
import static io.dapr.it.testcontainers.ContainerConstants.DAPR_RUNTIME_IMAGE_TAG;
44-
import static org.junit.Assert.assertTrue;
4543
import static org.junit.jupiter.api.Assertions.assertEquals;
4644
import static org.junit.jupiter.api.Assertions.assertNotNull;
4745

@@ -119,29 +117,6 @@ public void testWorkflows() throws Exception {
119117
assertEquals(instanceId, workflowOutput.getWorkflowId());
120118
}
121119

122-
@Test
123-
public void testExecutionKeyWorkflows() throws Exception {
124-
TestWorkflowPayload payload = new TestWorkflowPayload(new ArrayList<>());
125-
String instanceId = workflowClient.scheduleNewWorkflow(TestExecutionKeysWorkflow.class, payload);
126-
127-
workflowClient.waitForInstanceStart(instanceId, Duration.ofSeconds(100), false);
128-
129-
Duration timeout = Duration.ofSeconds(1000);
130-
WorkflowInstanceStatus workflowStatus = workflowClient.waitForInstanceCompletion(instanceId, timeout, true);
131-
132-
assertNotNull(workflowStatus);
133-
134-
TestWorkflowPayload workflowOutput = deserialize(workflowStatus.getSerializedOutput());
135-
136-
assertEquals(1, workflowOutput.getPayloads().size());
137-
assertEquals("Execution key found", workflowOutput.getPayloads().get(0));
138-
139-
String executionKey = workflowOutput.getWorkflowId() +"-"+"io.dapr.it.testcontainers.TaskExecutionKeyActivity";
140-
assertTrue(KeyStore.getInstance().getKey(executionKey));
141-
142-
assertEquals(instanceId, workflowOutput.getWorkflowId());
143-
}
144-
145120
private TestWorkflowPayload deserialize(String value) throws JsonProcessingException {
146121
return OBJECT_MAPPER.readValue(value, TestWorkflowPayload.class);
147122
}

sdk-tests/src/test/java/io/dapr/it/testcontainers/KeyStore.java

Lines changed: 0 additions & 51 deletions
This file was deleted.

sdk-tests/src/test/java/io/dapr/it/testcontainers/TaskExecutionKeyActivity.java

Lines changed: 0 additions & 35 deletions
This file was deleted.

sdk-tests/src/test/java/io/dapr/it/testcontainers/TestDaprWorkflowsConfiguration.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,9 @@ public WorkflowRuntimeBuilder workflowRuntimeBuilder(
5656
WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder(new Properties(overrides));
5757

5858
builder.registerWorkflow(TestWorkflow.class);
59-
builder.registerWorkflow(TestExecutionKeysWorkflow.class);
6059
builder.registerActivity(FirstActivity.class);
6160
builder.registerActivity(SecondActivity.class);
62-
builder.registerActivity(TaskExecutionKeyActivity.class);
63-
64-
61+
6562
return builder;
6663
}
6764
}

sdk-tests/src/test/java/io/dapr/it/testcontainers/TestExecutionKeysWorkflow.java

Lines changed: 0 additions & 58 deletions
This file was deleted.

sdk-workflows/src/main/java/io/dapr/workflows/WorkflowActivityContext.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ public interface WorkflowActivityContext {
1717

1818
String getName();
1919

20-
String getTaskExecutionKey();
21-
2220
<T> T getInput(Class<T> targetType);
2321

2422
}

sdk-workflows/src/main/java/io/dapr/workflows/runtime/DefaultWorkflowActivityContext.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,4 @@ public String getName() {
5656
public <T> T getInput(Class<T> targetType) {
5757
return this.innerContext.getInput(targetType);
5858
}
59-
60-
@Override
61-
public String getTaskExecutionKey() {
62-
return this.innerContext.getTaskExecutionKey();
63-
}
6459
}

sdk-workflows/src/test/java/io/dapr/workflows/runtime/WorkflowActivityClassWrapperTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static class TestActivity implements WorkflowActivity {
1616
@Override
1717
public Object run(WorkflowActivityContext ctx) {
1818
String activityContextName = ctx.getName();
19-
return ctx.getInput(String.class) + " world! from " + activityContextName + " with task execution key " + ctx.getTaskExecutionKey();
19+
return ctx.getInput(String.class) + " world! from " + activityContextName;
2020
}
2121
}
2222

@@ -37,11 +37,10 @@ public void createWithClass() {
3737

3838
when(mockContext.getInput(String.class)).thenReturn("Hello");
3939
when(mockContext.getName()).thenReturn("TestActivityContext");
40-
when(mockContext.getTaskExecutionKey()).thenReturn("123");
4140

4241
Object result = wrapper.create().run(mockContext);
4342

4443
verify(mockContext, times(1)).getInput(String.class);
45-
assertEquals("Hello world! from TestActivityContext with task execution key 123", result);
44+
assertEquals("Hello world! from TestActivityContext", result);
4645
}
4746
}

0 commit comments

Comments
 (0)