Managing Idempotence in SOA Suite

According to the SOA Suite 12c documentation, an idempotent activity is an activity that can be safely retried. It means if your BPEL Process fails, a rollback operation will be executed and all data won’t be persisted in the database. OK, but sometimes you want to persist some data even your BPEL Process fails. How can you achieve it? Set the operation as nonidempotent and the Dehydration will occur after this operation.

In this post, you will learn how to set an operation as nonidempotent.
As a starting point, let’s use the application created here: Using DB Adapter in SOA Suite 12c.
We will add a new Database Adapter to manage the jobs table, and when we try to add a new employee with a new job, the job will be persisted even if the BPEL Process fails.

Download the sample application: SOAIdempotentApp.zip.

Open the EmployeeProject file.
To create the Database Adapter, right-click External References section, and choose Insert > Database.
In Step 1, set the name as JOBSDbReference and click Next.

managing-idempotence-in-soa-suite1

In Step 2, choose the Database Connection, set the JNDI Name and click Next.
In Step 3, choose Insert Only and Select By Primary Key options, and click Next.

managing-idempotence-in-soa-suite2

In Step 4, click Import Tables button, choose JOBS table, and click Next.

managing-idempotence-in-soa-suite3

In Steps 5, 6, 7 and 8, click Next.
In Step 9, click Finish.

Create a wire between CreateEmployeeBPELProcess and JOBSDbReference.

managing-idempotence-in-soa-suite5

Double-click the CreateEmployeeBPELProcess component and configure the process according the image below.

managing-idempotence-in-soa-suite6

Create a wire between the first Invoke and JOBSDbReference.
In the Edit Invoke dialog, complete the form, create the input and output variables, and click OK.

managing-idempotence-in-soa-suite7

Double-click the first Assign component, wire the parameters and click OK.

managing-idempotence-in-soa-suite8

Create a wire between the second Invoke and JOBSDbReference.
In the Edit Invoke dialog, complete the form, create the input variable, and click OK.

managing-idempotence-in-soa-suite9

Double-click the second Assign component, wire the parameters and click OK.

managing-idempotence-in-soa-suite10

Double-click the If component, set the condition and click OK.

managing-idempotence-in-soa-suite11

To force an error, create a new Assertion that validates email string length.
Double-click the Invoke_InsertEmployee component, add a new Assertion and click OK.

managing-idempotence-in-soa-suite12

Double-click the JOBSDbReference and go to Idempotence tab.
Deselect the Idempotent check box for insert operation and click OK.

managing-idempotence-in-soa-suite13

We finished our BPEL Process!
Deploy your SOA Project to Integrated WebLogic Server, go to Enterprise Manager (EM) and test the service.
When you try to add a new employee and sets the email less than 5 characters, the process works well.

managing-idempotence-in-soa-suite14

managing-idempotence-in-soa-suite15

When you try to add a new employee and sets the email with more than 5 characters, the process fails, but the new job is added.

managing-idempotence-in-soa-suite16

managing-idempotence-in-soa-suite17

Waslley Souza

Author: Waslley Souza

Consultor Oracle com foco em tecnologias Oracle Fusion Middleware e SOA. Certificado Oracle WebCenter Portal, Oracle ADF e Java.

Leave a Reply

Your email address will not be published. Required fields are marked *