In previous post, we discussed about web service handler.
In web service handler rejected message is handled by web service. In this post
we will discuss about next error handler which is Advanced Queue error handler.
In Queue error handler rejected message is enqueued to advanced
queue.
Please note that your AQ table type is RAW type otherwise
you will see below error.
java.sql.SQLException:
ORA-25215: user_data type and queue type do not match.
Follow below steps to use Advanced Queue error handler for
rejected file.
Queue
Error Handler
First you need to have advanced queue in oracle which
will take the rejected message. Refer my previous post where I explain how to
create advanced queue in Oracle.
For this post we will use below AQ and AQ table which we
created in previous post.
Advanced
Queue- SampleAQ
Advanced
Queue Table - SampleAQTable
File
Polling Service
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-queue">
<enqueue uri="QueueURI"/>
<!-- QueueURI format -
jdbc:oracle:thin:@<host>:<port>:<sid>#<un>/<pw>#queue
-->
</Action>
Please add below content to 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-queue"/>
</condition>
</faultName>
</Conditions>
<Actions>
<!--Rejected Message to AQ-->
<Action
id="ora-queue">
<enqueue
uri="jdbc:oracle:thin:@localhost:1521:xe#sys as sysdba/oracle#SampleAQ"/>
</Action>
</Actions>
</faultPolicy>
</faultPolicies>
Save your changes and deploy this composite to server.
Testing
Put file corrupted file to polling location. You should
see new entry in SampleAQTable.
0 comments :
Post a Comment