Thursday, May 13, 2010

BPEL Process Rejection Handler

Create a new Application in Jdeveloper



Now create a Bpel process



Make it an empty bpel process




NOw create a Partner Link.

In the diagram view, right-click in the left swim lane and select "Create Partner Link".
After naming your partner link, click on the icon to "Browse WSDL Files From Local File System"



Browse to directory SOA_HOME/bpel/system/xmllib/jca and import RejectionMessage.wsdl


and select the wsdl file

When asked to make a local copy, say "Yes".
When asked if you want to create a new wsdl that will allow you to create partner links say yes
For your new partner link, My Role will be RejectionHandlerPortType_Role.




NOw in my case i have soa suite installed at my local system only so it will to fetch the record from local system only.

Now if you see there are two wsdl files created.

RejectionMessage.wsdl and RejectionMessageRef.wsdl

Now open
RejectionMessage.wsdl file and you can see an entry like

import namespace="http://xmlns.oracle.com/pcbpel/errorHandling"
schemaLocation="http://localhost:7200/orabpel/xmllib/jca/JCAErrorHandling.xsd"

It has automatically taken the xsd file as it is in local system.

If it is not the case then you can copy the xsd file in the bpel folder of the process created and the same will work by using

import namespace="http://xmlns.oracle.com/pcbpel/errorHandling"
schemaLocation="JCAErrorHandling.xsd"

but if it is local no need to do all these things just verify the host and port number and save the changes.

Now go to your BPEL process and create a variable


On the Structure tab go to Variables -> Process -> Variables.
Right-click and select Create Variable.
Variable type is Message, and using the icon to the left, browse to Message Types -> Project WSDL Files -> RejectionMessage.wsdl -> Message Types and select RejectionMessage.


and say ok and your variable will get created.



NOw Drag and drop a Receive activity into your process.
For Partner Link select RejectionMessage, for Operation handleRejection
For the variable, select the process variable you just have created by clicking on search icon
Check the "Create Instance" check-box and save your project.




Now your BPEL PRocess rejection handler is complete.Deploy it to the server.

Now we will see how can we use this feature in fault handling.

We often come across a situation wherein we want a situation like if the input is not correct then it should do some corrective action,so let suppose i am having a file adapter which is seeking input in some particular file format and when the correct form of input is not provided it should send an email notification to the client or may be some other logic so we can do so by BPEL process rejcetion handler.

I am not explaining the whole process but top illustartion

create a simple file adapter case which is sseeking input in a particular format.
NOw go to the bpel.xml of the file adapter there you have to make an entyr like this

<property name="rejectedMessageHandlers">bpel://default|rejectionHandler|handleRejection|message
</property>


which is basically in following format

<property name="rejectedMessageHandlers">bpel://<domain>|<process name>|handleRejection|message
</property>

So once you made the changes save your project and deploy it,now as soon as you will put an input file with some different format an instance of rejection handler will be also initiated.

The faulted payload will come to the bpel process rejection handler and you can design your rejection handler process to define the further action as per your business requirement.

This has worked for me.Please try and let me know if some issues.


I wanted to have a scenario

When a wrong input comes it should automatically go to some page where we can correct the payload and resubmit it.Please let me know views on this on how to achieve this.

8 comments:

Yatan said...

hi Mikku, first of all thanks for wonderful post, I have followed this however I am getting error in the console for the 'RejectionHandler'process, If I try to open the process in the BPEL console it gives
An Error Occured :


0

Mikku said...

Hi Yatan,i am not able to see the errors that you are getting at your end.

I believe you are able to deploy the process at your end and while trying to open the bpel process you are getting some issues.

paste me the error messages you are getting at your end.

You can also review the logs in domain.log to find more info about this issue.

SOA_HOME\bpel\domains\default\logs\domain.log

Yatan said...

thanks Mikku, yes you are correct I am able to deploy the process and while opening the process I get error, "An Error Occured : 0",
I was going through BPEL forum "http://forums.oracle.com/forums/thread.jspa?threadID=893394&start=0&tstart=0" where they say to create a Asyshronous process and then change the input type, I hope empty BPEL process and asysn process both can be used.

Mikku said...

Yatan, i never have tried with asynchronous process so i can not comment on the same but as per my understanding rejection handler process are invoked based on error condition.

As you can see in empty bpel process we have created a variable of type rejection message,In case of asynchronous process we map the input variable to this rejection message type,So basically they work as same however we do not need output here so asynchronous bpel process does not make a sense here I believe empty bpel process make much sense here.

I will check with asyn process to know more about the issue you are facing

Yatan said...

thanks Mikku, the issue is, If I design the "rejectionHandler"process as you have told after deploying and testing it in the BPEL console, the process does not open up, it simply gives error-->"An Error Occured : 0"

Mikku said...

MAy be you might have missed some steps,let me check if i have the process still at my end.I will post it to you.

Mikku said...

Yatan i have created a bpel process rejection handler and have uploaded in following location

http://uploading.com/files/9d5e9c2b/RejectionHandler.7z/

Please check if it works for you,this is working fine at my end.Change the port number and host name as per your environment.

Let me know if it works

Mikku said...

if that link doesn't work use this

http://www.sendspace.com/file/9exb1q

Sorry as i m not aware of any site where in i can upload my files :)