ESB Lesson06 Page 1 Oracle ESB Lesson06: Transactions and Exception Handling Oracle Integration Product Management
ESB Lesson06 Page 1
Oracle ESB Lesson06: Transactions and Exception Handling
Oracle Integration Product Management
ESB Lesson06 Page 2
Scenario Overview
Use CaseForce some exceptions in the CustomerData “CustDBOut” database adapter and to illustrate exception document resubmit errors and transaction boundaries.
ESB Transactions and Document Exception Resubmission
ESB Lesson06 Page 3
Scenario Overview
Features- Console Instance Tracking- ESB Routing Service- Error Hospital- File Adapter
ESB Transactions and Document Exception Resubmission
ESB Lesson06 Page 4
Scenario Overview
Steps- Run ESB CustomerData Demo- Delete customer_data table- Test and view errors- Make DB Adapter Routing Rule
Async- Test and View errors- Create customer_data table- Resubmit from Console instance
tracking
ESB Transactions and Document Exception Resubmission
ESB Lesson06 Page 5
ESB Transaction Rules• ESB Supports Global Transactions
– Including BPEL if using Java bindings between the 2
• Routing Rules Define transaction boundaries– “Async” execution terminates existing txn– “Sync” execution continues inbound txn– ESB has 1 Listener per ESB System per Async Topic
• What does this mean ?– Async routing rules to endpoints in the same ESB system resolve to the same transaction– Async routing rules to endpoints in different ESB system resolve to different transaction
• CustomerData Proof point– Make DB and JMS Routing Rules Async and test– Because they are in the same ESB System, they are in the same transaction– If they were in different ESB Systems, they would be in different transactions
• Non Transaction Endpoints provide special handling– File, FTP, SOAP
ESB Lesson06 Page 6
ESB Exception Retry Rules
• 3 Types of Exceptions– Application/Business faults– Fatal Exceptions– Retryable Exceptions
• Exceptions Visible in Console Instance Tracking• Only Retryable Exceptions can be resubmitted• Yellow Indicates Non Transactional Endpoint• “R” indicates transaction Rollback status
ESB Lesson06 Page 7
Rerun CustomerData Scenario
- Start Server - Copy LegacyCustomer.xml to C:\customer\In dir- View Instance tracking data- Observe 1 global transaction
Note that all services executed successfully and in a single global
transaction
ESB Lesson06 Page 8
Drop Table to Trigger Exception
- Start Developer prompt- Run ..\olite\bin\sql_olite.bat- Enter “drop table customer_data”- Enter ”Commit”
ESB Lesson06 Page 9
Rerun Test for Sync Transaction Exception
- Copy LegacyCustomer.xml to “In” dir- View Instance tracking data- Observe Failed Transaction Path- Click the CustDBOut Service highlighted in Red
Yellow represents non transactional
endpoint
Red represents failed transactional
endpoint
Grey shows skipped transactional
endpoint
Green and red lines shows path of
transaction
ESB Lesson06 Page 10
View File Adapter Rejected Documents
- Navigate to System Explorer and view rejected Messages
- <SOA_HOME>\j2ee\home\jca\CustomerData.CustIn_RS.ReadCustomerData\rejectedMessages
ESB Lesson06 Page 11
View Non Retryable Exception Details
- Click the CustDBOut Service- Click “Errors” Tab- Click “Error Details” button to observe Error msg and “Stack Trace”
ESB Lesson06 Page 12
Go Back to Services View
- Click “Services”- Select “CustOut_RS” in Service Pane- Click “Routing Rules” Tab
ESB Lesson06 Page 13
Change Routing Rule To Async
- Click “+” to expand CustDBOut Routing Rule- Click and set “Rule Execution” to “Asynchronous”- Click “Apply” to save the change
ESB Lesson06 Page 14
View Routing Rule Change
- See “Update Service” response dialogue- Click “OK”- Notice CustDBOut Routing Rule moved to end- Click on “Diagram”- See new “Async” execution rule icon
ESB Lesson06 Page 15
Rerun Test for Async Transaction Exception
- Rerun test by copying “LegacyCustomer.xml” to “C:\Customer\In” dir- View Instance Tracking Data- Observe CustIn and CRMOut executed successfully while CustDBOut Failed
Notice the Asynchronous icon
indicating “CustDBOut” is on a different
transaction
ESB Lesson06 Page 16
Recreate the “customer_data” Table
- Go to sql_olite window- Enter “@c:\customer\create_customer.sql”- Observe table created
ESB Lesson06 Page 17
Resubmit Retryable Exception
- Click “Instances”, “CustDBOut”, “Errors”- Optionally View “Error Details”- Click “Resubmit” and see “Resubmit Successful”
ESB Lesson06 Page 18
View Successfully Resubmitted Transaction
- Refresh page, navigate back and view successful transaction
ESB Lesson06 Page 19
Exception Handling Best Practices - Sync
• Custom Rejection Handlers redirect to JCA destinations• File, AQ, WSIF (JMS, DB …)• Supports both inbound and outbound adapters
• Use JCA Endpoint Property retry semantics• Blocks on Existing Thread• RetryCount, RetryInterval, Location• Configured in JDev or ESB Control• SOAP Location supports auto failover retry array
Location=http://localhost:8888/someurl http://localhost:8889/someotherurl
• Error Notifications Configured on ESB System Page
Use JCA Rejection Handlers for Sync Rules
ESB Lesson06 Page 20
Exception Handling - Rejection Handlers
ESB ErrorHospital
JMS ERROR_TOPIC
ESBControl
ESBAPI
JCAIn
JCAOut
J2EE AS
Error
ManualResubmit
JMS RESUBMIT_TOPIC
• Out of BoxEndpoint Retry
• Interval, Count
Rejection Handlers• Inbound/Outbound
• All JCA endpoints
No Manual Resubmit
Synchronous Routing Rule Delivery
Error
Retry
RejectionHandlers
File, AQ/DBJMS, WSIF
ESB Routing Service
Sync Rules
Async Rules
Error
Alerts
Start
ESB Lesson06 Page 21
Exception Handling - Rejection Handlers
ESB Routing Service
Sync Rules
Async Rules
ESB ErrorHospital
ESBControl
ESBAPI
JCAIn
JCAOut
J2EE AS
Error
ManualResubmit
JMS RESUBMIT_TOPIC
• Out of BoxEndpoint Retry
• Interval, Count
Rejection Handlers• Inbound/Outbound
• All JCA endpoints
• Custom Exception HandlerBPEL or J2EE App
Retry Via SOAP or JCA
BPEL Workflow Approval
Error
Retry
RejectionHandlers
File, AQ/DBJMS, WSIF
SOAP
BPEL, J2EEExceptionHandler
RetryRetry
Error
Synchronous Routing Rule Delivery
JMS ERROR_TOPIC Alerts
Custom AlertsNotifications
Start
ESB Lesson06 Page 22
Exception Handling - Rejection Handlers
...</invocation><endpointProperties><property name="rejectedMessageHandlers" value="file://c:\rejectSample\reject"/></endpointProperties></service>
Example showing how to set a rejection handler to send the message to AQ<property name="rejectedMessageHandlers“
value="queue://jdbc:oracle:thin:@localhost:1521:XE|soademo/soademo|AQ_RAW_IN_ERROR_QUEUE"/>
Example for changing the location of the file adapter rejection handler
ESB supports the same JCA rejection handler functionality as BPEL including File, AQ and WSIF Rejection handlers. Using WSIF, you can redirect ESB error messages to virtually any JCA Adapter such as JMS, DB etc… The snippets below can be inserted into the adapter .esbsvc file after the </invocation> element. Stop JDeveloper and update this file manually with a text editor then reopen in JDeveloper and register it. Double check the change was not overwritten during registration. After registering you can view and edit the new "rejectedMessageHandlers" property in the adapters ESB Control Properties tab.
http://www.oracle.com/technology/products/integration/adapters/pdf/Adapter_TN_004_Adapter_ErrorManagement.pdfFor more information, see this OTN note on the Integration Adapters Page linked below
ESB Lesson06 Page 23
Exception Handling Best Practices - Async
• Use ESB Control for Manual Resubmit• Exceptions propagated to Error Hospital
• ESB Client Management API Enables Retry Automation– Batch resubmit out of box with API sample– Automate retry using custom subscriber to ERROR_TOPIC
– Implement with MDB, BPEL, J2EE applicationAvoid listening on ERROR_TOPIC with ESB JMS Adapter due to potential of error recursion
– Send Custom Notifications– Store Exception Instance Id to DB– Post process exception retry with scheduler, bulk resubmit– Potential use of BPEL Workflow or JMS Router
• Endpoint Properties and Rejection Handlers• Fully supported just like Sync Rules
Use Async Rules for Retryable Exceptions
ESB Lesson06 Page 24
ESB Routing Service
Sync Rules
Async Rules
Exception Handling - Error Hospital
ESB ErrorHospital
ESBControl
ESBAPI
JCAIn
JCASOAP
Out
J2EE AS
Error
ManualResubmit
JMS RESUBMIT_TOPIC
Retry
• Out of BoxManual Resubmit
Endpoint Retry
Error Hospital
Client Mgt API
Alert Notifications
Asynchronous Routing Rule Delivery
JMS ERROR_TOPIC Alerts
Start
ESB Lesson06 Page 25
Exception Handling - Error Hospital
ESB Routing Service
Sync Rules
Async Rules
ESB ErrorHospital
JMS ERROR_TOPIC
ESBControl
ESBAPI
JCAIn
JCASOAP
Out
MDB or BPEL
RetryPolicy DB
BatchRetry App
J2EE AS
PolicyScheduler
Error
ManualResubmit
BatchResubmit
AutomatedResubmit
InstanceId
JMS RESUBMIT_TOPIC
Bulk GUIResubmit
Custom AlertsNotifications
• Out of BoxManual Resubmit
Endpoint Retry
Error Hospital
Client Mgt API
Alert Notifications
• CustomMDB handler
Custom Alerts Notify
Automated Retry
Bulk Resubmit
Policy Scheduler
Asynchronous Routing Rule Delivery
Retry
Alerts
Start