GithubHelp home page GithubHelp logo

corey-tock / samples-java Goto Github PK

View Code? Open in Web Editor NEW

This project forked from temporalio/samples-java

0.0 0.0 0.0 1.15 MB

Temporal Java SDK samples

Home Page: http://docs.temporal.io/docs/java-quick-start

License: Other

Shell 0.04% Java 99.92% Dockerfile 0.04%

samples-java's Introduction

Temporal Java SDK Samples

This repository contains sample Workflow applications that demonstrate various capabilities of Temporal using the Java SDK.

Table of Contents

How to use

  1. Clone this repository:

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

    ./gradlew build
    
  3. You need a locally running Temporal Server instance to run the samples. We recommend a locally running version of the Temporal Server managed via Docker Compose:

    git clone https://github.com/temporalio/docker-compose.git
    cd  docker-compose
    docker-compose up
    

Note that for the "listworkflows" example you need to have the Elasticsearch feature enabled on the Temporal Server side. To do this you can run locally with:

   git clone https://github.com/temporalio/docker-compose.git
   cd  docker-compose
   docker-compose -f docker-compose-cas-es.yml up

Alternatively you could install the Temporal Server on Kubernetes / Minicube using the Temporal Helm charts. Note that in this case you should use the Temporal CLI (tctl) tool to create a namespace called "default":

   tctl --ns default n re

Temporal Web UI

The Temporal Server running in a docker container includes a Web UI, exposed by default on port 8088 of the docker host. If you are running Docker on your host, you can connect to the WebUI running using a browser and opening the following URI:

http://localhost:8088

If you are running Docker on a different host (e.g.: a virtual machine), then modify the URI accordingly by specifying the correct host and the correct port.

http://${DOCKER_HOST}:${WEBUI_PORT}.

If you have deployed the Temporal Server on Kubernetes using Helm Charts, you can use the kubectl command-line tool to forward your local machine ports to the Temporal Web UI:

    kubectl port-forward services/temporaltest-web 8088:8088
    kubectl port-forward services/temporaltest-frontend-headless 7233:7233

With this you should be able to access the Temporal Web UI with http://localhost:8088.

Running samples

By default, samples assume relevant Temporal container ports are listening on localhost, on port 7233. If this is not the case, you can tunnel traffic to this port to a different one (even running on a different host), using for example netcat, socat, or ssh.

If, for example, you're running Docker on a virtual machine vm, you can use ssh to tunnel the traffic using the following command before running the samples:

ssh -g -L 7233:localhost:7233 -N user@vm

Samples directory

The following section lists all available samples. Click on the sample link to view the README, which contains instructions on how to run them.

Each sample has an associated unit test which demonstrates the use of the Temporal Java SDK testing API. All tests are available under src/test/java

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

API demonstrations

SDK Metrics

Tracing Support

IDE Integration

IntelliJ

It is possible to run the samples from the command line, but if you prefer IntelliJ here are the import steps:

  • Navigate to File->New->Project from Existing Sources.
  • Select the cloned directory.
  • In the Import Project page, select Import project from external model
  • Choose Gradle and then click Next
  • Click Finish.

samples-java's People

Contributors

dependabot[bot] avatar mfateev avatar tsurdilo avatar spikhalskiy avatar vkoby avatar vitarb avatar manikandanrs avatar vancexu avatar shawnhathaway avatar greyteardrop avatar chronoguy avatar sullis avatar halakaraki avatar ardagan avatar mcbryde avatar flossypurse avatar wxing1292 avatar mastermanu avatar fossabot avatar barakalon avatar spicypepper999 avatar yasin3061 avatar sushisource avatar shubhsingh avatar samarabbas avatar robholland avatar lorensr avatar meiliang86 avatar joebowbeer avatar emcrisostomo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.