{"id":1460,"date":"2016-10-30T05:59:55","date_gmt":"2016-10-30T11:59:55","guid":{"rendered":"http:\/\/garysamuelson.com\/blog\/?p=1460"},"modified":"2018-05-28T08:49:17","modified_gmt":"2018-05-28T14:49:17","slug":"camunda-bpm-straight-through-process-with-apache-camel-event-routing","status":"publish","type":"post","link":"https:\/\/garysamuelson.com\/blog\/?p=1460","title":{"rendered":"Straight Through Process with Camunda BPM and Apache Camel"},"content":{"rendered":"<h3><em>Forward<\/em><\/h3>\n<p>In this article I introduce straight though processing (STP), its relationship to business process management (BPM), and various associated technical details.<\/p>\n<p><a title=\"Source Code\" href=\"https:\/\/github.com\/g4code8\/gs_codesamples\/tree\/master\/bpmcamundacamel2\" target=\"_blank\" rel=\"noopener\">Source code at GitHub<\/a><\/p>\n<h2><b>Introduction<\/b><\/h2>\n<p>Straight through processing (STP) describes the automated and uninterrupted execution of services from beginning to end. The process &#8220;start&#8221; receives enough information so that each subsequent step can move forward with uninterrupted execution. Human intervention is not required.<\/p>\n<p>Business Process Management Notation (BPMN) helps illustrate STP. And, with both concept and illustration we now have an established metaphor for communicating capability across both technical and non-technical audience.<\/p>\n<div id=\"attachment_1466\" style=\"width: 596px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1466\" class=\" wp-image-1466\" src=\"http:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image.png\" alt=\"Business Process Management Notation (BPMN) helps illustrate STP\" width=\"586\" height=\"282\" srcset=\"https:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image.png 854w, https:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image-300x144.png 300w, https:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image-150x72.png 150w, https:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image-400x192.png 400w\" sizes=\"auto, (max-width: 586px) 100vw, 586px\" \/><\/a><p id=\"caption-attachment-1466\" class=\"wp-caption-text\">Business Process Management Notation (BPMN) helps illustrate STP<\/p><\/div>\n<p>&nbsp;<\/p>\n<h2>Architectural Overview: Comparing Service Orchestration Without and With BPM<\/h2>\n<h3><\/h3>\n<h3>Without BPM:<\/h3>\n<p>Though lacking an illustrated process diagram, this architecture still provides STP.<\/p>\n<p><strong>(1)<\/strong> User makes request to web-app&#8217;<br \/>\n<strong>(2)<\/strong> Web-app&#8217; forwards user-request to ReST service infrastructure<br \/>\n<strong>(3)<\/strong> Service infrastructure, or SOA, then breaks out request into a series of back-office service calls<\/p>\n<div id=\"attachment_1467\" style=\"width: 595px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1467\" class=\" wp-image-1467\" src=\"http:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image1.png\" alt=\"Though lacking an illustrated process diagram, this architecture still provides STP\" width=\"585\" height=\"488\" srcset=\"https:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image1.png 1047w, https:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image1-300x250.png 300w, https:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image1-1024x855.png 1024w, https:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image1-150x125.png 150w, https:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image1-400x334.png 400w\" sizes=\"auto, (max-width: 585px) 100vw, 585px\" \/><\/a><p id=\"caption-attachment-1467\" class=\"wp-caption-text\">Though lacking an illustrated process diagram, this architecture still provides STP<\/p><\/div>\n<p>&nbsp;<\/p>\n<h3>With BPM:<\/h3>\n<p>So let&#8217;s make our design a little more interesting by adding BPM to help communicate our concepts and ideas. We&#8217;re working towards meaningful representation. And, BPM&#8217;s pattern of linking together tasks into composite process resonates &#8211; meaning that both developers and analysts (and even management) tend to grasp this message.<\/p>\n<p style=\"padding-left: 30px;\"><em>Tasks, as building-blocks, can be assembled\/re-assembled into composites representing business functions.<\/em><\/p>\n<p>Let&#8217;s review the new architecture with a focus on the new BPM layer:<\/p>\n<p><strong>(1)<\/strong> Service Layer (SOA) makes a single request to BPM<br \/>\n<strong>(2)<\/strong> BPM orchestrates communication with back-office systems<br \/>\n<strong>(3)<\/strong> BPM returns results<\/p>\n<div id=\"attachment_1468\" style=\"width: 605px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image2.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1468\" class=\" wp-image-1468\" src=\"http:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image2.png\" alt=\"Tasks, as building-blocks, can be assembled\/re-assembled into composites representing business functions\" width=\"595\" height=\"719\" srcset=\"https:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image2-123x150.png 123w, https:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image2-400x484.png 400w\" sizes=\"auto, (max-width: 595px) 100vw, 595px\" \/><\/a><p id=\"caption-attachment-1468\" class=\"wp-caption-text\">Tasks, as building-blocks, can be assembled\/re-assembled into composites representing business functions<\/p><\/div>\n<p>&nbsp;<\/p>\n<h2>Reference Implementation<\/h2>\n<p>Focusing on Business Services integration with our BPM layer. Java code example demonstrates <a title=\"Camunda\" href=\"https:\/\/camunda.com\/\" target=\"_blank\" rel=\"noopener\">Camunda BPM<\/a> integration and omits back-office integration (keeping it simple).<\/p>\n<p><strong>(1)<\/strong> Service Layer (SOA) makes a single request to BPM<br \/>\n<strong>(2)<\/strong> BPM prepares a response<br \/>\n<strong>(3)<\/strong> BPM returns results<\/p>\n<div id=\"attachment_1469\" style=\"width: 640px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image3.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1469\" class=\" wp-image-1469\" src=\"http:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image3.png\" alt=\"Java code example demonstrates Camunda-BPM integration and omits back-office integration\" width=\"630\" height=\"525\" srcset=\"https:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image3.png 1966w, https:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image3-300x250.png 300w, https:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image3-1024x855.png 1024w, https:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image3-150x125.png 150w, https:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image3-400x334.png 400w\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" \/><\/a><p id=\"caption-attachment-1469\" class=\"wp-caption-text\">Java code example demonstrates Camunda-BPM integration and omits back-office integration<\/p><\/div>\n<p>&nbsp;<\/p>\n<h2>Adding Asynchronous Behavior<\/h2>\n<p>The above example works fine no matter the number of tasks within our process. But, I&#8217;ve noticed that all our process variables may not be returned, via the above illustrated example, if we configure a task for asynchronous behavior. This is reasonable given the context of model as it launches new threads during the course of execution.<\/p>\n<p>To get all of our process variables back at the end of an asynchronous process we add the <a title=\"Request-reply Pattern\" href=\"http:\/\/www.enterpriseintegrationpatterns.com\/patterns\/messaging\/RequestReply.html\" target=\"_blank\" rel=\"noopener\">request-reply pattern<\/a>. And, <a title=\"Apache Camel\" href=\"http:\/\/camel.apache.org\/\" target=\"_blank\" rel=\"noopener\">Apache Camel <\/a>provides both excellent documentation and implementation to suit our needs.<\/p>\n<p>Our ReST API is now launching our Camunda process via the Camel conext and route defined. The camel route uses WildFly&#8217;s new built-in Artemis JMS implementation to first start the process and then return results.<\/p>\n<p>Let&#8217;s review the new architecture:<\/p>\n<p><strong>(1)<\/strong> Service Layer (SOA) sends request (message), via Camel component, to the queue: JmsBpmStartQueue<br \/>\n<strong>(2)<\/strong> Camel picks up the message and starts the BPM process via a managed bean<br \/>\n<strong>(3)<\/strong> BPM orchestrates communication with back-office systems<br \/>\n<strong>(4)<\/strong> BPM returns results to the JmsBpmStartQueue<br \/>\n<strong>(5)<\/strong> Camel forwards message back to top-level Service (JAX-RS)<\/p>\n<div id=\"attachment_1470\" style=\"width: 634px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image4.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1470\" class=\" wp-image-1470\" src=\"http:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image4.png\" alt=\"To get all of our process variables back at the end of an asynchronous process we need to include the request-reply pattern\" width=\"624\" height=\"777\" srcset=\"https:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image4-240x300.png 240w, https:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image4-120x150.png 120w, https:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image4-400x499.png 400w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/a><p id=\"caption-attachment-1470\" class=\"wp-caption-text\">To get all of our process variables back at the end of an asynchronous process we need to include the request-reply pattern<\/p><\/div>\n<p>&nbsp;<\/p>\n<h2>Reference Implementation showing Apache Camel<\/h2>\n<p><strong>(1)<\/strong> Service Layer (SOA) sends request (message), via Camel component, to the queue: JmsBpmStartQueue<br \/>\n<strong>(2)<\/strong> Camel picks up the message and starts the BPM process via a managed bean<br \/>\n<strong>(3)<\/strong> Bean starts BPM Process<br \/>\n<strong>(4)<\/strong> BPM returns results to the JmsBpmStartQueue<br \/>\n<strong>(5)<\/strong> Camel forwards message back to top-level Service (JAX-RS)<\/p>\n<p>NOTE: Round-trip takes about 127ms (measured from HttpRequester)<\/p>\n<div id=\"attachment_1471\" style=\"width: 780px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image5.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1471\" class=\" wp-image-1471\" src=\"http:\/\/garysamuelson.com\/blog\/wp-content\/uploads\/2016\/10\/Image5.png\" alt=\"Async STP via Apache Camel\" width=\"770\" height=\"1416\" \/><\/a><p id=\"caption-attachment-1471\" class=\"wp-caption-text\">Async STP via Apache Camel<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Forward In this article I introduce straight though processing (STP), its relationship to business process management (BPM), and various associated technical details. Source code at GitHub Introduction Straight through processing (STP) describes the automated and<a class=\"moretag\" href=\"https:\/\/garysamuelson.com\/blog\/?p=1460\"> Read more&hellip;<\/a><\/p>\n","protected":false},"author":1,"featured_media":1466,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24,16,22,20,4,23],"tags":[],"class_list":["post-1460","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apache-camel","category-business-process-management-integration","category-camunda","category-service-component-architecture-sca","category-software-architecture","category-straight-through-processing-stp"],"_links":{"self":[{"href":"https:\/\/garysamuelson.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1460","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/garysamuelson.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/garysamuelson.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/garysamuelson.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/garysamuelson.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1460"}],"version-history":[{"count":8,"href":"https:\/\/garysamuelson.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1460\/revisions"}],"predecessor-version":[{"id":1562,"href":"https:\/\/garysamuelson.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1460\/revisions\/1562"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/garysamuelson.com\/blog\/index.php?rest_route=\/wp\/v2\/media\/1466"}],"wp:attachment":[{"href":"https:\/\/garysamuelson.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/garysamuelson.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/garysamuelson.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}