{"id":21069298,"url":"https://github.com/selcuksert/process-automation-servicetask","last_synced_at":"2025-10-04T08:52:59.025Z","repository":{"id":130790980,"uuid":"296351492","full_name":"selcuksert/process-automation-servicetask","owner":"selcuksert","description":"RHPAM project with service task usage","archived":false,"fork":false,"pushed_at":"2020-09-23T07:14:19.000Z","size":2392,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-14T02:25:40.640Z","etag":null,"topics":["bpmn","jbpm","kie","kie-server","process","process-automation-manager","redhat","rhpam","servicetask","workitemhandler"],"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/selcuksert.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":"2020-09-17T14:29:37.000Z","updated_at":"2021-10-25T18:06:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"86e6b272-5884-4032-8c5e-d84ab2107c3e","html_url":"https://github.com/selcuksert/process-automation-servicetask","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/selcuksert/process-automation-servicetask","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selcuksert%2Fprocess-automation-servicetask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selcuksert%2Fprocess-automation-servicetask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selcuksert%2Fprocess-automation-servicetask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selcuksert%2Fprocess-automation-servicetask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/selcuksert","download_url":"https://codeload.github.com/selcuksert/process-automation-servicetask/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selcuksert%2Fprocess-automation-servicetask/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278289494,"owners_count":25962354,"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","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bpmn","jbpm","kie","kie-server","process","process-automation-manager","redhat","rhpam","servicetask","workitemhandler"],"created_at":"2024-11-19T18:34:05.498Z","updated_at":"2025-10-04T08:52:58.997Z","avatar_url":"https://github.com/selcuksert.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ToDo List Evaluation Process\nRedHat Process Automation Manager (RHPAM) provides the ability to integrate/utilize different technologies with built-in service tasks. It is also possible to implement custom service tasks where out-of-box capabilities do not fulfill the needs. To implement a custom service task one needs to implement `org.kie.api.runtime.process.WorkItemHandler` interface of KIE API. \n\nFor details, please check [official documentation](https://access.redhat.com/documentation/en-us/red_hat_process_automation_manager/7.8/html-single/custom_tasks_and_work_item_handlers_in_business_central/index).\n\nThis project implements a sample BPM project on RHPAM that uses 3 service tasks:\n* REST Service Task: Built-in service task that is used to call a test API of [JSONPlaceholder](http://jsonplaceholder.typicode.com/)\n* [Logger Service Task](/handlers/log): Custom service task implementation that logs input data as JSON using [SLF4J](http://www.slf4j.org/) and [Jackson ObjectMapper](https://github.com/FasterXML/jackson-databind/blob/master/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java).\n* [MySQL Service Task](/handlers/mysql): Custom service task that persists/inserts task data based on [JSONPlaceholder's ToDo API](http://jsonplaceholder.typicode.com/todos) response schema using [MySQL JDBC driver](https://dev.mysql.com/downloads/connector/j/).\n\n![BPMN diagram](/doc/images/evaluation.bpmn.png)\n\n## Service Task Implementations\nThe two [custom service task types](/handlers) were implemented using KIE Java API which are essentially `WorkItemHandler`s. Due to their nature they are customizable and re-usable throughout processes and projects in Business Central. In order to use them you need to import packaged versions (JAR files) and enable them in Business Central (http(s)://HOST:PORT/business-central). The [official documentation](https://access.redhat.com/documentation/en-us/red_hat_process_automation_manager/7.8/html-single/custom_tasks_and_work_item_handlers_in_business_central/index) contains relevant details throughout implementation and deployment journeys.\n\nThe handler implementations in this project can be build and deployed to an artifact server (here docker hosted Artifactory) using following maven goals:\n```bash\nmvn clean package deploy\n```\nThe resultant JAR file in `target` folder of project is the packaged version that can be imported to Business Central. \n\n## Importing Custom Service Tasks\nIn order to activate custom service tasks (**CustomLogTask**, **MySQLTask**) in Business Central you should follow the procedure set (Chapter 1 - Procedures 1-\u003e4) in [official documentation](https://access.redhat.com/documentation/en-us/red_hat_process_automation_manager/7.8/html-single/custom_tasks_and_work_item_handlers_in_business_central/index#manage-service-tasks-proc_custom-tasks):\n| | |\n|:-------------------------:|:-------------------------:|\n|![import_st_c](/doc/images/service_task_c_file.png)|![import_st_u](/doc/images/service_task_u_file.png)|\n|![import_st_ac](/doc/images/service_task_a_file.png)|![import_st_ac](/doc/images/service_task_ac_file.png)|\n\nThen you need to activate them via ON/OFF switch right hand side of imported ones:\n![service_task_list](/doc/images/service_task_list.png)\n\n## Importing Sample Business Process Project\nThere also exists a [business project](https://github.com/selcuksert/process-automation-servicetask-repo) which uses custom service tasks mentioned here. For a quick start you can directly import the project into Business Central just using Import Project button with setting the repository URL (https://github.com/selcuksert/process-automation-servicetask-repo) in your designated space:\n| | |\n|:----:|:----:|\n|![import_p](/doc/images/import_project.png)|![import_c](/doc/images/import_project_c.png)|\n\n## Activating Service Tasks for Project\nThe procedure set (Chapter 1 - Procedures 6-\u003e10) in [official documentation](https://access.redhat.com/documentation/en-us/red_hat_process_automation_manager/7.8/html-single/custom_tasks_and_work_item_handlers_in_business_central/index#manage-service-tasks-proc_custom-tasks) need to be applied to activate service tasks for any business process project. For the sample project we need *Rest, CustomLogTask, MySQLTask* to be installed:\n| | |\n|:-------------------------:|:-------------------------:|\n![st_project_install](/doc/images/st_project_inst.png) |![project_st_list](/doc/images/project_st_list.png)\n\nIt is also important to note that in deployment settings (MVEL) we need to pass `classLoader` parameter to constructor of WorkItemHandler classes of *Rest, MySQLTask* tasks as KIE classloader needs to be in action to avoid `ClassNotFound` exceptions during process execution:\n![project_wih_settings.png](/doc/images/project_wih_settings.png)\n\n## Service Task Parameters\nBased on their implementations service tasks need input and output parameters for their own processing. \n\n### Process Variables\nThe sample project needs some process level variables (.bpmn file view -\u003e Properties -\u003e Process Data):\n![process_variables](/doc/images/process_variables.png)\n| Name | Data Type |Description|\n|:-----|:----------|:----|\n|taskId|java.lang.Long|Process variable to store task ID input of [JSONPlaceholder's ToDo API](http://jsonplaceholder.typicode.com/todos)|\n|response|[com.corp.todo.Task](https://github.com/selcuksert/process-automation-servicetask-repo/blob/master/src/main/java/com/corp/todo/Task.java)|Custom model that aligns with ToDo API task data schema|\n|insertResult|String|SQL statement execution result|\n\nThe custom model that aligns with the API data schema can easily be added using visual class editor of Business Central (Project Page -\u003e Add Asset -\u003e Data Object):\n![bc_class_editor](/doc/images/bc_class_editor.png)\n\n### REST Service Task\nThe [official documentation (a bit out-dated)](https://access.redhat.com/documentation/en-us/red_hat_jboss_bpm_suite/6.4/html/user_guide/rest_task) contains details on REST Service Task. It is also possible to derive information on input/output parameters and processing logic from WIH implementation class [`RESTWorkItemHandler.java`](https://github.com/kiegroup/jbpm/blob/master/jbpm-workitems/jbpm-workitems-rest/src/main/java/org/jbpm/process/workitem/rest/RESTWorkItemHandler.java).\n\nThe sample project set following parameters (Click on service task -\u003e Properties (Pen icon right hand side) -\u003e Data Assignments):\n![rest_st_params](/doc/images/rest_st_params.png)\n| Name | Data Type | Source |\n|:-----|:----------|:-------|\n|AcceptCharset|String|UTF-8|\n|AcceptHeader|String|application/json|\n|ContentType|String|application/json|\n|ContentTypeCharset|String|UTF-8|\n|HandleResponseErrors|String|true|\n|Method|String|GET|\n|ResultClass|String|[com.corp.todo.Task](https://github.com/selcuksert/process-automation-servicetask-repo/blob/master/src/main/java/com/corp/todo/Task.java)|\n|Url|String|h\u003cspan\u003ettps://jsonplaceholder.typicode.com/todos/#{taskId}\u003c/span\u003e|\n\n| Name | Data Type | Target |\n|:-----|:----------|:-------|\n|Result|[com.corp.todo.Task](https://github.com/selcuksert/process-automation-servicetask-repo/blob/master/src/main/java/com/corp/todo/Task.java)|response|\n\n*One can directly access to any process data variable using `#{paramName.fieldName}`*\n\n### Log Service Task\nThe sample project set following parameters (Click on service task -\u003e Properties (Pen icon right hand side) -\u003e Data Assignments):\n| | |\n|:---:|:---:|\n|![log_completed](/doc/images/log_completed.png)|![log_not_completed](/doc/images/log_not_completed.png)|\n|![log_rest](/doc/images/log_rest.png)|![log_insert](/doc/images/log_insert.png)|\n\n|Task| Name | Data Type | Source |\n|:----|:----|:---|:---|\n|Completed|dataToLog|Object|#{response.completed}|\n|Completed|prettyPrint|String|true|\n|Not Completed|dataToLog|Object|#{response.completed}|\n|Not Completed|prettyPrint|String|true|\n|REST|dataToLog|Object|response|\n|REST|prettyPrint|String|true|\n|Insert|dataToLog|Object|insertResult|\n|Insert|prettyPrint|String|true|\n\n### MySQL Service Task\nThe sample project set following parameters (Click on service task -\u003e Properties (Pen icon right hand side) -\u003e Data Assignments):\n![mysql_params](/doc/images/mysql_params.png)\n| Name | Data Type | Source |\n|:-----|:----------|:-------|\n|username|String|`MySQL DB Username`|\n|password|String|`MySQL DB Password`|\n|url|String|`jdbc:mysql://${host}:${port}/{dbName}`|\n|taskToInsert|Object|response|\n\n| Name | Data Type | Target |\n|:-----|:----------|:-------|\n|completed|String|insertResult|\n\nYou also need to have a table in MySQL with following schema:\n```bash\nmysql\u003e use pam;\nDatabase changed\nmysql\u003e show columns from task;\n+-----------+------------+------+-----+---------+-------+\n| Field     | Type       | Null | Key | Default | Extra |\n+-----------+------------+------+-----+---------+-------+\n| id        | bigint     | YES  |     | NULL    |       |\n| user_id   | bigint     | YES  |     | NULL    |       |\n| title     | mediumtext | YES  |     | NULL    |       |\n| completed | tinyint(1) | YES  |     | NULL    |       |\n+-----------+------------+------+-----+---------+-------+\n4 rows in set (0.01 sec)\n```\n## Triggering the Process\nThe Business Central comes with Swagger Web Interface (default URL: http(s)://${BC_HOST}:${BC_PORT}/kie-server/docs). For details please refer to the [official documentation](https://access.redhat.com/documentation/en-us/red_hat_process_automation_manager/7.8/html-single/interacting_with_red_hat_process_automation_manager_using_kie_apis/index).\n\nAfter successfully build and deploy the project to KIE server one can use POST endpoint `/server/containers/{containerId}/processes/{processId}/instances` under *Process Instances* group to trigger the process:\n| KIE Server Status | Swagger UI |\n|:-----|:----------|\n|![kie-server](/doc/images/kie-server.png)|![swagger](/doc/images/swagger.png)|\n\nThe endpoint requires two parameters:\n* `container id` where the process definition resides -\u003e Deployment\n* `process id` that new instance should be created from -\u003e Definition Id\n\nThese two parameters can be retrieved via process definition page:\n| Process List | Process Details |\n|:-----|:----------|\n|![process_def](/doc/images/process_def.png)|![process_def_det](/doc/images/process_def_det.png)|\n\nThe body of the post request is the taskId (recall process data that we use in API URL):\n```json\n{\n  \"taskId\":#\n}\n```\n\nThe result of the API call is the ID of initiated process:\n![swagger_result](/doc/images/swagger_result.png)\n\n## The conditions on Exclusive Gateway\nAn Exclusive Gateway (or XOR Gateway) joins alternative paths within a Process flow. The flow continues through only one of the paths that satisfies condition set on it. \n![exc_gw](/doc/images/exc_gw.png)\n\nThe sample project joins two paths on an Exclusive Gateway with following conditions:\n| Completed | Not Completed |\n|:-----|:-----|\n|![exc_gw_comp](/doc/images/exc_gw_comp.png)|![exc_gw_not_comp](/doc/images/exc_gw_not_comp.png)|\n\n## Result of the Process Execution\nThe sample project has a business process design that persists data of given task ID to designated MySQL DB if it is **completed**.\n\n### Not Completed Task:\nThe external test API returns following data for task [#1](https://jsonplaceholder.typicode.com/todos/1):\n```json\n{\n  \"userId\": 1,\n  \"id\": 1,\n  \"title\": \"delectus aut autem\",\n  \"completed\": false\n}\n```\n\nAfter execution via Swagger UI the stdout log stream of BC server is as follows (the result of custom log service task executions):\n```bash\ncurl -X POST \"http://localhost:8080/kie-server/services/rest/server/containers/ToDo_1.0.0-SNAPSHOT/processes/ToDo.evaluation/instances\" -H \"accept: application/json\" -H \"content-type: application/json\" -d \"{ \\\"taskId\\\": 1}\"\n```\n\n```\nredhat-pam     | 20-09-2020 19:07:14,817 INFO  [com.corp.concepts.process.automation.handler.log.LogTaskWorkItemHandler] (default task-34) [CustomLogTask-2] Data:\nredhat-pam     |  {\nredhat-pam     |   \"userId\" : 1,\nredhat-pam     |   \"id\" : 1,\nredhat-pam     |   \"title\" : \"delectus aut autem\",\nredhat-pam     |   \"completed\" : false\nredhat-pam     | }\nredhat-pam     | 20-09-2020 19:07:14,836 INFO  [com.corp.concepts.process.automation.handler.log.LogTaskWorkItemHandler] (default task-34) [CustomLogTask-3] Data:\nredhat-pam     |  \"false\"\n```\n\nThe MySQL DB table contains no data:\n```bash\nmysql\u003e use pam;\nDatabase changed\n\nmysql\u003e select * from task;\nEmpty set (0.00 sec)\n```\n\n### Completed Task:\nThe external test API returns following data for task [#44](https://jsonplaceholder.typicode.com/todos/44):\n```json\n{\n  \"userId\": 3,\n  \"id\": 44,\n  \"title\": \"cum debitis quis accusamus doloremque ipsa natus sapiente omnis\",\n  \"completed\": true\n}\n```\n\nAfter execution via Swagger UI the stdout log stream of BC server is as follows (the result of custom log service task executions):\n```bash\ncurl -X POST \"http://localhost:8080/kie-server/services/rest/server/containers/ToDo_1.0.0-SNAPSHOT/processes/ToDo.evaluation/instances\" -H \"accept: application/json\" -H \"content-type: application/json\" -d \"{ \\\"taskId\\\": 44}\"\n```\n\n```\nredhat-pam     | 20-09-2020 19:26:18,417 INFO  [com.corp.concepts.process.automation.handler.log.LogTaskWorkItemHandler] (default task-34) [CustomLogTask-5] Data:\nredhat-pam     |  {\nredhat-pam     |   \"userId\" : 3,\nredhat-pam     |   \"id\" : 44,\nredhat-pam     |   \"title\" : \"cum debitis quis accusamus doloremque ipsa natus sapiente omnis\",\nredhat-pam     |   \"completed\" : true\nredhat-pam     | }\nredhat-pam     | 20-09-2020 19:26:18,438 INFO  [com.corp.concepts.process.automation.handler.log.LogTaskWorkItemHandler] (default task-34) [CustomLogTask-6] Data:\nredhat-pam     |  \"true\"\nredhat-pam     | 20-09-2020 19:26:18,786 INFO  [com.corp.concepts.process.automation.handler.mysql.MySQLWorkItemHandler] (default task-34) Insert statement: com.mysql.jdbc.JDBC42PreparedStatement@3224a981: insert into task (completed,user_id,title,id) values (1,3,'cum debitis quis accusamus doloremque ipsa natus sapiente omnis',44)\nredhat-pam     | 20-09-2020 19:26:18,803 INFO  [com.corp.concepts.process.automation.handler.log.LogTaskWorkItemHandler] (default task-34) [CustomLogTask-8] Data:\nredhat-pam     |  true\n```\n\nThe MySQL DB table contains data of related task:\n```bash\nmysql\u003e use pam;\nDatabase changed\n\nmysql\u003e select * from task;\n+------+---------+-----------------------------------------------------------------+-----------+\n| id   | user_id | title                                                           | completed |\n+------+---------+-----------------------------------------------------------------+-----------+\n|   44 |       3 | cum debitis quis accusamus doloremque ipsa natus sapiente omnis |         1 |\n+------+---------+-----------------------------------------------------------------+-----------+\n1 row in set (0.00 sec)\n```\n\n## Docker\nThe sample project uses Docker images from [docker-images](https://github.com/selcuksert/docker-images) repository:\n```bash\ndocker-compose -f ./docker-images/redhat/pam/docker-compose.yml mysql pam openldap mavenserver\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselcuksert%2Fprocess-automation-servicetask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fselcuksert%2Fprocess-automation-servicetask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselcuksert%2Fprocess-automation-servicetask/lists"}