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.
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.
In Step 4, click Import Tables button, choose JOBS table, and click Next.
In Steps 5, 6, 7 and 8, click Next.
In Step 9, click Finish.
Create a wire between CreateEmployeeBPELProcess and JOBSDbReference.
Double-click the CreateEmployeeBPELProcess component and configure the process according the image below.
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.
Double-click the first Assign component, wire the parameters and click OK.
Create a wire between the second Invoke and JOBSDbReference.
In the Edit Invoke dialog, complete the form, create the input variable, and click OK.
Double-click the second Assign component, wire the parameters and click OK.
Double-click the If component, set the condition and click OK.
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.
Double-click the JOBSDbReference and go to Idempotence tab.
Deselect the Idempotent check box for insert operation and click OK.
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.
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.