Coder Social home page Coder Social logo

philipz / camunda-external-task-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ibm/camunda-external-task-demo

0.0 2.0 0.0 1.22 MB

a demo of realizing Camunda External Task pattern

License: Apache License 2.0

Java 97.61% Dockerfile 2.39%

camunda-external-task-demo's Introduction

camunda-external-task-demo

A demo for using Camunda BPM Engine external task patter to do service orchestration.

external task pattern

Highlights:

  • Demonstrates Temporal decoupling / Better scaling / Avoid Timeouts use cases.
  • Demonstrates implementing Camunda BPM Engine as an embedded component to an REST service project. The process engine is added as an application library to a custom application which is a convenient way and small footprint for modernizing existing applicaitons.
  • Camunda official demos are usually based on spring tech, which is easy to integrate with camunda. This demo embedded camunda workflow engine into a pure JAX-RS web service, no anymore spring dependencies. This demonstrates Camunda can also work well with non-spring tech stacks.

service orchestration by Camunda

decoupling service by using BPM Engine as Event Bus

1. Maven Build

$git clone
$cd camunda-external-task-demo
$mvn clean package -f camunda-embedded-engine-demo-model/pom.xml
$mvn clean package -f camunda-embedded-engine-demo/pom.xml
$mvn clean package -f simple-charge-card-worker/pom.xml
$mvn clean package -f simple-check-card-worker/pom.xml 
$mvn clean package -f simple-check-item-worker/pom.xml 

2. Build Container Images

$docker build -t camunda-embedded-engine-demo:latest camunda-embedded-engine-demo/.
$docker build -t simple-check-card-worker:latest simple-check-card-worker/.
$docker build -t simple-check-item-worker:latest simple-check-item-worker/.
$docker build -t simple-charge-card-worker:latest simple-charge-card-worker/.

3. Deploy

Deploy the services, Camunda web app and postgresql containers to Code Ready Container. The work flow engine is embedded in camunda-embedded-engine-demo service, and postgresql is the database for workflow engine and data persistent. Camunda web app can be used to monitor the workflow execution, and needs to connect to the same postgresql. You can find details in deployments.yaml.

The following script is for deploying on Code Ready Container.

# create a new openshift project with name 'camunda-demo'
$oc new-project camunda-demo
# tag the images for pushing to openshift internal image registry
$docker tag camunda-embedded-engine-demo:latest default-route-openshift-image-registry.apps-crc.testing/camunda-demo/camunda-embedded-engine-demo:latest
$docker tag simple-check-card-worker:latest default-route-openshift-image-registry.apps-crc.testing/camunda-demo/simple-check-card-worker:latest
$docker tag simple-check-item-worker:latest default-route-openshift-image-registry.apps-crc.testing/camunda-demo/simple-check-item-worker:latest
$docker tag simple-charge-card-worker:latest default-route-openshift-image-registry.apps-crc.testing/camunda-demo/simple-charge-card-worker:latest
# push to openshift internal image registry
$docker push default-route-openshift-image-registry.apps-crc.testing/camunda-demo/camunda-embedded-engine-demo:latest
$docker push default-route-openshift-image-registry.apps-crc.testing/camunda-demo/simple-check-card-worker:latest
$docker push default-route-openshift-image-registry.apps-crc.testing/camunda-demo/simple-check-item-worker:latest
$docker push default-route-openshift-image-registry.apps-crc.testing/camunda-demo/simple-charge-card-worker:latest
# deploy by yaml definition
$oc apply -n camunda-demo -f camunda-db-pvc-crc.yaml
$oc apply -n camunda-demo -f deployments.yaml

If you want to deploy on Openshift Clusters on IBM Cloud, please first push the images to internal image registry on Openshift on IBM Cloud, and use camunda-db-pvc-ibmc.yaml to creat pvc with dynamic provision.

Camunda web app needs priviledge to startup, use the following command. Camunda web app is optional, it is just used to visualize workflow execution.

$oc adm policy add-scc-to-user anyuid -z default

4. Test

Use the following command to send a request to camunda-embedded-engine-demo service, and a new camunda work flow process instance will be created and started in background.

$curl --location --request POST 'http://camunda-embedded-engine-demo-route-camunda-demo.apps-crc.testing/camunda-embedded-engine-demo/webapi/myresource' \
--header 'Content-Type: application/json' \
--header 'Content-Type: text/plain' \
--data-raw '{
	"doCardCharge": true,
	"doCheckCard": true,
	"doCheckItem": true,
	"cardNumber": "0123456789",
	"amount": 335.0,
	"item": "item-def"
}'

Then if you spin up simple-check-item-worker, simple-check-card-worker, simple-charge-card-worker one by one, you can monitor the process of external workers execution in camunda web. The following image shows the workflow and external worker execution sequence.

workflow execution on camunda web

Usually we should spin up all workers at the same time, so check item and check card should work parallelly according to the work flow definition.

Reference:

Understanding and Using External Tasks

Camunda Microservices and BPM Whitepaper

The Job Executor: What Is Going on in My Process Engine?

camunda-external-task-demo's People

Contributors

jizg avatar stevemar avatar

Watchers

James Cloos avatar  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.