Oracle Fusion Middleware Blog

Hi Guys,

Was busy past couple of months due to work and all. Finally got time to wrtie a new blog. Today, I would be explaining how do you handle rejection messages in BPEL. Rejection messages are basically the messages your composite receives but its not as per the format expected by your service , due to which BPEL instance do not get created. So your flow doesnot goes into your BPEL and there is no way to handle that exception in your code.

Below is the extract taken from Oracle:

The messages that error out before being posted to the service infrastructure are referred to as rejected messages. For example, the Oracle File Adapter selects a file having data in CSV format and tries to translate it to XML format (using NXSD). If there is any error in the translation, this message is rejected and are not be posted to the target composite.
Primarily, adapters and binding components are the generators of rejected messages.

To handle such scenarios where you need to take specific action if you get rejected messages, you can use fault management framework. Lets do it step by step.

To illustrate this, I have created sample interface that reads a CSV file from a location and there is only single receive activity inside the BPEL that will receive the input.

Based on the CSV file , I have created a sample schema and configured our File adapter to read the file based on this schema.

My composite is already deployed on EM. Lets test it. This is the file that I have placed in input directory.

Instance will be created , since the file is in correct format. Verify by opening the instance and checking your input.

Now create a Fault Policy file and fault bindings file and place it in the folder that has composite.xml.

Open the fault policy file and define a fault policy for the rejected messages in the fault-policies.xml file, stored with the composite.xml file in the JDeveloper project directory. In the file add the name of your service adapter in the faultname section. In our case it is “readFile”. And the action define “writeTofile” that will write the rejected message in the location specified with the filename that is given.

Now associate the fault policy with a service endpoint of the composite in fault-bindings.xml, as is done in the following screenshot:

Deploy your composite and place some file in the input directory thats not as per the schema.

New instance wont get genereate. Instead you will see error message under “Faults and Rejected Messages”. Click on the error message and open payload.

Now this failed message will be writtten to the file and the location that we gave in our fault policy. Go to that location and verify the same.

This way , we can handle rejection messages and take appropriate actions depending upon the requirements.

For more information please refer Oracle Documentation: Rejection Messages

Hope this post was useful to you.

Happy Learning,