Thursday, November 10, 2011

Retrieve BPEL payload from the database

Given an instance id, how to get the payload used to invoke the BPEL, from the dehydration database (called SOA infrastructure database in 11G)?

You have two options, each with its pros and cons:

Option 1. Extract payload from process instance data (i.e. "cube instance")
  • Lookup instance handle using conversation Id or instance Id
  • Call the com.oracle.bpel.client.IInstanceHandle.getField("bpelVariableName") API to get the payload. If the variable is a message type, the returned object is a Map and you can get the Element via map.get("partName"). If the variable is an element type, the returned object is an Element object.

Caveats:
  • If your BPEL process change the value of the input variable, this API It will get the latest value, not the initial one.
  • It may not be able to get the variables from the faulted instances. It may only work with successful instances

Option 2. Extract payload from audit trail
  • Lookup instance handle using conversation Id or instance ID
  • Fetch audit trail from instance handle using IInstanceHandle.getAuditXXX() API
  • Use substring functions to extract initiating payload

Caveats:
  • You need to do your own parsing of XML in order to extract the initial payload
  • If you use auditLevel to dial down the audit trail to a certain degree, or even totally suppress it, you may not be able get the payload from audit trail