Skip to content

Aymalla/temporal-samples-java

 
 

Repository files navigation

Temporal Java SDK Samples

This repository contains samples that demonstrate various capabilities of Temporal using the Java SDK.

It contains two modules:

  • Core: showcases many different SDK features.
  • SpringBoot: showcases springboot autoconfig integration.

Learn more about Temporal and Java SDK

Requirements

  • Java 1.8+ for build and runtime
  • Java 11+ for development and contribution
  • Local Temporal Server, easiest to get started would be using Temporal CLI. For more options see docs here.

Build and run tests

  1. Clone this repository:

    git clone https://github.com/temporalio/samples-java
    cd samples-java
    
  2. Build and run Tests

    ./gradlew build
    

Running Samples:

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.

Running "Core" samples

See the README.md file in each main sample directory for cut/paste Gradle command to run specific example.

Hello samples

  • Hello: This sample includes a number of individual Workflows that can be executed independently. Each one demonstrates something specific.

Scenario-based samples

  • 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.

  • 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.

  • Customer Application Approval DSL: Demonstrates execution of a customer application approval workflow defined in a DSL (like JSON or YAML)

  • 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.

API demonstrations

SDK Metrics

Tracing Support

Running SpringBoot Samples

  1. Start SpringBoot from main repo dir:

    ./gradlew bootRun
    
  2. Navigate to localhost:3030

  3. Select which sample you want to run

More info on each sample:

  • Hello: Invoke simple "Hello" workflow from a GET endpoint
  • SDK Metrics: Learn how to set up SDK Metrics

Releases

No releases published

Packages

No packages published

Languages

  • Java 98.8%
  • HTML 1.2%