-
Notifications
You must be signed in to change notification settings - Fork 145
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
Example for tasks interaction #567
base: main
Are you sure you want to change the base?
Conversation
hey, sorry still reviewing. ty for doing this sample! |
no hurry @tsurdilo |
core/src/main/java/io/temporal/samples/taskinteraction/Task.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/temporal/samples/taskinteraction/TaskService.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/temporal/samples/taskinteraction/Task.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/temporal/samples/taskinteraction/TaskService.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/temporal/samples/taskinteraction/TaskWorkflowImpl.java
Outdated
Show resolved
Hide resolved
import io.temporal.serviceclient.WorkflowServiceStubs; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
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.
I think it is confusing to require WorkflowID to complete tasks as they are usually stored in a separate system.
The task token contains the workflow ID already. So I would change the TaskActivityImpl to print the task token and then the UpdateTask to get the token as an argument. The UpdateTask would parse out the workflow id out of the token and signal the appropriate workflow.
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.
right now only the "task token" is required to update / complete the task
import io.temporal.serviceclient.WorkflowServiceStubs; | ||
import java.util.List; | ||
|
||
public class ListOpenTasks { |
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.
I think this is confusing as this list tasks of a specific workflow. In real systems tasks assigned to a specific user would be listed. I would remove the whole list-related functionality to avoid such confusion.
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.
I agree, but also I think it could be useful to show the workflow execution internal state. Do you think we can expose this information in any other way or should I just remove it?
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.
ListOpenTasks
removed,
I am maintaining the method getOpenTask
to query the internal state and complete the task automatically from UpdateTask
I can remove the method getOpenTask
, and have the dev running the example passing the task id to UpdateTask , instead of getting the taskid from the workflow execution using getOpenTask
hi, is there any outstanding things to be done on this pr? thanks |
Hi @tsurdilo this is on me, I have to remove the getOpenTask method |
… in workflow code
Bumps [org.mockito:mockito-core](https://github.com/mockito/mockito) from 5.8.0 to 5.11.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](mockito/mockito@v5.8.0...v5.11.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [ch.qos.logback:logback-classic](https://github.com/qos-ch/logback) from 1.5.0 to 1.5.3. - [Commits](qos-ch/logback@v_1.5.0...v_1.5.3) --- updated-dependencies: - dependency-name: ch.qos.logback:logback-classic dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…lio#601) Bumps [com.fasterxml.jackson:jackson-bom](https://github.com/FasterXML/jackson-bom) from 2.16.1 to 2.17.0. - [Commits](FasterXML/jackson-bom@jackson-bom-2.16.1...jackson-bom-2.17.0) --- updated-dependencies: - dependency-name: com.fasterxml.jackson:jackson-bom dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…mporalio#602) Bumps [com.google.errorprone:error_prone_core](https://github.com/google/error-prone) from 2.25.0 to 2.26.1. - [Release notes](https://github.com/google/error-prone/releases) - [Commits](google/error-prone@v2.25.0...v2.26.1) --- updated-dependencies: - dependency-name: com.google.errorprone:error_prone_core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Tihomir Surdilovic <[email protected]>
* Add KeyWordList type to typed SA sample Signed-off-by: Tihomir Surdilovic <[email protected]> * formatting Signed-off-by: Tihomir Surdilovic <[email protected]> --------- Signed-off-by: Tihomir Surdilovic <[email protected]>
18e3c12
to
9fd4389
Compare
|
I like it, this is a nice sample to have. |
Had a bit of a hard time following example code as in the whole time was thinking this would be good to have as a reusable interceptor that can be just applied to any workflow. Also would be nice to incorporate visibility into this as to |
Approving this as think its good sample, just see previous comment about it being bit hard to understand / follow. |
Thanks @tsurdilo
Let me see if I can refactor it / make it simpler
👍 |
97e7a38
to
b2a4f67
Compare
|
||
logger.info("Awaiting for the two tasks to complete"); | ||
// Block execution until both tasks complete | ||
Promise.allOf(Arrays.asList(task1, task2)).get(); |
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.
i think here you need to loop through promises again to check if any failed and if not call .get on each (to make sure they both actually compelted)
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.
I get your point and i can add it, but I don't think any of these promises can fail with the current implementation
|
||
Thread.sleep(200); | ||
final List<Task> pendingTask = getPendingTask(workflowTaskManager); | ||
System.out.println("Pending task " + pendingTask); |
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.
do we want system outs here?
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.
This is the client completing task , and this shows pending tasks.
|
||
initTaskList(inputPendingTasks); | ||
|
||
Workflow.await(() -> Workflow.getInfo().isContinueAsNewSuggested()); |
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.
maybe im missing something here but if all tasks in task list complete
before continueAsNewSuggested triggers this exec will running
i wonder if this can be changed to like "if we did not receive any new tasks for duration X" maybe instead?
reason is that cost of running execs on cloud so users might wanna complete this exec and use signalWithStart instead when new tasks come in? maybe im missing something so let me know
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.
I can add a condition so if there are no pending tasks the workflow returns/closes, WDYT @tsurdilo
What was changed
Why?
Some users look into Temporal as an alternative to BPM tools, like jBPM or Camunda. One common question is how to deal with HumanTask. This example shows a basic implementation to track task state
Checklist
Closes
How was this tested: