Run the Prototype on Camunda Platform

Goal

The goal of this lab is to make your Twitter QA process executable and run it on the Camunda Spring-Boot application.

Short description

  • Give the process model a meaningful ID and a name.
  • Fill all required properties in the property panel of the Camunda Modeler to make the process executable. Model the services as script task with a script just print something to the console. Set the candidate group to management and model the conditions on the sequence flows as approved or not approved.
  • Save the process in the src/main/resources directory of your project.
  • Restart the spring-boot application.
  • Try your process in the tasklist filling the generic forms.

Detailed steps

  1. Be sure Modeler has been started and the Twitter QA process model is open.

  2. Click on the canvas whitespace if you have not modeled a Pool or click on the Pool head if you have modeled one to put focus on the process. Expand the Properties Panel and enter a more user friendly Process ID and Name. The Properties Panel tab can be found on the right hand side of the screen and can be opened and closed by clicking on it. The ID and Name can be found near the top of the General tab. IDs cannot have have spaces in them whereas Names can. In this example we put in TwitterQAProcess for the ID and Twitter QA for the Name. Also, be sure the Executable checkbox has been enabled. Models from Cawemo are not imported as executable. Be sure to check for that.

  3. Select the first activity in the process to bring up the Context Pad. The activity might be named something like Review tweet. In the Context Pad click on the wrench icon and select User Task to change it into a human task. In the Properties Panel of the task set the Candidate groups field in the Properties Panel to management. See lower right hand corner of the screen shot below. By setting this field, anybody who belongs to the management group will receive this task to complete.

  4. Next, we need to set the conditions of the outgoing sequence flows from the exclusive gateway that asks whether a tweet has been approved or not. Contrary to what you may think, the logic is set on the the outbound sequence flows and not on the gateway itself. Click on the affirmative sequence flow (it might be ‘Yes’ or ‘Approved’ depending on how you modeled it). In the Properties Panel of the affirmative sequence select Expression for the Condition Type and enter #{approved == true} for the Expression. What this means is that we need to set a boolean variable named approved at the Review tweet task and we’ll do this later. Be sure to set the negative sequence flow to Condition Type of Expression and the Expression to #{approved == false}. Another option for the negative sequence flow is to set the sequence flow to Default Flow. You do that by clicking on the wrench in the Context Pad of the negative sequence flow and selecting Default Flow. Choose one method for the negative flow.

  5. For now we’ll use print statements to system out for the next tasks. Later on we’ll add actual integrations. Click on the Publish tweet task (or whatever you named the affirmative sequence task). In the Context Pad click on the wrench icon and select Script Task. The Script Task uses a scroll like icon. In the Properties Panel of the Publish tweet task set Script Format to javascript (it is case insensitive). Leave Script Type to Inline Script and set the script to: print('Tweet published'); Repeat the same for the negative sequence flow task though change the script to something like: print('Tweet rejected');

  6. In order to include the process as part of the application it needs to be saved within your IDE project. In Modeler select File > Save File As and navigate to your src/main/resources folder of your project. Be sure to check your IDE to make sure you can see your bpmn file saved to src/main/resources folder.

  7. If you are running Eclipse, check for autorefresh in the settings. In Eclipse select Window > Preferences and then select General > Workspaces. Enable Refresh using native hooks or polling. Otherwise, if you update the process in Modeler, those changes may not get refreshed in Eclipse. Changes to the process model should get picked up automatically in IntelliJ

  8. Stop the running application and restart it with the maven command you used from the last exercise.

  9. Check the output console for a successful start and process deployment.

  10. Go to Camunda Tasklist by opening a browser and heading to localhost:8080/camunda/app/tasklist/. Login using demo/demo as username and password. Let’s test out the process.

  11. In Tasklist you can start the process by clicking on Start process link in the upper right hand corner.

  12. In the dialog box that appears click on Twitter QA (or whatever name you gave it) to start the process. You’ll then be presented with a screen to add variables before you start the process. Click on the plus (+) sign and add a variable named content of type String with some Value like My tweet. Click on Start

  13. Back in the Tasklist refresh your screen or click on the All Tasks filter. You should see the Review tweet task appear in the list of tasks. If you click on Review tweet in this list a generic screen should appear in the right hand pane. Before you can work on the task you must claim it and bring it into your personal tasklist. That way, nobody else can work on it. So, click on the Claim link at the right hand side of the form and now you can work on the task.

  14. On the generic form let’s load our available variables. Click on Load Variables

  15. We should see the content variable. Next, let’s add an approved boolean. Click on Add a variable +

  16. In the line that appears below content add a variable named approved of type Boolean and check it to approve the tweet. Click on Complete.

  17. Go back to your system out console in your IDE and you should see ‘Tweet published’ in the console.

Illustrated description

Optional

Run it again, this time rejecting the tweet.

On this Page: