{"id":20935215,"url":"https://github.com/kirillesau/camunda-8-spring-example","last_synced_at":"2025-03-13T02:41:51.027Z","repository":{"id":133800996,"uuid":"599953202","full_name":"kirillesau/camunda-8-spring-example","owner":"kirillesau","description":"An example of how to use Camunda 8 with Spring-Boot.","archived":false,"fork":false,"pushed_at":"2023-02-10T13:08:18.000Z","size":82,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-19T19:57:30.809Z","etag":null,"topics":["camunda","java17","spring-boot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kirillesau.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2023-02-10T08:47:59.000Z","updated_at":"2023-02-10T08:49:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"b80f45c2-0ff6-4f43-b8f7-ded76d03f7a8","html_url":"https://github.com/kirillesau/camunda-8-spring-example","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/kirillesau%2Fcamunda-8-spring-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirillesau%2Fcamunda-8-spring-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirillesau%2Fcamunda-8-spring-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirillesau%2Fcamunda-8-spring-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kirillesau","download_url":"https://codeload.github.com/kirillesau/camunda-8-spring-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243330266,"owners_count":20274037,"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":["camunda","java17","spring-boot"],"created_at":"2024-11-18T22:13:44.455Z","updated_at":"2025-03-13T02:41:51.015Z","avatar_url":"https://github.com/kirillesau.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Camunda 8 with Spring Boot example\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n![GitHub last commit](https://img.shields.io/github/last-commit/kirillesau/camunda-8-spring-example)\n[![Java CI with Maven](https://github.com/kirillesau/camunda-8-spring-example/actions/workflows/build%20with%20maven.yml/badge.svg?branch=master)](https://github.com/kirillesau/camunda-8-spring-example/actions/workflows/build%20with%20maven.yml)\n\nFor this example, I am using the [camunda-community-hub](https://github.com/camunda-community-hub) approach as\ndescribed [here](https://github.com/camunda-community-hub/spring-zeebe).\n\n## Prerequisite\n\nThe example requires a [Camunda account](https://docs.camunda.io/docs/next/guides/getting-started/) with access to\nthe [Camunda Platform Console](https://docs.camunda.io/docs/components/console/introduction-to-console/).\n\n## How to run\n\n### Maven\n\n\u003e Note: You can only run it if the credentials have been filled in correctly! See [Modify application.properties\n](README.md#modify-applicationproperties)\n\n```shell\n./mvnw package spring-boot:run\n```\n\nAfter that instances can be started with the following variable content:\n\n````json\n{\n  \"reference\": \"C8_12345\",\n  \"amount\": 100.00,\n  \"cardNumber\": \"1234567812345678\",\n  \"cardExpiry\": \"12/2023\",\n  \"cardCVC\": \"123\"\n}\n````\n\nSee the [official guide](https://docs.camunda.io/docs/components/modeler/web-modeler/start-instance/) for further\ninformation.\n\nThe terminal will show the following output:\n\n````console\n2023-02-10 10:43:00.167 TRACE 31393 --- [pool-4-thread-1] d.k.c.job.CreditCardJobWorker            : start Job for Bpmn-id: paymentProcess\n2023-02-10 10:43:00.168 TRACE 31393 --- [pool-4-thread-1] d.k.c.service.CreditCardService          : Charging Credit Card: 1234567812345678\n2023-02-10 10:43:00.168  INFO 31393 --- [pool-4-thread-1] d.k.c.service.CreditCardService          : Credit Card Data: \n2023-02-10 10:43:00.168  INFO 31393 --- [pool-4-thread-1] d.k.c.service.CreditCardService          : - reference: C8_12345\n2023-02-10 10:43:00.169  INFO 31393 --- [pool-4-thread-1] d.k.c.service.CreditCardService          : - amount: 100.0\n2023-02-10 10:43:00.169  INFO 31393 --- [pool-4-thread-1] d.k.c.service.CreditCardService          : - cardExpiry: 12/2023\n2023-02-10 10:43:00.169  INFO 31393 --- [pool-4-thread-1] d.k.c.service.CreditCardService          : - cardCVC: 123\n````\n\n## Implementation tips\n\n### Modify application.properties\n\nFill the [application.properties](src/main/resources/application.properties)-File with your individual values. Client\ncredentials can be generated in the Camunda 8 Console.\nSee [Set up client connection credentials](https://docs.camunda.io/docs/guides/setup-client-connection-credentials/) for\nfurther information.\n\n```properties\nzeebe.client.cloud.region=\u003cyour region\u003e\nzeebe.client.cloud.clusterId=\u003cyour cluster id\u003e\nzeebe.client.cloud.clientId=\u003cyour client id\u003e\nzeebe.client.cloud.clientSecret=\u003cyour client secret\u003e\n```\n\n### Modify pom.xml\n\nAdd additional dependencies in your pom.xml:\n\n```xml\n...\n\u003cproperties\u003e\n    ...\n    \u003cspring-zeebe.version\u003e8.1.5\u003c/spring-zeebe.version\u003e\n\u003c/properties\u003e\n        ...\n\u003cdependencies\u003e\n...\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.camunda\u003c/groupId\u003e\n    \u003cartifactId\u003espring-zeebe-starter\u003c/artifactId\u003e\n    \u003cversion\u003e${spring-zeebe.version}\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.camunda\u003c/groupId\u003e\n    \u003cartifactId\u003espring-zeebe-test\u003c/artifactId\u003e\n    \u003cversion\u003e${spring-zeebe.version}\u003c/version\u003e\n    \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n\u003c/dependencies\u003e\n        ...\n```\n\n### Modify Application-class\n\n```java\nimport io.camunda.zeebe.spring.client.EnableZeebeClient;\nimport io.camunda.zeebe.spring.client.annotation.Deployment;\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\nimport org.springframework.scheduling.annotation.EnableScheduling;\n\n@EnableZeebeClient\n@SpringBootApplication\n@EnableScheduling\n@Deployment(resources = \"classpath*:*.bpmn\")\npublic class ExampleApplication {\n\n    public static void main(String[] args) {\n        SpringApplication.run(ExampleApplication.class, args);\n    }\n\n}\n\n```\n\n### Add a new bpmn file\n\nAdd your .bpmn file to [resources](src/main/resources).\n\nSee [CreditCardProcess.bpmn](src/main/resources/CreditCardProcess.bpmn) for example.\n\n### Create a new worker\n\n```java\nimport io.camunda.zeebe.client.api.response.ActivatedJob;\nimport io.camunda.zeebe.spring.client.annotation.JobWorker;\nimport io.camunda.zeebe.spring.client.annotation.Variable;\nimport io.camunda.zeebe.spring.client.annotation.VariablesAsType;\nimport org.springframework.stereotype.Component;\n\n@Component\npublic class ExampleWorker {\n\n    // simple worker\n    @JobWorker(type = \"exampleType\")\n    public void handle(final ActivatedJob job) {\n        // implement your code here\n    }\n\n    // worker with 1 variable\n    @JobWorker(type = \"exampleType2\")\n    public void handle2(final ActivatedJob job, @Variable String variableName) {\n        // implement your code here\n    }\n\n    // worker with x variables as object\n    @JobWorker(type = \"exampleType3\")\n    public void handle3(final ActivatedJob job, @VariablesAsType MyCustomObject customObject) {\n        // implement your code here\n    }\n\n}\n```\n\n### Testing\n\n```java\nimport io.camunda.zeebe.client.ZeebeClient;\nimport io.camunda.zeebe.client.api.response.ProcessInstanceEvent;\nimport io.camunda.zeebe.process.test.api.ZeebeTestEngine;\nimport io.camunda.zeebe.spring.test.ZeebeSpringTest;\nimport org.junit.jupiter.api.Test;\nimport org.mockito.Mockito;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.boot.test.context.SpringBootTest;\n\nimport static io.camunda.zeebe.process.test.assertions.BpmnAssert.assertThat;\nimport static io.camunda.zeebe.spring.test.ZeebeTestThreadSupport.waitForProcessInstanceCompleted;\n\n@SpringBootTest\n@ZeebeSpringTest\nclass ExampleTest {\n\n    @Autowired\n    private ZeebeClient zeebe;\n\n    @Autowired\n    private ZeebeTestEngine zeebeTestEngine;\n\n    @Test\n    void creditCardShouldBeCharged() {\n        MyObject myObjectVariables = new MyObject();\n\n        // start a process instance\n        ProcessInstanceEvent processInstance = zeebe.newCreateInstanceCommand() //\n                .bpmnProcessId(\"paymentProcess\").latestVersion() //\n                .variables(myObjectVariables) //\n                .send().join();\n\n        // wait for process completion\n        waitForProcessInstanceCompleted(processInstance);\n\n        // assert that process is finished and my EndEvent is passed\n        assertThat(processInstance)\n                .hasPassedElement(\"My_EndEvent_Id\")\n                .isCompleted();\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirillesau%2Fcamunda-8-spring-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkirillesau%2Fcamunda-8-spring-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirillesau%2Fcamunda-8-spring-example/lists"}