By Juergenkress-Oracle on Jun 18, 2015
A very common use case for using an SLA (Service Level Agreement) is when there is a start date-time (not necessarily the current date-time) and an end date-time and you want to use the time difference between those two dates as your SLA in your BPM process. In the good old BPM 10g days you could do that easily. You could take the two dates and subtract one from the other and the result could be used as a SLA value. Unfortunately, the same cannot be done in BPM 11g as easily but we do have a solution.
The following will demonstrate how the above scenario can be achieved in BPM 11g. Since the SLA calculation itself is just a few lines of Java code, we will use a BPEL component called 'Java Embedding' for it. It does exactly what the name suggests; it embeds Java code into a BPEL process. In this blog, we will kill two birds with one stone and will look at the Java code to calculate the SLA value and also look at how to embed that into a reusable BPEL process. The BPEL process can then be referenced or invoked from any client, including a BPM process.
- Create a very simple reusable synchronous BPEL process. This BPEL process will be the SLA calculation utility. The input payload will have the two date-times (start date-time and end date-time) as strings. The output payload will have the calculated SLA value as string.
- We will set the output variable in the ‘Java Embedding’ component later, but for it to work the output variable has to have already been initialized. Therefore, let’s initialize the output variable. Drag the ‘Assign’ component and give it an appropriate name and assign a default value to the output variable. I have assigned it ‘PT60M’, which translates to 60 minutes Duration. Here are some examples of Duration code:
PT5M - five minutes
P1D - a day
P1M - a month
P1Y1DT1H1S - one year, one day, one hour, and one second
For regular information on Oracle SOA Suite become a member in the SOA & BPM Partner Community for registration please visit www.oracle.com/goto/emea/soa (OPN account required) If you need support with your account please contact the Oracle Partner Business Center.