1
- # Cadence Samples
2
- These are some samples to demonstrate various capabilities of Java Cadence client and server. You can learn more about cadence at:
1
+ # Java Cadence Samples
2
+ These samples demonstrate various capabilities of Java Cadence client and server. You can learn more about Cadence at:
3
3
* Cadence: https://github.com/uber/cadence
4
4
* Java Cadence Client: https://github.com/uber-java/cadence-client
5
5
* Go Cadence Client: https://github.com/uber-go/cadence-client
6
6
7
7
## Overview of the Samples
8
8
9
- * ** HelloWorld Samples**
10
- * HelloActivity is a sample of a single activity workflow
11
- * HelloActivityRetry demonstrates how to retry an activity
12
- * HelloAsync is a sample of how to call activities asynchronously and wait for them using Promises.
13
- * HelloAsyncLambda is a sample of how to run a part of a workflow asynchronously in a separate task (thread).
14
- * HelloAsyncActivityCompletion is a sample of an asynchronous activity implementation.
15
- * HelloChild is a sample of a child workflow
16
- * HelloException demonstrates exception propagation and wrapping
17
- * HelloQuery is a sample of a query
18
- * HelloSignal is a sample of sending and handling a signal.
19
- * HelloPeriodic is a sample workflow that executes an activity periodically forever.
20
-
21
- * ** FileProcessing** -- shows a workflow for media processing use case. The sample workflow
22
- downloads a file, processes it and uploads result to a destination. Demonstrates how to route activities to a
23
- specific host.
24
-
25
- ## Build Samples
26
-
27
- We are working on getting [ cadence-client library] ( https://github.com/uber-java/cadence-client ) into a public Maven repository.
28
- In the meantime before running samples it has to be build to get it into the local maven cache.
29
- See instructions from the Cadence Client README for the instructions.
30
-
31
- After cadence-client library is available just run
32
-
33
- ./gradlew build`
34
-
35
- to build the samples. Verify that they actually can run:
36
-
37
- ./gradlew -q execute -PmainClass=com.uber.cadence.samples.common.RegisterDomain
38
-
39
- ## Prerequisite
40
- Run Cadence Server using Docker Compose
9
+ * ** HelloWorld Samples**
10
+
11
+ The following samples demonstrate:
12
+
13
+ * ** HelloActivity** : a single activity workflow
14
+ * ** HelloActivityRetry** : how to retry an activity
15
+ * ** HelloAsync** : how to call activities asynchronously and wait for them using Promises
16
+ * ** HelloAsyncLambda** : how to run part of a workflow asynchronously in a separate task (thread)
17
+ * ** HelloAsyncActivityCompletion** : an asynchronous activity implementation
18
+ * ** HelloChild** : a child workflow
19
+ * ** HelloException** : exception propagation and wrapping
20
+ * ** HelloQuery** : a query
21
+ * ** HelloSignal** : sending and handling a signal
22
+ * ** HelloPeriodic** : a sample workflow that executes an activity periodically forever
23
+
24
+ * ** FileProcessing** demonstrates task routing features. The sample workflow downloads a file, processes it, and uploads
25
+ the result to a destination. The first activity can be picked up by any worker. However, the second and third activities
26
+ must be executed on the same host as the first one.
27
+
28
+ ## Get the Samples
29
+
30
+ Run the following commands:
31
+
32
+ git clone https://github.com/mfateev/uber-java-cadence-samples
33
+ cd cadence-java-client-samples
34
+
35
+ ## Import into IntelliJ
36
+
37
+ In the IntelliJ user interface, navigate to ** File** ->** New** ->** Project from Existing Sources** .
38
+
39
+ Select the cloned directory. In the ** Import Project page** , select ** Import project from external model** ,
40
+ choose ** Gradle** and then click ** Next** ->** Finish** .
41
+
42
+ ## Build the Samples
43
+
44
+ Assumng that the https://github.com/uber-java/cadence-client is in local maven cache.
45
+
46
+ ./gradlew build
47
+
48
+ If the latest samples stop building after you pull the latest version, refresh the Gradle dependencies:
49
+
50
+ ./gradlew build --refresh-dependencies
51
+
52
+ Or, in IntelliJ, in the ** Gradle projects** window, right-click "cadence-samples" and then click
53
+ ** Refresh dependencies** .
54
+
55
+ ## Run Cadence Server
56
+
57
+ Run Cadence Server using Docker Compose:
41
58
42
59
curl -O https://raw.githubusercontent.com/uber/cadence/master/docker/docker-compose.yml
43
60
docker-compose up
44
-
45
- If it does not work see instructions for running the Cadence Server at https://github.com/uber/cadence/blob/master/README.md
46
61
47
- ## Registering Domain
62
+ If this does not work, see the instructions for running Cadence Server at https://github.com/uber/cadence/blob/master/README.md .
63
+
64
+ ## Register the Domain
48
65
49
- Run it once before running any samples to register domain.
66
+ To register the domain, run the follownig command once before running any samples:
50
67
51
- ./gradlew -q execute -PmainClass=com.uber.cadence.samples.common.RegisterDomain
68
+ ./gradlew -q execute -PmainClass=com.uber.cadence.samples.common.RegisterDomain
52
69
53
- ## Running the samples
70
+ ## Run the samples
54
71
55
- Each sample has particular requirements for running it. Here's how to run each of the samples once
56
- you've built them using the preceding instructions.
72
+ Each sample has specific requirements for running it. The following sections contain information about
73
+ how to run each of the samples after you've built them using the preceding instructions.
57
74
58
75
### Hello World
59
76
60
- To run hello world:
77
+ To run the hello world samples :
61
78
62
79
./gradlew -q execute -PmainClass=com.uber.cadence.samples.hello.HelloActivity
63
80
./gradlew -q execute -PmainClass=com.uber.cadence.samples.hello.HelloActivityRetry
@@ -72,29 +89,13 @@ To run hello world:
72
89
73
90
### File Processing
74
91
75
- The * FileProcessing* sample uploads files to [ Amazon S3] ( http://aws.amazon.com/s3/ ) . To run this
76
- sample, you will need to first [ create an S3
77
- bucket] ( http://docs.aws.amazon.com/AmazonS3/latest/gsg/CreatingABucket.html ) .
78
-
79
- Then, locate the following section in the ` access.properties ` file and fill in the name of an S3
80
- bucket that you want the sample to use:
81
-
82
- ####### FileProcessing Sample Config Values ##########
83
- Workflow.Input.TargetBucketName=<Your S3 bucket name>
84
-
85
- The sample has two executables. You should run each command in a separate terminal window. The first one
86
- is the worker that hosts workflow and activities implementation:
92
+ This sample has two executables. Execute each command in a separate terminal window. The first command
93
+ runs the worker that hosts the workflow and activities implementation. To demonstrate that activities
94
+ execute together, we recommend that you run more than one instance of this worker.
87
95
88
96
./gradlew -q execute -PmainClass=com.uber.cadence.samples.fileprocessing.FileProcessingWorker
89
-
90
- The second is responsible for starting workflows:
91
97
92
- ./gradlew -q execute -PmainClass=com.uber.cadence.samples.fileprocessing.FileProcessingStarter
93
-
94
- ### Split Merge
95
-
96
- The sample has two executables. You should run each command in a separate terminal window.
98
+ The second command starts workflows. Each invocation starts a new workflow execution.
97
99
98
- ./gradlew -q execute -PmainClass=com.uber.cadence.samples.splitmerge.SplitMergeWorker
99
- ./gradlew -q execute -PmainClass=com.uber.cadence.samples.splitmerge.SplitMergeStarter
100
+ ./gradlew -q execute -PmainClass=com.uber.cadence.samples.fileprocessing.FileProcessingStarter
100
101
0 commit comments