Home

Awesome

Temporal Simple Polyglot example

<p align="center"> <img src="img/polyglot-overview.png" height="500px" alt="App Overview"/> </p>

This demo uses the following Temporal SDKs:

It shows how Temporal can act as a service orchestrator and mediator between different distributed applications written in different programming languages.

Interactions between Workflows and Activities:

  1. Java Workflow signals Go Workflow (10 times)
  2. Go Workflow signals Java Workflow (10 times)
  3. Java Workflow invokes a Go Activity
  4. Go Activity queries Java Workflow
  5. Go Workflow invokes Java Activity
  6. Java Activity queries Go Workflow
  7. Java Workflow signals PHP Workflow (10 times)
  8. Go Workflow signals PHP Workflow (10 times)
  9. Java Workflow invokes NodeJS Activity and propagates its error
  10. Go Workflow invokes NodeJS Activity and propagates its error
  11. PHP Wokflow invokes NodeJS Activity and propagates its error

Running the demo

  1. Start the Temporal Server:
git clone https://github.com/temporalio/docker-compose.git
cd  docker-compose
docker compose up

Note: The sample apps in different languages should be started in the shown order. They should be started within 3 minutes from each other. You can set different Workflow execution timeouts to change this if you wish.

  1. Start the Node sample:
cd app-node
npm install
npm start

"npm install" does not have to be run each time, only when changes are made.

  1. Start the PHP sample:
cd app-php
composer install
./rr serve
php app.php simple  

"composer install" does not have to be run each time.

  1. Start the Go worker and starter:
cd app-go
go run worker/main.go
go run starter/main.go
  1. Start the Java worker and starter:
cd app-java
mvn compile exec:java -Dexec.mainClass="org.simple.app.StartWorker"
mvn compile exec:java -Dexec.mainClass="org.simple.app.StartWorkflow"

Seeing the results:

  1. Look at the logs printed in the same window where you ran the Go workflow starter, you should ge:
Workflow result: 
Hello from Java Workflow: 0
Hello from Java Workflow: 1
Hello from Java Workflow: 2
Hello from Java Workflow: 3
Hello from Java Workflow: 4
Hello from Java Workflow: 5
Hello from Java Workflow: 6
Hello from Java Workflow: 7
Hello from Java Workflow: 8
Hello from Java Workflow: 9
Java SimpleActivity - hello from: GoWorkflow Query result: This is a simple Go Workflow
Error from Node Activity: NodeJs Activity Error...
  1. Look at the results of our Java workflow, you should get:
Hello from Go workflow: 0
Hello from Go workflow: 1
Hello from Go workflow: 2
Hello from Go workflow: 3
Hello from Go workflow: 4
Hello from Go workflow: 5
Hello from Go workflow: 6
Hello from Go workflow: 7
Hello from Go workflow: 8
Hello from Go workflow: 9
Go Activity - hello from: JavaWorkflow Query result: This is a simple Java Workflow
Error from Node Activity: NodeJs Activity Error...
  1. Look at the results of your PHP workflow, you should get:
Result:
Hello from Java Workflow: 0
Hello from Java Workflow: 1
Hello from Java Workflow: 2
Hello from Java Workflow: 3
Hello from Java Workflow: 4
Hello from Java Workflow: 5
Hello from Java Workflow: 6
Hello from Java Workflow: 7
Hello from Java Workflow: 8
Hello from Java Workflow: 9
Hello from Go workflow: 0
Hello from Go workflow: 1
Hello from Go workflow: 2
Hello from Go workflow: 3
Hello from Go workflow: 4
Hello from Go workflow: 5
Hello from Go workflow: 6
Hello from Go workflow: 7
Hello from Go workflow: 8
Hello from Go workflow: 9
Error from Node Activity: NodeJs Activity Error...