In previous post, we discussed about in-build error
handling for file and ftp adapter. In-build error handling will put the corrupted file to default rejected
message folder.
In this post, we will discuss about File Rejection
Handler i.e. how to use Fault Handling Framework to handle errors when we
encounter corrupt file during file polling.
Following error handler we can define inside fault
policies to handler error.
·
Web Service Handler
·
Custom Java Handler
·
JMS Queue
·
File
We will discuss each error handler one by one. In this
post we will discuss about “File” Rejection handler.
File
Rejection Handler
By default adapter put the rejected message to default
folder (C:\Oracle\Middleware\user_projects\domains\base_domain\rejmsgs)
so we can configure this error handler if we want to put that rejected message
to other location.
We need to use Fault Handling Framework to configure the
error handler so we need to have fault-binding.xml and fault-policies.xml file.
Create a new fault-binding.xml file in the same project
and add below content to it.
<?xml
version="1.0" encoding="UTF-8" ?>
<faultPolicyBindings
version="2.0.1"
xmlns="http://schemas.oracle.com/bpel/faultpolicy"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<service
faultPolicy="RejectedMessage">
<name>PollCustomerData</name>
</service>
</faultPolicyBindings>
Please note that “PollCustomerData” is name of the
adapter that poll the file.
Now create a fault-policies.xml file where we add fault
and required action.
For this error handler below is the format for the
action.
<Action
id="ora-file">
<fileAction>
<location>FOLDER_LOCATION</location>
<fileName>FILE_NAME</fileName>
<!--
FILE_NAME will support %ID%(rejected message instance id) or %TIMESTAMP%
wildcards -->
</fileAction>
</Action>
Use below content for fault-policies.xml file.
<?xml
version="1.0" encoding="UTF-8" ?>
<faultPolicies
xmlns="http://schemas.oracle.com/bpel/faultpolicy">
<faultPolicy version="2.0.1"
id="RejectedMessage">
<Conditions>
<!-- remote fault: -->
<faultName
xmlns:rjm="http://schemas.oracle.com/sca/rejectedmessages"
name="rjm:PollCustomerData">
<condition>
<action
ref="ora-file"/>
</condition>
</faultName>
</Conditions>
<Actions>
<!--write rejected message to file-->
<Action id="ora-file">
<fileAction>
<location>D:\rejectedmsgs</location>
<fileName>rejmsg_%ID%_%TIMESTAMP%.xml</fileName>
</fileAction>
</Action>
</Actions>
</faultPolicy>
</faultPolicies>
Please not that fault policy id should be same in both
fault-binding.xml and fault-policies.xml file.
Save your changes and deploy your composite.
Testing
Result
Now put corrupted file to poll folder. You will see file
got deleted and see two files in D:\rejectedmsgs folder.
rejmsg_40003_1399012637053 file contains file content.
rejmsg_40003_1399012637053_metadata file contains
metadata information.
Download sample code from here.
Next post explains about next error handler, File Rejection Handler, Web Service Error Handler for File Adapter.
hi vivek i got the following errors when i tried the above process ,
ReplyDeletein fault-policies.xml
Warning(16,21): schema - (Error) Element 'fileAction' not expected.
Warning(20,16): schema - (Error) Element not completed: 'Action'
warnings in fault-bindings.xml
Warning(5,43): schema - (Error) Element 'service' not expected.
and in some cases i am getting like
Warning(2,66): schema - (Error) Can not find definition for element 'faultPolicies'
Please paste your both the files here. One of the error says , you didn't close the "Action" tag in the file.
DeleteVivek
This comment has been removed by the author.
DeleteThis comment has been removed by the author.
Deletevivek my fault policies are not getting posted here..i dont no y??
DeleteYou can send it to my email id.
DeleteVivek
Ever get past this error, I'm getting the same thing. Just curious if there was a trick.
DeleteThat was just a warning message, if you deploy your composite with this warning, your composite will work as expected.
DeleteVivek
This comment has been removed by the author.
ReplyDeletefault bindings code
ReplyDeleteftpReceiveFlexcubeData
fault policys code
/nfssoa/files/SOA4FSI_PROD/rejmsgs/FCUBS06BillPayPaymentCayInterface
INVALID_MSG_FCUBS06BillPayPaymentCayInterface.*.dat
issue is the rejected file is moving to default rejected messages, that file need in this path /nfssoa/files/SOA4FSI_PROD/rejmsgs/FCUBS06BillPayPaymentCayInterface
what i have to do?
you can simply mention "/nfssoa/files/SOA4FSI_PROD/rejmsgs/FCUBS06BillPayPaymentCayInterface" path in location field.
DeleteHi Vivek,
ReplyDeleteI am using FTP adapter to get files. Is there a way to redirect the rejected messages to same FTP server?
Thanks,
Ram
Hi Vivek,
ReplyDeleteIam using FTP adapter to read files from remote server. Is there a way to write the rejected messages to some location iin the same FTP server instead of writing them in local SOA server.
Thanks,
Ram