{"id":24552996,"url":"https://github.com/npdeehan/kaffee-und-kuchen","last_synced_at":"2025-04-15T23:14:17.907Z","repository":{"id":90222864,"uuid":"214187154","full_name":"NPDeehan/kaffee-und-kuchen","owner":"NPDeehan","description":"Easily switching a syncronouse archetecture to an a-sync with a Camunda workflow engine. ","archived":false,"fork":false,"pushed_at":"2021-08-18T08:20:51.000Z","size":347,"stargazers_count":8,"open_issues_count":0,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T23:13:54.167Z","etag":null,"topics":["asynchronous","camunda-engine","micro-services","workflow"],"latest_commit_sha":null,"homepage":"https://forum.camunda.org/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NPDeehan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-10T13:14:28.000Z","updated_at":"2024-08-30T16:35:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"45cfee3c-2b1e-4197-a967-89588721e7b3","html_url":"https://github.com/NPDeehan/kaffee-und-kuchen","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NPDeehan%2Fkaffee-und-kuchen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NPDeehan%2Fkaffee-und-kuchen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NPDeehan%2Fkaffee-und-kuchen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NPDeehan%2Fkaffee-und-kuchen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NPDeehan","download_url":"https://codeload.github.com/NPDeehan/kaffee-und-kuchen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249167448,"owners_count":21223506,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asynchronous","camunda-engine","micro-services","workflow"],"created_at":"2025-01-23T01:33:47.346Z","updated_at":"2025-04-15T23:14:17.901Z","avatar_url":"https://github.com/NPDeehan.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kaffee und Kuchen\nThis is an example of how to decouple dependent micro-services by adding the Camunda Engine as part of the architecture. The project can be seen being demoed at this talk, which took place at Devoxx Belgium 2019.\n\n[![Devoxx Belgium](http://img.youtube.com/vi/ky_mG4giNm4/0.jpg)](http://www.youtube.com/watch?v=ky_mG4giNm4)\n\nThere are 3 services a ``cashier`` frontend where you can make orders to an ``order sorter`` the order sorter will then request coffee from the ``barista`` service if required.\n\n![knkarch]\n\nThere are two versions of the architecture\n * Synchronous. All communication between services is completed in one transaction per request.\n * Asynchronous. Each request is persisted and completed in a new transaction while waiting for the potential of additional  requests.\n\n## Synchronous Architecture\nTo start the Synchronous version of this example open and build the following 3 Spring Boot projects\n* [Cashier](./Cashier/) - Which will start on http://localhost:8082\n* [Barista](./Barista/) - Which will start on http://localhost:8081\n* [Sort Order Sync](./SortOrder-Sync/) - Which will start on http://localhost:8080\n\nEach of these can be started within your IDE as a Spring Boot project. You can also build them and start the jar file in the generated target folder.\n\nOnce each is started you can enter orders by going to the [Cashier Homepage](http://localhost:8082).\n![knkorder1]\n\nWhen the submit button is clicked it will send a REST call ``http://localhost:8080/order-up`` to the Order-Sorter service with a payload that includes the order and the name of the person making the order.\nIf the order contains ``coffee`` then it will call the barista service on `http://localhost:8081/WorkIt/`. Once the coffee is ready it returns to the order sorter, which will return the result to the frontend, which will display ``Order of [orderMessage] Is Ready``\n\n## Asynchronous Architecture\nThis architecture only requires a change to the ``Order Sorter`` the goal is to change this service so that instead of running synchronously for each request, it will actually hold the state of each request and return the result of the request with an asynchronous call.\n\n![kuk-async-arch]\n\nTo start this version of the project you need to start (if you haven't already):\n* [Cashier](./Cashier/) - Which will start on http://localhost:8082\n* [Barista](./Barista/) - Which will start on http://localhost:8081\n\nYou will need to shut down [Sort Order Sync](./SortOrder-Sync/) and instead start up [Sort Order aSync](./SortOrder-aSync/). Both use the same port (8080) so you can't run them at the same time.\n\nOnce an order is made the state will be kept by the Camunda Engine and you can view the current state by going to Cockpit on ``http://localhost:8080/`` you can log in with:\n\nusername `reb`\n\npassword `reb`\n\nNavigate to Cockpit or go directly through this link http://localhost:8080/app/cockpit/default/\n\n\nThere are a number of changes made to Sort Order project to give us the features we need.\n* Camunda Engine is added to the project\n* Callback service is created and called\n* Process Model is created and added\n* Camunda Engine is autowired in the service and a process is started\n* The ``application.yaml`` has the Camunda configuration added to it.\n\n\n### Camunda Engine is added to the project\n\nThe Camunda Engine and the Camunda webapps are added to the project by adding the following dependencies to the ``pom.xml`` file.\n\n```xml\n\n        \u003cdependency\u003e\n            \u003cgroupId\u003eorg.camunda.bpm.springboot\u003c/groupId\u003e\n            \u003cartifactId\u003ecamunda-bpm-spring-boot-starter-rest\u003c/artifactId\u003e\n            \u003cversion\u003e7.15.0\u003c/version\u003e\n        \u003c/dependency\u003e\n        \u003cdependency\u003e\n            \u003cgroupId\u003eorg.camunda.bpm.springboot\u003c/groupId\u003e\n            \u003cartifactId\u003ecamunda-bpm-spring-boot-starter-webapp\u003c/artifactId\u003e\n            \u003cversion\u003e7.15.0\u003c/version\u003e\n        \u003c/dependency\u003e\n\n```\n\n### Callback service is created and called\n\nA callback bean called ``tellCashierAboutOrder`` is added to the project so that we can asynchronously contact the front end of the cashier service with the result of the request.\n\n### Process Model is created and added\n\nThe process engine needs this [BPMN model](./SortOrder-aSync/src/main/resources/howAreYou.bpmn) to describe how the process should proceed, what should be called and where to commit transactions. This is added to the ``resources`` folder.\n\n![async-process]\n\n### Camunda Engine is autowired in the service and a process is started\nThe Engine's RuntimeService is added to the ``ServiceController`` class\n\n```java\n@Autowired\nprivate RuntimeService runtimeService;\n```\n\nand the process model is called directly when the REST request comes in.\n\n```java\nruntimeService.startProcessInstanceByKey(\"ProcessOrder\", businessKey, vars);\n```\n\n### Camunda configuration added\n\nTo log into the webapps a user needs to be defined. This is added to the ``application.yaml`` file\n\n```yaml\ncamunda:\n  bpm:\n    admin-user:\n      id: reb\n      password: reb\n      firstName: Reb\n```\n\n\n[knkarch]: ./images/kuk-arch.png \"the architecture of the micro services\"\n[knkorder1]: ./images/kuk-order1.png \"Cashier front end\"\n[kuk-async-arch]: ./images/kuk-async-arch.png \"Architecture with the Camunda engine\"\n[async-process]: ./images/asyncProcess.png \"Order Sorter Process Model\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpdeehan%2Fkaffee-und-kuchen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnpdeehan%2Fkaffee-und-kuchen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpdeehan%2Fkaffee-und-kuchen/lists"}