This demo demonstrates Temporal's ability to preserve stack traces across process and SDK language boundaries. Temporal uses a single Protobuf to represent failures, which simplifies the process of preserving stack traces across process and SDK language boundaries.
Note: Running this demo will require you to have Python, Java, and Go installed on your machine. These are already provided in the Codespaces environment
temporal server start-dev --ui-port 8080 --db-filename clusterdata.db
This code demonstrates the propagation of errors across language and process boundaries. A Go program requests the execution of a Java Workflow that calls an Activity in Python to compose a greeting. This greeting purposefully fails, and the error messages are propagated back up to the starter, preserving the stack traces and adding breadcrumbs so you can see the path it took.
Below is a diagram of how this process works:
sequenceDiagram
participant Go as Go Starter
participant Java as Java Workflow
participant Python as Python Activity
Go->>Java: Start workflow
Java->>Python: Execute activity
Python-->>Java: Activity fails (Error)
Java-->>Go: Propagate error
Before running the below code, ensure you have a Temporal Service running
- Change into the
activity
directory - Create a virtual environment and activate it
python -m venv venv
source venv/bin/activate
- Install the required Python packages
pip install -r requirements.txt
- Run the Worker
python worker.py
- Change directories into the
workflow
directory. - Compile the Java Workflow.
mvn clean compile
- Run the Worker using
mvn
mvn exec:java -Dexec.mainClass="greetingworkflow.GreetingWorker"
- Change directories into the
starter
directory. - Install the Go SDK
go get
- Run the Starter with your name
go run main.go NAME
- Review the stack trace in the terminal that runs the Python Worker. It should only show the Python code.
- Review the stack trace in the terminal window that runs the Java Worker. You should see the stack trace from the Python Activity in the Java stack trace.
- Observe the stack trace in the terminal window that runs Starter code. Note that it shows the messages from the failures from both the Java Workflow and Python Activity.
- Go to the Web UI and click into the Workflow Execution named
errors-demo
. Scroll down and view the Event History and expand on the Failed events. You should see the stack traces within the history. In the final error, you will see the propagated errors from the Python Activity in the Java Workflow stack trace. This stack trace will be similar to what you observed in the Java Workflow Terminal stack trace.