cadence-workflow / cadence-java-samples

Other
97 stars 60 forks source link

Added Spring application example for worker service #68

Closed shijiesheng closed 1 year ago

shijiesheng commented 1 year ago

Changes

Added example on how to create spring application for worker service

Test

After cadence server container is up,

./gradlew -q execute -PmainClass=com.uber.cadence.samples.common.RegisterDomain ./gradlew -q execute -PmainClass=com.uber.cadence.samples.spring.CadenceSamplesApplication

The output looks like

1:17:10 PM: Executing 'execute -q -PmainClass=com.uber.cadence.samples.spring.CadenceSamplesApplication'...

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::               (v2.7.15)

13:17:16.981 [main] INFO  c.u.c.s.s.CadenceSamplesApplication - Starting CadenceSamplesApplication using Java 1.8.0_192 on shengs-C02XN3VDJGH6 with PID 48745 (/Users/shengs/code/cadence-java-samples/build/classes/java/main started by shengs in /Users/shengs/code/cadence-java-samples)
13:17:16.986 [main] INFO  c.u.c.s.s.CadenceSamplesApplication - No active profile set, falling back to 1 default profile: "default"
13:17:18.004 [main] INFO  o.s.b.w.e.tomcat.TomcatWebServer - Tomcat initialized with port(s): 8080 (http)
13:17:18.013 [main] INFO  o.a.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8080"]
13:17:18.016 [main] INFO  o.a.catalina.core.StandardService - Starting service [Tomcat]
13:17:18.016 [main] INFO  o.a.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.79]
13:17:18.166 [main] INFO  o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
13:17:18.167 [main] INFO  o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 1127 ms
13:17:18.486 [main] INFO  c.u.c.s.WorkflowServiceTChannel - Initialized TChannel for service cadence-frontend, LibraryVersion: 3.7.2, FeatureVersion: 1.5.0
13:17:18.929 [main] INFO  o.a.coyote.http11.Http11NioProtocol - Starting ProtocolHandler ["http-nio-8080"]
13:17:18.948 [main] INFO  o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): 8080 (http) with context path ''
13:17:18.957 [main] INFO  c.u.c.s.s.CadenceSamplesApplication - Started CadenceSamplesApplication in 2.357 seconds (JVM running for 2.832)
Starting workers
Start one synchronous HelloWorld workflow
13:17:19.578 [workflow-root] INFO  c.u.c.s.s.w.HelloWorldWorkflowImpl - executing HelloWorldWorkflow::sayHello
13:17:19.579 [workflow-root] INFO  c.u.c.s.s.w.HelloWorldWorkflowImpl - output: Hello, hello
Synchronous HelloWorld workflow finished
13:17:19.703 [main] INFO  o.a.coyote.http11.Http11NioProtocol - Pausing ProtocolHandler ["http-nio-8080"]
13:17:19.703 [main] INFO  o.a.catalina.core.StandardService - Stopping service [Tomcat]
13:17:19.707 [main] INFO  o.a.coyote.http11.Http11NioProtocol - Stopping ProtocolHandler ["http-nio-8080"]
13:17:19.708 [main] INFO  o.a.coyote.http11.Http11NioProtocol - Destroying ProtocolHandler ["http-nio-8080"]