View all files | ||||
This repository contains samples that demonstrate various capabilities of Temporal using the Java SDK.
It contains the following modules:
Clone this repository:
Build and run Tests
You can run both "Core" and "SpringBoot" samples from the main samples project directory. Details on how to run each sample can be found in following two sections. To skip to SpringBoot samples click here.
See the README.md file in each main sample directory for cut/paste Gradle command to run specific example.
Hello: This sample includes a number of individual Workflows that can be executed independently. Each one demonstrates something specific.
File Processing Sample: Demonstrates how to route tasks to specific Workers. This sample has a set of Activities that download a file, processes it, and uploads the result to a destination. Any Worker can execute the first Activity. However, the second and third Activities must be executed on the same host as the first one.
Booking SAGA: Demonstrates Temporals take on the Camunda BPMN "trip booking" example.
Synchronous Booking SAGA: Demonstrates low latency SAGA with potentially long compensations.
Money Transfer: Demonstrates the use of a dedicated Activity Worker.
Money Batch: Demonstrates a situation where a single deposit should be initiated for multiple withdrawals. For example, a seller might want to be paid once per fixed number of transactions. This sample can be easily extended to perform a payment based on more complex criteria, such as at a specific time or an accumulated amount. The sample also demonstrates how to Signal the Workflow when it executes (Signal with start). If the Workflow is already executing, it just receives the Signal. If it is not executing, then the Workflow executes first, and then the Signal is delivered to it. Signal with start is a "lazy" way to execute Workflows when Signaling them.
Domain-Specific-Language - Define sequence of steps in JSON: Demonstrates using domain specific language (DSL) defined in JSON to specify sequence of steps to be performed in our workflow.
Polling Services: Recommended implementation of an activity that needs to periodically poll an external resource waiting its successful completion
Heartbeating Activity Batch: Batch job implementation using a heartbeating activity.
Iterator Batch: Batch job implementation using the workflow iterator pattern.
Sliding Window Batch: A batch implementation that maintains a configured number of child workflows during processing.
Safe Message Passing: Safely handling concurrent updates and signals messages.
Custom Annotation: Demonstrates how to create a custom annotation using an interceptor.
Async Packet Delivery: Demonstrates running multiple execution paths async within single execution.
Worker Versioning: Demonstrates how to use worker versioning to manage workflow code changes.
Environment Configuration: Load client configuration from TOML files with programmatic overrides.
Async Untyped Child Workflow: Demonstrates how to invoke an untyped child workflow async, that can complete after parent workflow is already completed.
Updatable Timer: Demonstrates the use of a helper class which relies on Workflow.await to implement a blocking sleep that can be updated at any moment.
Workflow Count Interceptor: Demonstrates how to create and register a simple Workflow Count Interceptor.
Workflow Retry On Signal Interceptor: Demonstrates how to create and register an interceptor that retries an activity on a signal.
List Workflows: Demonstrates the use of custom search attributes and ListWorkflowExecutionsRequest with custom queries.
Payload Converter - CloudEvents: Demonstrates the use of a custom payload converter for CloudEvents.
Payload Converter - Crypto: Demonstrates the use of a custom payload converter using jackson-json-crypto.
Async Child Workflow: Demonstrates how to invoke a child workflow async, that can complete after parent workflow is already completed.
Terminate Workflow: Demonstrates how to terminate a workflow using client API.
Get Workflow Results Async: Demonstrates how to start and get workflow results in async manner.
Per Activity Type Options: Demonstrates how to set per Activity type options.
Configure WorkflowClient to use mTLS: Demonstrates how to configure WorkflowClient when using mTLS.
Configure WorkflowClient to use API Key: Demonstrates how to configure WorkflowClient when using API Keys.
Payload Codec: Demonstrates how to use simple codec to encode/decode failure messages.
Exclude Workflow/ActivityTypes from Interceptors: Demonstrates how to exclude certain workflow / activity types from interceptors.
Standalone Activities: Demonstrates how to start, execute, list, and count Standalone Activities — Activities that run independently without a Workflow, using ActivityClient.
Encrypted Payloads: Demonstrates how to use simple codec to encrypt and decrypt payloads.
AWS Encryption SDK: Demonstrates how to use the AWS Encryption SDK to encrypt and decrypt payloads with AWS KMS.
Getting Started: Demonstrates how to get started with Temporal and Nexus.
StandAlone Nexus Operations: Demonstrates how to start Standalone Nexus Operations — Nexus Operations that run independently without a Workflow.
Mapping Multiple Arguments: Demonstrates how map a Nexus operation to a Workflow that takes multiple arguments.
Cancellation: Demonstrates how to cancel an async Nexus operation.
Context/Header Propagation: Demonstrates how to propagate context through Nexus operation headers.
Nexus Messaging: Demonstrates how to send signal, update and query messages through Nexus. This contains two samples, one sending messages to an existing workflow and a second that creates a workflow through Nexus and sends messages to it.
These samples use SpringBoot 2 by default. To switch to using SpringBoot 3 look at the gradle.properties file and follow simple instructions there.
Start SpringBoot from main repo dir:
To run the basic sample run
Navigate to localhost:3030
Select which sample you want to run
More info on each sample:
To run any of the SpringBoot samples in your Temporal Cloud namespace:
Edit the application-tc.yaml to set your namespace and client certificates.
Start SpringBoot from main repo dir with the tc profile:
Follow the previous section from step 2
The Spring AI samples demonstrate the Temporal Spring AI integration, which makes Spring AI agents durable on Temporal — model calls run as Temporal Activities recorded in Workflow history, and tools are dispatched per their type so they fit Workflow execution.
Each sample is its own Spring Boot application with an interactive CLI. Run from the main repo dir:
All samples need an OPENAI_API_KEY environment variable; some need additional setup (see each sample's source for details).
More info on each sample: