During this exercise, you will
- Review the business logic of the provided Workflow Definition to understand its behavior
- Modify the Worker initialization code to specify a task queue name
- Run the Worker initialization code to start the Worker process
- Execute the Workflow from the command line, specifying your name as input
Make your changes to the code in the practice subdirectory (look for TODO
comments that will guide you to where you should make changes to the code).
If you need a hint or want to verify your changes, look at the complete version
in the solution subdirectory.
- Open the
HelloWorkflowWorkflow.javaandHelloWorkflowWorkflowImpl.javafiles (located in thepractice/src/main/java/helloworkflowsubdirectory) in the editor - Review the input parameters, business logic, and return value.
- Open the
HelloWorkflowWorker.javafile (located in thepractice/src/main/java/helloworkflowsubdirectory) in the editor - Specify
greeting-tasksas the name of the task queue - Save your changes
- Open a terminal window in the environment and change to the
practicesubdirectory for this exercise - Run the following command to compile the code, as well as download and install the Java dependencies needed by the code, which will include the Temporal Java SDK
$ mvn compile
- Run the following command in the terminal window to start the Worker
$ mvn compile exec:java -Dexec.mainClass="helloworkflow.HelloWorkflowWorker"
- Open another terminal window in the environment and change to the
practicesubdirectory for this exercise - Run the following command, replacing
Masonwith your first name. Be sure to retain the same quoting shown here when you run the command:
$ temporal workflow start \
--type HelloWorkflowWorkflow \
--task-queue greeting-tasks \
--workflow-id my-first-workflow \
--input '"Mason"'
Note that this command starts the Workflow, but it does not wait for it to complete or show the result.
If you have time, continue with the optional part of the exercise below to see how to view the result using temporal.
You can run the following command to display the result of a Workflow Execution:
temporal workflow show --workflow-id my-first-workflow
It is also possible, and often more convenient, to view this information using the Web UI. You will have a chance to do this in the next exercise.