Sunteți pe pagina 1din 6

7/6/2015

How to Recover Initial Messages (Payload) from SOA Audit for Mediator and BPEL components

Fusion Middleware

Fusion Applications

About

Log in

How to Recover Initial Messages (Payload) from SO


Audit for Mediator and BPEL components
January 27, 2014 by Jack Desai

Leave a Comment

Introduction

In Fusion Applications, the status of SOA composite instances are either running, completed, faulted or staled. The
instances become staled immediately (irrespective of current status) when the respective composite is redeployed
same version. The messages (payload) are stored in SOA audit tables until they are purged. The users can go thr
Enterprise Manager and view audit trails and respective messages of each composite. This is good for debugging
instances. However there are situations where you want to re-submit initiation of SOA composite instances in bulk f
following reasons:

The composite was redeployed with the same version number that resulted in all respective instances (complete
successfully, faulted or in-flight) becoming stale (Staled status)
Instances failed because down-stream applications failed and the respective composite did not have an ability to
initial message in persistence storage to retry later

In these cases, it may be necessary to capture the initial message (payload) of many instances in bulk to resubmit
can be managed programmatically through SOA Facade API. The Facade API is part of Oracle SOA Suites Infrastr
Management Java API that exposes operations and attributes of composites, components, services, references an
long as instances are not purged, the developer can leverage SOA Facade API to retrieve initial messages of eithe
or BPEL components programmatically. The captured messages can be either resubmitted immediately or stored in
persistence storage, such as file, jms or database, for later submission. There are several samples, but this post ta
approach of creating a SOA composite that provides the ability to retrieve initial message of Mediator or BPEL com
The sample provides the frame work and you can tailor it to your requirements.

Main Article
SOA Facade API

Please refer to this for complete SOA Facade API documentation. The SOA audit trails and messages work interna
follows:
http://www.ateam-oracle.com/how-to-recover-initial-messages-payload-from-soa-audit-for-mediator-and-bpel-components/

1/6

7/6/2015

How to Recover Initial Messages (Payload) from SOA Audit for Mediator and BPEL components

The Audit Level should be either Production or Development to capture the initial payload
The Audit Trail Threshold determines the location of the initial payload. If the threshold is exceeded, the View X
shown in the audit trail instead of the payload. The default value is 50,000 bytes. These large payloads are store
separate database table: audit_details.

Please refer to the following document for more details on these properties.

Since the SOA composite we are developing will be deployed in the same respective SOA Server, you do not requi
credentials to create the locator object. This is all you need:

TIP: Locator locator = LocatorFactory.createLocator();


Please see the SOA Facade API document for more information the Locator class.

Once the Locator object is created, you can lookup composites and apply various filters to narrow down the search
respective components. This is all explained in detail with examples in the SOA Facade document. Here, we focus o
retrieve the initial messages of the Mediator and BPEL components to resubmit them.

How to retrieve initial payload from BPEL?

In BPEL, the initial payload is either embedded in the audit trail or has a link to it. This is controlled by the audit trai
value. If the payload size exceeds the audit threshold value then the audit trail has a link. This is the main method t
trail:

TIP: auditTrailXml = (String)compInst.getAuditTrail


/* The compInst is an instance Component that is derived from: */
Component lookupComponent = (Component)locator.lookupComponent(componentName);
ComponentInstanceFilter compInstFilter = new ComponentInstanceFilter(); compInstFilter.setId(componentId);

If the payload size exceeds the audit threshold value, then the actual payload is an XML link that is stored in the au
table. The following is the API facade to get it:

TIP: auditDetailXml = (String)locator.executeComponentInstanceMethod(componentType +:+ componentId


auditMethod, new String[]{auditId});
The auditId for SOA is always 0.

How to retrieve initial payload from Mediator

The initial payload in Mediator is never embedded in the Audit Trail. It is always linked and the syntax is similar to B
payload size exceeds the audit threshold value). However, the auditID is in the Mediator audit trail and it must be
get that value for the initial payload. This is the code snippet to get the auditId from Mediator audit trail:
http://www.ateam-oracle.com/how-to-recover-initial-messages-payload-from-soa-audit-for-mediator-and-bpel-components/

2/6

7/6/2015

1
2
3
4
5
6
7
8
9
10
11

How to Recover Initial Messages (Payload) from SOA Audit for Mediator and BPEL components

if (componentType.equals("mediator")) {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(new InputSource(new StringReader(auditTrailXml)));
NodeList nodeList = document.getElementsByTagName("event");
String attribute = nodeList.item(0).getAttributes().getNamedItem("auditId").getNodeValue();
addAuditTrailEntry("The Audit is: " + attribute);
auditId = attribute;auditMethod="getAuditMessage";}

/* Once you have the "auditID" from above code, the syntax to get the initial payload is the same
auditDetailXml = (String)locator.executeComponentInstanceMethod(componentType +":"+ componentId,

Complete Java embedded code in BPEL


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

try {
String componentInstanceID = new Long(getInstanceId()).toString();
addAuditTrailEntry("This Run time Component Instance ID is "+componentInstanceID);

XMLElement compositeNameVar = (XMLElement) getVariableData("inputVariable", "payload", "/client:p


String compositeName = compositeNameVar.getTextContent();

XMLElement compositeIdVar = (XMLElement) getVariableData("inputVariable", "payload", "/client:pro


String compositeId = compositeIdVar.getTextContent();

XMLElement componentTypeVar = (XMLElement) getVariableData("inputVariable", "payload", "/client:p


String componentType = componentTypeVar.getTextContent();

XMLElement componentNameVar = (XMLElement) getVariableData("inputVariable", "payload", "/client:p


String componentName = componentNameVar.getTextContent();

XMLElement componentIdVar = (XMLElement) getVariableData("inputVariable", "payload", "/client:pro


String componentId = componentIdVar.getTextContent();
String auditDetailXml = "null";
String auditTrailXml = "null";
String auditMethod = "getAuditDetails";
String auditId = "0";
addAuditTrailEntry("The lookup Composite Instance Name is "+compositeName);
addAuditTrailEntry("The lookup Composite Instance ID is "+compositeId);
addAuditTrailEntry("The lookup Component Instance Name is "+componentName);
addAuditTrailEntry("The lookup Component Instance Type is " + componentType);
addAuditTrailEntry("The lookup Component Instance ID is "+componentId);
Locator locator = LocatorFactory.createLocator();
Composite composite = (Composite)locator.lookupComposite(compositeName);
Component lookupComponent = (Component)locator.lookupComponent(componentName);
ComponentInstanceFilter compInstFilter = new ComponentInstanceFilter();
compInstFilter.setId(componentId);
List<ComponentInstance> compInstances = lookupComponent.getInstances(compInstFilter);
if (compInstances != null) {
addAuditTrailEntry("====Audit Trail of Instance===");
for (ComponentInstance compInst : compInstances) {
String compositeInstanceId = compInst.getCompositeInstanceId();
String componentStatus = compInst.getStatus();
addAuditTrailEntry("Composite Instance ID is "+compositeInstanceId);

http://www.ateam-oracle.com/how-to-recover-initial-messages-payload-from-soa-audit-for-mediator-and-bpel-components/

3/6

7/6/2015

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98

How to Recover Initial Messages (Payload) from SOA Audit for Mediator and BPEL components

addAuditTrailEntry("Component Status is "+componentStatus);


addAuditTrailEntry("Get Audit Trail");
auditTrailXml = (String)compInst.getAuditTrail();

if (componentType.equals("mediator")) {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(new InputSource(new StringReader(auditTrailXml)));
NodeList nodeList = document.getElementsByTagName("event");
String attribute = nodeList.item(0).getAttributes().getNamedItem("auditId").getNodeVa
addAuditTrailEntry("The Audit is: " + attribute);
auditId = attribute;
auditMethod="getAuditMessage";
}
addAuditTrailEntry("Received Audit Trail");

addAuditTrailEntry("Get Audit Details of: "+ componentType +":"+ componentId + "for audit
try {
auditDetailXml = (String)locator.executeComponentInstanceMethod(componentType +
} catch (Exception e) {
addAuditTrailEntry("Exception in getting audit details:" + e);
}
addAuditTrailEntry("Received Audit Details");

setVariableData("auditTrailString", "payload", "/client:AuditTrailString/client:auditTrai


setVariableData("auditDetailString", "payload", "/client:AuditDetailString/client:auditDe

addAuditTrailEntry("BPEL Variables set");

} catch (Exception e) {
addAuditTrailEntry("Exception in getting Audit Trails and Details");
}
The sample payload to run above composite is:
<element name="process">
<complexType>
<sequence>
<element name="compositeName" type="string"/>
<element name="compositeId" type="string"/>
<element name="componentType" type="string"/>
<element name="componentName" type="string"/>
<element name="componentId" type="string"/>
</sequence>
</complexType>
</element>

Sample Code
Please get the complete Jdeveloper Project as follows:
1. DummySOAApplication to retrieve initial payload of Mediator and BPEL components

2. The SOA Audit Trail Composite SOAAuditTrails that contains the logic to get initial payload of Dummy Compo
http://www.ateam-oracle.com/how-to-recover-initial-messages-payload-from-soa-audit-for-mediator-and-bpel-components/

4/6

7/6/2015

How to Recover Initial Messages (Payload) from SOA Audit for Mediator and BPEL components

3. Sample Payload SOA_audit_payload

All site content is the property of Oracle Corp. Redistribution not allowed without written permission
Like

Tw eet

filed under: architecture , bpel, diagnose and troubleshoot, extend and customize , lifecycle management
tagged with: api, audit trail, bpel, component, component instance , composite , composite instances, compo
fusion , fusion applications, instance , payload , soa, soa composite , soa composites, soa suite , stale

Add Your Comment


You must be logged in to post a comment.

Search this website

Search

Share
0

Categories
Architecture (21)

http://www.ateam-oracle.com/how-to-recover-initial-messages-payload-from-soa-audit-for-mediator-and-bpel-components/

5/6

7/6/2015

How to Recover Initial Messages (Payload) from SOA Audit for Mediator and BPEL components

Recent Posts
Invoke Fusion Cloud Secured RESTFul
Web Services
Oracle VM Storage Repository
Replication for On-Premise Fusion
Applications Disaster Recovery
Node.js Invoking Secured REST
Services in Fusion Cloud Part 1
Fusion HCM Cloud Bulk Integration
Automation
Harvesting Information from IT Systems
Part 1
Important log files and their location in
Fusion Applications
Fusion Applications WebCenter Content
Integration Automating File
Import/Export

Archives
Select Month

Related RSS Feeds


Select RSS Feed

Social

Facebook

Copyright Information

Arch Beat
Privacy at Oracle

Twitter

OTN Group

Terms of use

FMW Group

About the A-Team

All content and s/w code on this site are offered without any warranty, or promise of operational quality or functionality.

http://www.ateam-oracle.com/how-to-recover-initial-messages-payload-from-soa-audit-for-mediator-and-bpel-components/

6/6

S-ar putea să vă placă și