{"id":1316,"date":"2023-02-03T17:03:08","date_gmt":"2023-02-03T14:03:08","guid":{"rendered":"https:\/\/www.bandidor.info\/wp\/?p=1316"},"modified":"2023-06-06T14:42:50","modified_gmt":"2023-06-06T11:42:50","slug":"make-use-of-my-local-camunda-8-cluster-part-ii","status":"publish","type":"post","link":"https:\/\/www.bandidor.info\/wp\/?p=1316","title":{"rendered":"Make Use Of My Local Camunda 8 Cluster &#8211; Part II"},"content":{"rendered":"\n<p>We will convert everything we implemented with Camunda 7 to Camunda 8. Make it work and run in our cluster!<\/p>\n\n\n\n<p>We continue where we left &#8211; <a href=\"http:\/\/make%20use%20of%20my%20local%20camunda%208%20cluster\/\">Make Use Of My Local Camunda 8 Cluster<\/a>.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Preparing the BPMN model<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">Polishing my old BPMN model made for Camunda 7<\/h2>\n\n\n\n<p>Let&#8217;s take a look at the BPM model I created for one of the previous posts <a href=\"https:\/\/www.bandidor.info\/wp\/?p=857\" title=\"Camunda on Oracle Cloud \u2013 will it work?\">Camunda on Oracle Cloud \u2013 will it work?<\/a>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2020\/04\/1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"981\" height=\"426\" src=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2020\/04\/1.png\" alt=\"\" class=\"wp-image-865\" srcset=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2020\/04\/1.png 981w, https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2020\/04\/1-300x130.png 300w, https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2020\/04\/1-768x334.png 768w\" sizes=\"auto, (max-width: 981px) 100vw, 981px\" \/><\/a><\/figure>\n\n\n\n<p>There is one change that has to be applied immediately. The activity <strong>Store invoice<\/strong> is doing nothing in the above model. This won&#8217;t work in Camunda 8. Let&#8217;s convert it in to a Script Task, that would print something to the console:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a href=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-02-193542.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-02-193542.png\" alt=\"\" class=\"wp-image-1317\" width=\"837\" height=\"374\" srcset=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-02-193542.png 933w, https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-02-193542-300x134.png 300w, https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-02-193542-768x343.png 768w\" sizes=\"auto, (max-width: 837px) 100vw, 837px\" \/><\/a><\/figure>\n\n\n\n<p>And this is how the script can be provided directly in the Modeler:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-02-193921.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"603\" src=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-02-193921-1024x603.png\" alt=\"\" class=\"wp-image-1318\" srcset=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-02-193921-1024x603.png 1024w, https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-02-193921-300x177.png 300w, https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-02-193921-768x453.png 768w, https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-02-193921.png 1098w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>More complex scripts can be added to the BPMN file if needed, but for testing purposes, this would be enough. Here is also a link to the documentation &#8211; <a href=\"https:\/\/docs.camunda.org\/manual\/7.18\/reference\/bpmn20\/tasks\/script-task\/\" title=\"\">https:\/\/docs.camunda.org\/manual\/7.18\/reference\/bpmn20\/tasks\/script-task\/<\/a><\/p>\n\n\n\n<p>And after we deploy it to the server and start the process, we will see the following in the engine log file:<\/p>\n\n\n\n\n<pre class=\"terminal\"><code>This prints to the console. Date = 1675368717649<br>This prints to the console. Date = 1675421469210<br>This prints to the console. Date = 1675421505432<\/code><\/pre>\n\n\n\n\n<p>And, just for fun, this is the console output of our small Create Invoice service:<\/p>\n\n\n\n\n<pre class=\"terminal\"><code>Client_1 &#8211;&gt; completed task aaa5d668-a3b0-11ed-a97c-1e2a4b590b03<br>Starting handler\u2026<br>Handler done<br>Database connected, making query<br>Closed database client connection<br>Query done, do the business logic and report success back to the engine<br>Success reported to the engine<br>\u2713 completed task c046a45d-a3b0-11ed-a97c-1e2a4b590b03<br>Client_1 &#8211;&gt; completed task c046a45d-a3b0-11ed-a97c-1e2a4b590b03<\/code><\/pre>\n\n\n\n\n<p>Let&#8217;s discuss what actually happens here.<\/p>\n\n\n\n<p>In our <strong>Create Invoice<\/strong> application, which in fact, a <strong>Service Task<\/strong>, we set the variable <code>date <\/code>to the current date, and when the task completes, it is returned as a process variable alongside with the <code>invoice <\/code>binary object:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; gutter: false; title: ; notranslate\" title=\"\">\n...\nconst date = new Date();\n...\nconst variables = new Variables().setAll({ invoice, date });\n...\ntaskService.complete(task, variables);\n...\n<\/pre><\/div>\n\n\n<p>This process variable, in turn, triggers the Boundary Event, and the process moves on to the next activity &#8211; <strong>Store Invoice<\/strong>. And it logs the date to the console as a Unix timestamp.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Converting to Camunda 8<\/h2>\n\n\n\n<p>Meanwhile, Camunda has published very useful guidelines to help to migration from Camunda 7 to Camunda 8. Here is the page &#8211; <a href=\"https:\/\/camunda.com\/platform-7\/migrate\/\" title=\"\">https:\/\/camunda.com\/platform-7\/migrate\/<\/a>. There is one great tool referenced on this page, and this is the Backend Diagram Converter &#8211; <a href=\"https:\/\/github.com\/camunda-community-hub\/camunda-7-to-8-migration\/tree\/main\/backend-diagram-converter#backend-diagram-converter\" title=\"\">https:\/\/github.com\/camunda-community-hub\/camunda-7-to-8-migration\/tree\/main\/backend-diagram-converter#backend-diagram-converter<\/a>. An executable JAR file can be downloaded here: <a href=\"https:\/\/repo1.maven.org\/maven2\/org\/camunda\/community\/migration\/backend-diagram-converter-cli\/0.4.3\/backend-diagram-converter-cli-0.4.3.jar\" title=\"\">https:\/\/repo1.maven.org\/maven2\/org\/camunda\/community\/migration\/backend-diagram-converter-cli\/0.4.3\/backend-diagram-converter-cli-0.4.3.jar<\/a>. <\/p>\n\n\n\n<p>Let&#8217;s try it:<\/p>\n\n\n\n\n<pre class=\"terminal\"><code>C:\\Users\\XXX&gt;java -Dfile.encoding=UTF-8 -jar backend-diagram-converter-cli-0.4.3.jar engine -d &#8211;csv &#8211;username=demo &#8211;password=demo http:\/\/192.168.2.243:8080\/engine-rest<br>Created .\\converted-c8-order.bpmn<br>Created .\\converted-c8-invoice.v2.bpmn<br>Created .\\converted-c8-reviewInvoice.bpmn<br>Created .\\conversion-results.csv<\/code><\/pre>\n\n\n\n\n<p>The tool connected to our Camunda 7 engine, analyzed three BPMN process models deployed to the engine and produced three converted models together with a CSV file that contains some explanations. Let&#8217;s open the converted BPMN model for our process:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-03-144033.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"477\" src=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-03-144033-1024x477.png\" alt=\"\" class=\"wp-image-1331\" srcset=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-03-144033-1024x477.png 1024w, https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-03-144033-300x140.png 300w, https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-03-144033-768x358.png 768w, https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-03-144033-1536x716.png 1536w, https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-03-144033.png 1657w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>We can see that there are just two error messages. One for the timer and another one for the conditional event. Let&#8217;s fix it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Timer fix<\/h3>\n\n\n\n<p>The timer is easy to fix; it&#8217;s just about adding the proper type. Let&#8217;s do it.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-03-144533.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"509\" src=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-03-144533-1024x509.png\" alt=\"\" class=\"wp-image-1332\" srcset=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-03-144533-1024x509.png 1024w, https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-03-144533-300x149.png 300w, https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-03-144533-768x382.png 768w, https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/02\/Screenshot-2023-02-03-144533.png 1488w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>We just set the Type to Cycle and the Value to &#8220;R10\/PT5S&#8221;, the same as before. At this moment, I realised that the timer definition was wrong in the original model; it had the type &#8220;Duration&#8221;, which was incompatible with the Value &#8220;R10\/PT5S&#8221; and, in fact, didn&#8217;t work.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Fix Conditional Boundary Event<\/h3>\n\n\n\n<p>The second error message tells us that our <strong>Conditional Boundary Event<\/strong> is not supported in Camunda 8 (yet). Here is a good overview of what is currently supported: <a href=\"https:\/\/docs.camunda.io\/docs\/components\/modeler\/bpmn\/bpmn-coverage\/\" title=\"\">BPMN coverage<\/a>. What do we do about that? Well, let&#8217;s take a shortcut.<\/p>\n\n\n\n<p>Our Conditional Boundary Event is supposed to wait for the process variable <code>date<\/code> to be set. But given the fact that we have only one activity in our BPMN model, and this is our <em>Create Invoice<\/em> Service Task, only this Service Task can change\/set the process variable. So, the model can be simplified with a gateway like this:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/05\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"971\" height=\"351\" src=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/05\/image.png\" alt=\"\" class=\"wp-image-1377\" srcset=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/05\/image.png 971w, https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/05\/image-300x108.png 300w, https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/05\/image-768x278.png 768w\" sizes=\"auto, (max-width: 971px) 100vw, 971px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>And the gateway will implement the following logic. If the variable <code>date <\/code>is set, it will continue to the Store Invoice step or just finish the process.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Tidy up Service Task<\/h2>\n\n\n\n<p>Our Service Task <em>Create Invoice<\/em> was automatically converted, but let&#8217;s make sure everything is OK with it. Here is its Properties Panel:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/05\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"846\" height=\"634\" src=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/05\/image-1.png\" alt=\"\" class=\"wp-image-1382\" srcset=\"https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/05\/image-1.png 846w, https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/05\/image-1-300x225.png 300w, https:\/\/www.bandidor.info\/wp\/wp-content\/uploads\/2023\/05\/image-1-768x576.png 768w\" sizes=\"auto, (max-width: 846px) 100vw, 846px\" \/><\/a><\/figure>\n<\/div>\n\n\n\n\n<p>Our very friendly conversion tool added a comment which explains what happened during the conversion. We now have <code>Type = invoice-creator<\/code> and this is the only thing we need to note down and use when creating our Service Task client. <\/p>\n\n\n\n<p>Read on to the next article <a href=\"https:\/\/www.bandidor.info\/wp\/?p=1357\" title=\"Make Use Of My Local Camunda 8 Cluster \u2013 Part III, final\">Make Use Of My Local Camunda 8 Cluster \u2013 Part III, final<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We will convert everything we implemented with Camunda 7 to Camunda 8. Make it work and run in our cluster! We continue where we left &#8211; Make Use Of My Local Camunda 8 Cluster. Preparing the BPMN model Polishing my old BPMN model made for Camunda 7 Let&#8217;s take a look at the BPM model&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":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":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[43,34,55],"tags":[42,35],"class_list":["post-1316","post","type-post","status-publish","format-standard","hentry","category-bpmn","category-camunda","category-camunda-8","tag-bpmn","tag-camunda"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2EszU-le","_links":{"self":[{"href":"https:\/\/www.bandidor.info\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1316","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bandidor.info\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bandidor.info\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bandidor.info\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bandidor.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1316"}],"version-history":[{"count":21,"href":"https:\/\/www.bandidor.info\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1316\/revisions"}],"predecessor-version":[{"id":1439,"href":"https:\/\/www.bandidor.info\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1316\/revisions\/1439"}],"wp:attachment":[{"href":"https:\/\/www.bandidor.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1316"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bandidor.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1316"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bandidor.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1316"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}