As mentioned in my previous post, Oracle BPM 11g Quick Tip - Making BPM Process Instance Creation, this is another "Quick Tip" topic. While on a project, I ran into an Oracle 10g SOA Suite guru and the topic came up about setting the value of the Composite Title or Name for an SOA Composite instance. I applied the practice to a BPM 11g Composite with little issue. Afterwards, I noticed that there are a few blog posts for setting the Title/Name in a BPEL process but not any for doing so in BPM.
Why set the Composite Title/Name from within a BPM Process? - In Oracle BPM 11g tracking instances via the Enterprise Manager (EM) console is a very important practice for troubleshooting and understanding what is going on in the BPM process. Setting the composite Title/Name so that the BPM instance can be easily identified, searched, and accessed via the EM will help with any development or administrative tracking efforts.
In the following example I will demonstrate:
- How to set the composite title/name from within a BPM process
- The use of the XPath functions that are necessary for setting the title/name
- The BPM instance being easily identified via the EM.
- Create a new Async BPM process.
- Open the "Start" event and add an Input Argument of String type titled "orderIdArg".
- Create a Process Data Object of String type called "orderId"
- Now drop a script activity into the transition after the "Start" activity. Name should be "Set Composite Title Name". Click OK.
- Double click the "Set Composite Title Name" script activity, and click the Implementation tab. Check the "Associations" check box and click the "Edit Data Associations" pencil icon.
- Drag the "orderId" Process Data Object to the variable assignment area and then click the "Expression Builder" icon.
- In the "Expression Builder" : 1) Change the Mode to "XPath Exp.", 2) In the "Advanced Functions" of the Functions list scroll down to find the "setCompositeInstanceTitle" function. 3) Select the "setCompositeInstanceTitle" function and click the "Insert Into Expression" button to add the function to the Expression area. 4) Select "orderId" from the Variables section and pass the orderId as the argument to the "setCompositeINstanceTitle" by clicking the "Insert Into Expression" button. 5) Cast the orderId argument using the string function. The final result should be "ora:setCompositeInstanceTitle(string(bpmn:getDataObject('orderId')))". It is important to cast the orderId to a string via the "string" function or else the setCompositeTitle() function may fail during runtime. Click OK, OK, and then OK again to return to the process model.
- Double click the "Start" activity. Check the "Use Associations" check box and click the "Edit Data Associations" icon.
- Drag and drop the "orderId" Process Data Object and map it to the "orderIdArg" argument. Click OK and OK again to return to the process model.
- The process should look something like the following:
- Save All.
- Deploy to your environment.
- Create an instance in the process using the number "1234", you can do this using the EM, SoapUI, or another tool.
- Log into the EM.
- Click on your deployed composite and view the instance that was just created.
- You should see something like the following:
Now with the ability to populate the Composite Instance Title/Name from within a BPM process, the EM can be used to search, troubleshoot, and correlate a BPM instance to a Composite Instance via the use of a business value. With this trick up our sleeves, life becomes a little simpler for BPM developers and SOA admins to do their jobs. Enjoy :)