{"id":372,"date":"2020-06-07T17:14:46","date_gmt":"2020-06-07T17:14:46","guid":{"rendered":"http:\/\/www.canchito-dev.com\/public\/blog\/?p=372"},"modified":"2021-05-02T13:39:23","modified_gmt":"2021-05-02T13:39:23","slug":"create-custom-service-tasks-for-flowable","status":"publish","type":"post","link":"http:\/\/www.canchito-dev.com\/public\/blog\/2020\/06\/07\/create-custom-service-tasks-for-flowable\/","title":{"rendered":"Create Custom Service Tasks for Flowable"},"content":{"rendered":"<h1 style=\"text-align: justify;\">Create Custom Service Tasks for Flowable<\/h1>\n<p style=\"text-align: justify;\">In this tutorial, we will be implementing a custom service task in Flowable<\/p>\n<h2 style=\"text-align: justify;\">Contribute\u00a0Code<\/h2>\n<p style=\"text-align: justify;\">If you would like to become an active contributor to this project please follow these simple steps:<\/p>\n<div>\n  <a class=\"donate-with-crypto\"\n     href=\"https:\/\/commerce.coinbase.com\/checkout\/faf64f90-2e80-46ee-aeba-0fde14cbeb46\"><br \/>\n    Buy Me a Coffee<br \/>\n  <\/a><br \/>\n  <script src=\"https:\/\/commerce.coinbase.com\/v1\/checkout.js?version=201807\">\n  <\/script>\n<\/div>\n<ol>\n<li style=\"text-align: justify;\">Fork it<\/li>\n<li style=\"text-align: justify;\">Create your feature branch<\/li>\n<li style=\"text-align: justify;\">Commit your changes<\/li>\n<li style=\"text-align: justify;\">Push to the branch<\/li>\n<li style=\"text-align: justify;\">Create new Pull Request<\/li>\n<\/ol>\n<h2 style=\"text-align: justify;\">What you\u2019ll need<\/h2>\n<ul>\n<li style=\"text-align: justify;\">About 40 minutes<\/li>\n<li style=\"text-align: justify;\">A favorite IDE. In this post, we use <a href=\"https:\/\/www.jetbrains.com\/idea\/download\/index.html\">Intellij Community<\/a><\/li>\n<li style=\"text-align: justify;\"><a href=\"http:\/\/www.oracle.com\/technetwork\/java\/javase\/downloads\/index.html\">JDK 7<\/a> or later. It can be made to work with JDK6, but it will need configuration tweaks. Please check the Spring Boot documentation<\/li>\n<\/ul>\n<h2 style=\"text-align: justify;\">Starting with Spring Initializr<\/h2>\n<p style=\"text-align: justify;\">For all Spring applications, it is always a good idea to start with the <a href=\"https:\/\/start.spring.io\/\">Spring Initializr<\/a>. The Initializr is an excellent option for pulling in all the dependencies you need for an application and does a lot of the setup for you. This example needs only the Spring Web, and H2 Database dependency. The following image shows the Initializr set up for this sample project:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"410\" data-permalink=\"http:\/\/www.canchito-dev.com\/public\/blog\/2020\/05\/12\/integrate-flowable-into-your-spring-boot-application\/initializr\/\" data-orig-file=\"http:\/\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/initializr.png\" data-orig-size=\"1438,947\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"CANCHITO-DEV: Spring Initializr\" data-image-description=\"&lt;p&gt;CANCHITO-DEV: Spring Initializr&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;CANCHITO-DEV: Spring Initializr&lt;\/p&gt;\n\" data-large-file=\"http:\/\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/initializr-1024x674.png\" class=\"aligncenter wp-image-410 size-full\" src=\"http:\/\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/initializr.png\" alt=\"CANCHITO-DEV: Spring Initializr\" width=\"1438\" height=\"947\" srcset=\"http:\/\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/initializr.png 1438w, http:\/\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/initializr-300x198.png 300w, http:\/\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/initializr-1024x674.png 1024w, http:\/\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/initializr-768x506.png 768w, http:\/\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/initializr-624x411.png 624w\" sizes=\"auto, (max-width: 1438px) 100vw, 1438px\" \/><\/p>\n<p style=\"text-align: justify;\">The following listing shows the `pom.xml` file that is created when you choose Maven:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt; &lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 https:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt;  \t\t\r\n  &lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;   \r\n  &lt;parent&gt; \r\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;    \r\n    &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;    \r\n    &lt;version&gt;2.2.7.RELEASE&lt;\/version&gt;    \r\n    &lt;relativePath\/&gt; &lt;!-- lookup parent from repository --&gt;    \r\n  &lt;\/parent&gt;    \r\n  &lt;groupId&gt;com.canchitodev.example&lt;\/groupId&gt;    \r\n  &lt;artifactId&gt;spring-flowable-integration&lt;\/artifactId&gt;    \r\n  &lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;    \r\n  &lt;packaging&gt;war&lt;\/packaging&gt;    \r\n    \r\n  &lt;name&gt;spring-flowable-integration&lt;\/name&gt;    \r\n  &lt;description&gt;Demo project for Spring Boot using Flowable BPM&lt;\/description&gt;    \r\n    \r\n  &lt;organization&gt; &lt;name&gt;Canchito Development&lt;\/name&gt;    \r\n    &lt;url&gt;http:\/\/www.canchito-dev.com&lt;\/url&gt;    \r\n  &lt;\/organization&gt;    \r\n  &lt;issueManagement&gt; \r\n    &lt;system&gt;Canchito Development&lt;\/system&gt;    \r\n    &lt;url&gt;https:\/\/github.com\/canchito-dev\/spring-flowable-integration\/issues&lt;\/url&gt;    \r\n  &lt;\/issueManagement&gt;    \r\n  &lt;url&gt;https:\/\/github.com\/canchito-dev\/spring-flowable-integration&lt;\/url&gt;  \r\n    \r\n    &lt;properties&gt;  \r\n    &lt;project.build.sourceEncoding&gt;UTF-8&lt;\/project.build.sourceEncoding&gt;      \t\t\t\t\t\t\t\r\n    &lt;project.reporting.outputEncoding&gt;UTF-8&lt;\/project.reporting.outputEncoding&gt;    \r\n    &lt;java.version&gt;1.8&lt;\/java.version&gt;    \r\n      &lt;flowable.version&gt;6.5.0&lt;\/flowable.version&gt;    \r\n  &lt;\/properties&gt;\r\n  \r\n  &lt;dependencies&gt;\r\n    &lt;!-- Starter for building web, including RESTful, applications using Spring MVC. Uses Tomcat as the default embedded container --&gt;      \r\n    &lt;dependency&gt;  \r\n      &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; \r\n      &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt; \r\n    &lt;\/dependency&gt; \r\n    &lt;!-- Starter for building web, including RESTful, applications using Spring MVC. Uses Tomcat as the default embedded container --&gt; \r\n    \r\n    &lt;!-- H2 Database Engine --&gt;  \r\n    &lt;dependency&gt; \r\n      &lt;groupId&gt;com.h2database&lt;\/groupId&gt; \r\n      &lt;artifactId&gt;h2&lt;\/artifactId&gt; \r\n      &lt;scope&gt;runtime&lt;\/scope&gt; \r\n    &lt;\/dependency&gt; \r\n    &lt;!-- H2 Database Engine --&gt;       \r\n    \r\n    &lt;!-- Starter for using Tomcat as the embedded servlet container. Default servlet container starter used by spring-boot-starter-web --&gt;  \r\n    &lt;dependency&gt;         \r\n      &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; \r\n      &lt;artifactId&gt;spring-boot-starter-tomcat&lt;\/artifactId&gt;   \r\n    &lt;\/dependency&gt;\r\n    &lt;!-- Starter for using Tomcat as the embedded servlet container. Default servlet container starter used by spring-boot-starter-web --&gt;   \r\n\r\n    &lt;!-- Starter for testing Spring Boot applications with libraries including JUnit, Hamcrest and Mockito --&gt;      \r\n    &lt;dependency&gt;    \r\n      &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;    \r\n      &lt;artifactId&gt;spring-boot-starter-test&lt;\/artifactId&gt;    \r\n      &lt;scope&gt;test&lt;\/scope&gt;    \r\n      &lt;exclusions&gt;   \r\n        &lt;exclusion&gt;   \r\n          &lt;groupId&gt;org.junit.vintage&lt;\/groupId&gt;    \r\n          &lt;artifactId&gt;junit-vintage-engine&lt;\/artifactId&gt;    \r\n        &lt;\/exclusion&gt;   \r\n      &lt;\/exclusions&gt;   \r\n    &lt;\/dependency&gt;    \r\n    &lt;!-- Starter for testing Spring Boot applications with libraries including JUnit, Hamcrest and Mockito --&gt;    \r\n  &lt;\/dependencies&gt;   \r\n  &lt;build&gt;      \r\n    &lt;plugins&gt;   \r\n      &lt;plugin&gt;   \r\n        &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;    \r\n        &lt;artifactId&gt;spring-boot-maven-plugin&lt;\/artifactId&gt;    \r\n      &lt;\/plugin&gt;   \r\n    &lt;\/plugins&gt;   \r\n  &lt;\/build&gt; \r\n&lt;\/project&gt;<\/pre>\n<h2 style=\"text-align: justify;\">Adding Flowable&#8217;s Dependencies<\/h2>\n<p style=\"text-align: justify;\">Now, simply add <code>flowable-spring-boot-starter<\/code> dependency. This will add all the engines.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"xml\">&lt;!-- Flowable Spring Boot Starter Basic --&gt;  \r\n&lt;dependency&gt;  \r\n  &lt;groupId&gt;org.flowable&lt;\/groupId&gt; \r\n  &lt;artifactId&gt;flowable-spring-boot-starter-basic&lt;\/artifactId&gt; \r\n  &lt;version&gt;${flowable.version}&lt;\/version&gt;&lt;\/dependency&gt;  \r\n&lt;!-- Flowable Spring Boot Starter Basic --&gt; \r\n\r\n```xml  \r\n&lt;!-- Flowable Spring Boot Starter Rest Api --&gt; \r\n&lt;dependency&gt;\r\n  &lt;groupId&gt;org.flowable&lt;\/groupId&gt;    \r\n  &lt;artifactId&gt;flowable-spring-boot-starter-rest&lt;\/artifactId&gt;    \r\n  &lt;version&gt;${flowable.version}&lt;\/version&gt; \r\n&lt;\/dependency&gt; \r\n&lt;!-- Flowable Spring Boot Starter Rest Api --&gt;<\/pre>\n<p style=\"text-align: justify;\">That\u2019s all that\u2019s needed. This dependency will transitively add the correct Flowable dependencies to the classpath. You can now run your Spring Boot application. But before you do, create the following folders under <code>src\/main\/resources<\/code>:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">src  \r\n |- main \r\n    |- resources \r\n       |- processes \r\n       |- cases \r\n       |- dmn \r\n       |- forms<\/pre>\n<p style=\"text-align: justify;\">If you would like to know a bit more on how to integrate Flowable in our Spring Boot application, have a look at our post <a href=\"http:\/\/www.canchito-dev.com\/public\/blog\/2020\/05\/10\/integrate-flowable-into-your-spring-boot-application\/\">Integrate Flowable into your Spring Boot Application<\/a>.<\/p>\n<h2 style=\"text-align: justify;\">Implementation<\/h2>\n<p style=\"text-align: justify;\">In order to customize the behavior of a <strong>service task<\/strong>, a class that implements the <em>org.flowable.engine.delegate.JavaDelegate <\/em>interface needs to be created, and its respective logic provided in the <em>execute <\/em>method. When process execution arrives at this particular step, it will execute the logic defined in that method and leave the activity in the default BPMN 2.0 way.<\/p>\n<p style=\"text-align: justify;\">Let\u2019s create, for example, a Java class that just prints a text in the log. This class needs to implement the <em>org.flowable.engine.delegate.JavaDelegate <\/em>interface, which requires us to implement the\u00a0 <em>execute(DelegateExecution)<\/em> method. This last method is the one that Flowable will call, and thus, it is the one that needs to have the logic that will be executed. So, create a class and call it <code class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">MyFirstDelegate<\/code>:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">@Service(\"myFirstDelegate\")  \r\n@Scope(\"prototype\")  \r\npublic class MyFirstDelegate implements JavaDelegate {  \r\n  \r\n    public void execute(DelegateExecution execution) {  \r\n        System.out.println(\"This is my first custom service task\");  \r\n  }  \r\n}<\/pre>\n<p style=\"text-align: justify;\">Notice that we have included the Spring annotations <code class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">@Service<\/code> and <code class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">@Scope<\/code>. The <code class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">@Service<\/code> annotations will help us create an instance of the class, while <code class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">@Scope<\/code> tell Spring to create a new instance whenever needed. This is useful because there are a few situations where thread-safety is not guaranteed, depending on the setup or environment Flowable is running in.<\/p>\n<p style=\"text-align: justify;\">The easiest solution to avoid thread-safety issues, is to return a new instance of the delegate class each time the delegate expression is resolved. For example, when using Spring, this means that the scope of the bean must be set to prototype (such as by adding the <code class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">@Scope(SCOPE_PROTOTYPE)<\/code> annotation to the delegate class). Just as we just did.<\/p>\n<p style=\"text-align: justify;\">Let&#8217;s continue by creating a process that uses our delegate class. Inside the folder <code>src\/main\/resources\/processes<\/code>, create a file named <em>my-first-custom-service-task.bpmn20.bpmn20.xml<\/em>. This is a dummy process definition. The content of the file is below:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;  \r\n&lt;definitions xmlns=\"http:\/\/www.omg.org\/spec\/BPMN\/20100524\/MODEL\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xmlns:xsd=\"http:\/\/www.w3.org\/2001\/XMLSchema\" xmlns:flowable=\"http:\/\/flowable.org\/bpmn\" xmlns:bpmndi=\"http:\/\/www.omg.org\/spec\/BPMN\/20100524\/DI\" xmlns:omgdc=\"http:\/\/www.omg.org\/spec\/DD\/20100524\/DC\" xmlns:omgdi=\"http:\/\/www.omg.org\/spec\/DD\/20100524\/DI\" typeLanguage=\"http:\/\/www.w3.org\/2001\/XMLSchema\" expressionLanguage=\"http:\/\/www.w3.org\/1999\/XPath\" targetNamespace=\"http:\/\/www.flowable.org\/processdef\"&gt;  \r\n  &lt;process id=\"myFirstCustomServiceTask\" name=\"My First Custom Service Task\" isExecutable=\"true\"&gt;\r\n    &lt;documentation&gt;This is an example of my first custom service task&lt;\/documentation&gt;  \r\n    &lt;startEvent id=\"startEvent1\" flowable:formFieldValidation=\"true\"&gt;&lt;\/startEvent&gt;  \r\n    &lt;sequenceFlow id=\"sid-E02AD7E3-FE89-462C-86E5-F28860E7D03A\" sourceRef=\"startEvent1\" targetRef=\"sid-DD49004C-1B9B-4CD2-96C6-263B49A91B04\"&gt;&lt;\/sequenceFlow&gt;  \r\n    &lt;serviceTask id=\"sid-DD49004C-1B9B-4CD2-96C6-263B49A91B04\" name=\"My First Delegate\" flowable:delegateExpression=\"${myFirstDelegate}\"&gt;&lt;\/serviceTask&gt;  \r\n    &lt;endEvent id=\"sid-FBAC523F-3400-43D2-B278-9F2068353C8F\"&gt;&lt;\/endEvent&gt;  \r\n    &lt;sequenceFlow id=\"sid-30C0434C-E743-4CE7-9BB8-C1AA92FAEAC2\" sourceRef=\"sid-DD49004C-1B9B-4CD2-96C6-263B49A91B04\" targetRef=\"sid-FBAC523F-3400-43D2-B278-9F2068353C8F\"&gt;&lt;\/sequenceFlow&gt;  \r\n  &lt;\/process&gt;\r\n&lt;\/definitions&gt;<\/pre>\n<p style=\"text-align: justify;\">For simplicity, we will create a REST endpoint that will\u00a0\u00a0let us start a new instance of this recently created process definition. Create a class and call it <code class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">MyRestController<\/code>, and add the following code:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">@RestController  \r\npublic class MyRestController {\r\n  @Autowired  \r\n  private RuntimeService runtimeService;  \r\n\r\n  @PostMapping(value=\"\/process\/{processDefinitionKey}\")  \r\n    public void startProcessInstance(  \r\n      @PathVariable(required = true) String processDefinitionKey  \r\n    ) { \r\n      runtimeService.startProcessInstanceByKey(processDefinitionKey);  \r\n  }  \r\n}<\/pre>\n<p style=\"text-align: justify;\">The endpoint receives as parameter, the process definition id found as path variable. Call it, using <a href=\"https:\/\/curl.haxx.se\/\">cURL<\/a> or <a href=\"https:\/\/www.postman.com\/\">Postman<\/a> as follow: <code>POST http:\/\/localhost:8080\/process\/myFirstCustomServiceTask<\/code>. If everything went well, you should see a log line with this text `This is my first custom service task`.<\/p>\n<h2 style=\"text-align: justify;\">Field Injection<\/h2>\n<p style=\"text-align: justify;\">Field injection is supported when using the <em>&#8216;flowable:class&#8217;<\/em> attribute. To inject values that are dynamically resolved at runtime, expressions can be used. Those expressions can use process variables. Create a class and call it <code class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">MyFirstFieldInjection<\/code>:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">@Service(\"myFirstFieldInjection\")  \r\n@Scope(\"prototype\")  \r\npublic class MyFirstFieldInjection implements JavaDelegate {  \r\n  \r\n  private Expression name;  \r\n  \r\n  public void execute(DelegateExecution execution) {  \r\n    System.out.println(String.format(\"Hello %s!\", (String) name.getValue(execution)));  \r\n  }  \r\n}<\/pre>\n<p style=\"text-align: justify;\">To test it, create a file named <em>my-first-field-injection.bpmn20.xml<\/em> inside the folder <code>src\/main\/resources\/processes<\/code>. This is a dummy process definition. The content of the file is below:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">&lt;?xml\u00a0version=\"1.0\"\u00a0encoding=\"UTF-8\"?&gt;\u00a0\u00a0\r\n&lt;definitions\u00a0xmlns=\"http:\/\/www.omg.org\/spec\/BPMN\/20100524\/MODEL\"\u00a0xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\u00a0xmlns:xsd=\"http:\/\/www.w3.org\/2001\/XMLSchema\"\u00a0xmlns:flowable=\"http:\/\/flowable.org\/bpmn\"\u00a0xmlns:bpmndi=\"http:\/\/www.omg.org\/spec\/BPMN\/20100524\/DI\"\u00a0xmlns:omgdc=\"http:\/\/www.omg.org\/spec\/DD\/20100524\/DC\"\u00a0xmlns:omgdi=\"http:\/\/www.omg.org\/spec\/DD\/20100524\/DI\"\u00a0typeLanguage=\"http:\/\/www.w3.org\/2001\/XMLSchema\"\u00a0expressionLanguage=\"http:\/\/www.w3.org\/1999\/XPath\"\u00a0targetNamespace=\"http:\/\/www.flowable.org\/processdef\"&gt;\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0&lt;process\u00a0id=\"myFirstFieldInjection\"\u00a0name=\"My\u00a0First\u00a0Field\u00a0Injection\"\u00a0isExecutable=\"true\"&gt;\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;startEvent\u00a0id=\"startEvent1\"\u00a0flowable:formFieldValidation=\"true\"&gt;&lt;\/startEvent&gt;\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;sequenceFlow\u00a0id=\"sid-D837E274-632E-4E81-88E5-72EAA43E0200\"\u00a0sourceRef=\"startEvent1\"\u00a0targetRef=\"sid-E61DC16F-D9D7-4D83-A5DC-44131A4188F0\"&gt;&lt;\/sequenceFlow&gt;\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;serviceTask\u00a0id=\"sid-E61DC16F-D9D7-4D83-A5DC-44131A4188F0\"\u00a0name=\"My\u00a0First\u00a0Field\u00a0Injection\u00a0Task\"\u00a0flowable:delegateExpression=\"${myFirstFieldInjection}\"&gt;\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;extensionElements&gt;\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;flowable:field\u00a0name=\"name\"&gt;\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;flowable:string&gt;&lt;![CDATA[canchito-dev]]&gt;&lt;\/flowable:string&gt;\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/flowable:field&gt;\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/extensionElements&gt;\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/serviceTask&gt;\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;endEvent\u00a0id=\"sid-03CFCEE6-9EBF-4386-9CE4-8A791DBB56B9\"&gt;&lt;\/endEvent&gt;\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;sequenceFlow\u00a0id=\"sid-3B4BA00A-8E1F-43E9-9D49-EC3DAF03F16B\"\u00a0sourceRef=\"sid-E61DC16F-D9D7-4D83-A5DC-44131A4188F0\"\u00a0targetRef=\"sid-03CFCEE6-9EBF-4386-9CE4-8A791DBB56B9\"&gt;&lt;\/sequenceFlow&gt;\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0&lt;\/process&gt;\r\n&lt;\/definitions&gt;<\/pre>\n<p style=\"text-align: justify;\">Use our previously created to start a new process instances of our newly created process. Call it, using <a href=\"https:\/\/curl.haxx.se\/\">cURL<\/a> or <a href=\"https:\/\/www.postman.com\/\">Postman<\/a> as follow: <code>POST http:\/\/localhost:8080\/process\/myFirstFieldInjection<\/code>. If everything went well, you should see a log line with this text `Hello canchito-dev!`.<\/p>\n<h2>Summary<\/h2>\n<p style=\"text-align: justify;\">In this post, we have shown how to create custom service task in Flowable<span style=\"font-size: 1rem;\">. We hope that, even though this was a very basic introduction, you understood how to use and configure them. We will try to go deeper into Flowable in upcoming posts.<\/span><\/p>\n<p style=\"text-align: justify;\">Please feel free to <a href=\"http:\/\/www.canchito-dev.com\/home\/index#contact\">contact us<\/a>. We will gladly response to any doubt or question you might have.<\/p>\n<p style=\"text-align: justify;\">Source code can be found in our <a href=\"https:\/\/github.com\/canchito-dev\/flowable-custom-service-task\">GitHub<\/a> repository.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In\u00a0this\u00a0tutorial,\u00a0we\u00a0will\u00a0be\u00a0implementing\u00a0a\u00a0custom\u00a0service\u00a0task\u00a0in\u00a0Flowable\u00a0<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[31,30,61,65],"tags":[18,34,13,73,67],"class_list":["post-372","post","type-post","status-publish","format-standard","hentry","category-bpm","category-flowable","category-flowable-bpm","category-spring-boot","tag-bpm","tag-flowable","tag-java","tag-service-task","tag-spring-boot"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p8EwXo-60","jetpack-related-posts":[{"id":419,"url":"http:\/\/www.canchito-dev.com\/public\/blog\/2020\/06\/27\/triggerable-custom-service-tasks-in-flowable\/","url_meta":{"origin":372,"position":0},"title":"Triggerable Custom Service Tasks in Flowable","author":"canchitodev","date":"June 27, 2020","format":false,"excerpt":"In this tutorial, we will be implementing a triggerable custom service task in Flowable. A triggerable task, is one that when it is reached, it is executes its business logic, but once done, it enters a wait state. In order to leave this state, it must be triggered.","rel":"","context":"In &quot;Flowable&quot;","block_context":{"text":"Flowable","link":"http:\/\/www.canchito-dev.com\/public\/blog\/category\/flowable\/"},"img":{"alt_text":"CANCHITO-DEV: Spring Initializr","src":"https:\/\/i0.wp.com\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/initializr.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/initializr.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/initializr.png?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/initializr.png?resize=700%2C400 2x, https:\/\/i0.wp.com\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/initializr.png?resize=1050%2C600 3x, https:\/\/i0.wp.com\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/initializr.png?resize=1400%2C800 4x"},"classes":[]},{"id":477,"url":"http:\/\/www.canchito-dev.com\/public\/blog\/2020\/06\/27\/use-flowable-apps-with-a-custom-rest-api\/","url_meta":{"origin":372,"position":1},"title":"Use Flowable Apps with a Custom REST API","author":"canchitodev","date":"June 27, 2020","format":false,"excerpt":"In this post, you will learn how configure Flowable's apps to use your custom Spring Boot REST API as a backend engine. All this, in a dockerized environment.","rel":"","context":"In &quot;BPM&quot;","block_context":{"text":"BPM","link":"http:\/\/www.canchito-dev.com\/public\/blog\/category\/bpm\/"},"img":{"alt_text":"CANCHITO-DEV: Process engine deployments in Flowable Admin","src":"https:\/\/i0.wp.com\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/process-engine-deployments.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/process-engine-deployments.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/process-engine-deployments.png?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/process-engine-deployments.png?resize=700%2C400 2x, https:\/\/i0.wp.com\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/process-engine-deployments.png?resize=1050%2C600 3x"},"classes":[]},{"id":356,"url":"http:\/\/www.canchito-dev.com\/public\/blog\/2019\/07\/05\/run-flowable-bpm-using-docker-and-mysql\/","url_meta":{"origin":372,"position":2},"title":"Run Flowable BPM using Docker and MySQL","author":"canchitodev","date":"July 5, 2019","format":false,"excerpt":"In this article, you will learn how to compile Flowable source code using MySQL as database source, and generate valid Docker images. Once you have the images, we will use Docker Compose for defining and running a multi-container Docker applications.","rel":"","context":"In &quot;BPM&quot;","block_context":{"text":"BPM","link":"http:\/\/www.canchito-dev.com\/public\/blog\/category\/bpm\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":370,"url":"http:\/\/www.canchito-dev.com\/public\/blog\/2020\/05\/12\/integrate-flowable-into-your-spring-boot-application\/","url_meta":{"origin":372,"position":3},"title":"Integrate Flowable into your Spring Boot Application","author":"canchitodev","date":"May 12, 2020","format":false,"excerpt":"In\u00a0this\u00a0tutorial,\u00a0we\u00a0will\u00a0be\u00a0integrating\u00a0Flowable's\u00a0BPM\u00a0engine\u00a0into\u00a0our\u00a0Spring\u00a0Boot\u00a0application.","rel":"","context":"In &quot;BPM&quot;","block_context":{"text":"BPM","link":"http:\/\/www.canchito-dev.com\/public\/blog\/category\/bpm\/"},"img":{"alt_text":"CANCHITO-DEV: Flowable Test Start Process","src":"https:\/\/i0.wp.com\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/start_process.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/start_process.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/start_process.png?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/start_process.png?resize=700%2C400 2x, https:\/\/i0.wp.com\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/start_process.png?resize=1050%2C600 3x, https:\/\/i0.wp.com\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/start_process.png?resize=1400%2C800 4x"},"classes":[]},{"id":471,"url":"http:\/\/www.canchito-dev.com\/public\/blog\/2020\/06\/27\/flowable-custom-engine-configuration\/","url_meta":{"origin":372,"position":4},"title":"Customizing Flowable Engine","author":"canchitodev","date":"June 27, 2020","format":false,"excerpt":"In this article, we will go into detail on how to customize Flowable's engine. Three changes to the engine will be done: (1) Change the database connection by modifying the data source and adding custom data source properties. (2)Use a strong UUID generator. (3)Implement a custom event handler.","rel":"","context":"In &quot;BPM&quot;","block_context":{"text":"BPM","link":"http:\/\/www.canchito-dev.com\/public\/blog\/category\/bpm\/"},"img":{"alt_text":"CANCHITO-DEV: Spring Initializr","src":"https:\/\/i0.wp.com\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/initializr-1024x674.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/initializr-1024x674.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.canchito-dev.com\/public\/blog\/wp-content\/uploads\/2020\/05\/initializr-1024x674.png?resize=525%2C300 1.5x"},"classes":[]},{"id":184,"url":"http:\/\/www.canchito-dev.com\/public\/blog\/2018\/03\/30\/asynchronous-service-invocation-using-flowable\/","url_meta":{"origin":372,"position":5},"title":"Asynchronous Service Invocation using Flowable","author":"canchitodev","date":"March 30, 2018","format":false,"excerpt":"In this article, I will explain one possible method to solved some \"limitations\" encountered during the integration and implementation of\u00a0Flowable BPM, when executing long-running tasks, by implementing the Signallable Flowable Behavior and a database table as a task queue. Similar behavior can be achieved using Flowable's send task and receive\u2026","rel":"","context":"In &quot;BPM&quot;","block_context":{"text":"BPM","link":"http:\/\/www.canchito-dev.com\/public\/blog\/category\/bpm\/"},"img":{"alt_text":"CANCHITO-DEV: Task Queue Service","src":"https:\/\/i0.wp.com\/canchito-dev.com\/img\/cwm\/userguide\/canchito_dev_task_queue_service.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.canchito-dev.com\/public\/blog\/wp-json\/wp\/v2\/posts\/372","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.canchito-dev.com\/public\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.canchito-dev.com\/public\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.canchito-dev.com\/public\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.canchito-dev.com\/public\/blog\/wp-json\/wp\/v2\/comments?post=372"}],"version-history":[{"count":9,"href":"http:\/\/www.canchito-dev.com\/public\/blog\/wp-json\/wp\/v2\/posts\/372\/revisions"}],"predecessor-version":[{"id":537,"href":"http:\/\/www.canchito-dev.com\/public\/blog\/wp-json\/wp\/v2\/posts\/372\/revisions\/537"}],"wp:attachment":[{"href":"http:\/\/www.canchito-dev.com\/public\/blog\/wp-json\/wp\/v2\/media?parent=372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.canchito-dev.com\/public\/blog\/wp-json\/wp\/v2\/categories?post=372"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.canchito-dev.com\/public\/blog\/wp-json\/wp\/v2\/tags?post=372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}