When to implement: When a PL/SQL stored procedure needs to initiate a SOA composite application.
Design Pattern Summary: A PL/SQL stored procedure raises an event through the Event Delivery Network within the database. A mediator in the SOA composite application subscribes to the event and routes it as appropriate.
Involved components:
PL/SQL stored procedures
Event Delivery Network database
SOA composite application that includes Oracle Mediator and other components as needed.
Oracle Fusion applications may contain stored procedures that need to invoke a component within a SOA composite application, such as a BPEL process service component. A stored procedure can use the Event Delivery Network database API to publish an event whose payload is xmltype
. An Oracle Mediator service component subscribes to the event by event name or by using a XPath expression on the event payload. The.edl
file (event definition file) for the event can be supplied in the composite or deployed separately in a MAR (metadata archive). When the stored procedure publishes the event, the subscribed Oracle Mediator service component forwards the payload to the BPEL process service component.
This chapter explains how to implement the recommended approach.
To invoke a SOA composite application component from a stored procedure, you must first create the event within the SOA composite application. The stored procedure must then raise the event and pass any required data via the EDN database API.
To invoke a SOA composite application component using PL/SQL:
Example 35-1 Calling the publish_event Method
DECLARE NAMESPACE VARCHAR2(200); LOCAL_NAME VARCHAR2(200); PAYLOAD CLOB; BEGIN NAMESPACE := 'http://xmlns.oracle.com/SubEventMediator/EventDefinition1'; LOCAL_NAME := 'CustomerEvent'; PAYLOAD := to_clob('<eb:business-event xmlns:eb= "http://oracle.com/fabric/businessEvent" xmlns:ob="http://xmlns.oracle.com/SubEventMediator/EventDefinition1"> <eb:name>ob:CustomerEvent</eb:name><eb:content><CU:CustomerData xmlns:CU="http://xmlns.oracle.com/Esb/CustomerData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <CustomerId>A22-9AXC2</CustomerId><CustomerName> Deserae International</CustomerName><Type>Gold</Type><Description>Accounting Outsourcing Partner</Description><Address>3228 Massilon Blvd</Address> <City>Juniper</City><State>Massachusetts</State><Zip>01854</Zip><Country>US </Country><Phone>877-555-9876</Phone><Status>Active</Status> <CreditRating>5</CreditRating><Discount>0</Discount><Terms>30n4</Terms> <EnrollDate>01/1/01</EnrollDate><LastOrderDate>05/05/05/</LastOrderDate> <Currency>USD</Currency><ContactName>Jan Forester</ContactName><ContactTitle>VP Finance</ContactTitle><ContactPhone>877-555-9000</ContactPhone><AccountRep> Geoff Seattle</AccountRep><CampaignRating>2</CampaignRating> <ReferedBy>Houston America Taxco</ReferedBy> </CU:CustomerData></eb:content></eb:business-event>'); EDN_PUBLISH_EVENT( NAMESPACE => NAMESPACE, LOCAL_NAME => LOCAL_NAME, PAYLOAD => PAYLOAD); END;
Secure Oracle Mediator by configuring the property runAsRoles=$publisher
.
When the database connection is established from the middle tier so as to invoke the PL/SQL stored procedure, a session is established with the appropriate identity. This identity is propagated through EDN back to the middle tier for the subscription. The subscription runs as the identity of the publisher.
Related Links
The following documents provide additional information related to subjects discussed in this section:
For details on securing the Oracle Mediator, see Securing the Design Pattern.
For more information about securing this pattern, see Securing Web Services Use Cases .
Verifying the deployment involves the following:
Testing and deploying the use case involves the following main steps:
You can use Oracle Enterprise Manager Fusion Middleware Control Console to verify that the SOA composite was successfully deployed. In Oracle Enterprise Manager Fusion Middleware Control Console, you can select the SOA composite instance and display the result of the event.
Using Oracle Enterprise Manager Fusion Middleware Control Console, you can:
Verify the deployment of the SOA composite.
Test the SOA composite.
Verify the SOA composite test results.
To verify that the SOA composite was successfully deployed and the event was received:
You can check the output log file to verify that the Mediator received the event.
To verify that the event was received using the output log file:
Example 35-2 Example p_n.xml
file
2007-07-25 13:16:02.062 NOTIFICATION Immediate case {WriteCustomer.Write} will be executed 2007-07-25 13:16:02.070 NOTIFICATION No Condition defined 2007-07-25 13:16:02.112 NOTIFICATION Routing rule invoked for operation "{http://xmlns.oracle.com/SubEventMediator/EventDefinition1}CustomerEvent". 2007-07-25 13:16:02.131 NOTIFICATION Transforming the source message to target 2007-07-25 13:16:02.132 NOTIFICATION Source message properties :{tracking.compositeInstanceId=151, tracking.ecid=140.87.4.171:75256:1185394211665:0:1774489684, id=d76fe830-cbdf-4338-8a1a-4687ff4c3a1a} 2007-07-25 13:16:02.142 NOTIFICATION Transformation Cache miss....!!!!!!!!!!!! 2007-07-25 13:16:02.167 NOTIFICATION Getting part {payload} from message:in 2007-07-25 13:16:02.169 NOTIFICATION New document created 2007-07-25 13:16:02.171 NOTIFICATION Calling the real transfomer 2007-07-25 13:16:02.174 NOTIFICATION setting out payload to part :CustomerData 2007-07-25 13:16:02.181 NOTIFICATION Source payload = <CU:CustomerData xmlns:CU="http://xmlns.oracle.com/Esb/CustomerData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><CustomerId xmlns=""> ... 2007-07-25 13:16:02.184 NOTIFICATION Transformed payload = <cust:CustomerData xmlns:cust="http://xmlns.oracle.com/Esb/CustomerData"> ... 2007-07-25 13:16:02.185 NOTIFICATION getPayload:normal payload 2007-07-25 13:16:02.249 NOTIFICATION getPayload:normal payload 2007-07-25 13:16:02.252 NOTIFICATION DEBUG: Mediator sending a request to reference WriteCustomer to its operation = Write 2007-07-25 13:16:04.424 NOTIFICATION Audit Trail for case {DD5F2D003AEB11DC8F1987F2DB38D28C : <case_trail> <event type="case" id="DD5F2D003AEB11DC8F1987F2DB38D28C" parentId="DC6A1EA03AEB11DC8F1987F2DB38D28C" caseName="WriteCustomer.Write" date="1185394562060" auditId="DCEFA2503AEB11DC8F1987F2DB38D28C"> <message>Case "WriteCustomer.Write" processing started</message> </event> <event type="transform" status="Completed" parentId="DD5F2D003AEB11DC8F1987F2DB38D28C" date="1185394562248" auditId="DD7B8EA03AEB11DC8F1987F2DB38D28C"> <message>Transformed message part "CustomerData" using "xsl/CustomerEvent _To_CustomerData.xsl"</message> </event> <event type="publish" status="Completed" parentId="DD5F2D003AEB11DC8F1987F2DB38D28C" date="1185394564317" auditId="DD7B8EA03AEB11DC8F1987F2DB38D28C"> <message>Invoked 1-way operation "Write" on target service "WriteCustomer"</message> </event> </case_trail>
The following documents provide additional information related to subjects discussed in this section:
For more information about testing and debugging your Oracle ADF application, see the chapter "Testing and Debugging ADF Components" of the Developing Fusion Web Applications with Oracle Application Development Framework.
For information about testing the ADF Business Components service, see the chapter "Integrating Web Services Into a Fusion Web Application" in the Developing Fusion Web Applications with Oracle Application Development Framework.
For more information about using the Fusion Middleware Control Console to test deployed SOA composite applications, see the chapter "Automating Testing of SOA Composite Applications" in the Developing SOA Applications with Oracle SOA Suite.
Following are tips that may help resolve common issues that arise when developing or running this use case.
Enable logging for Oracle Mediator using logging.xml
.
For the events functionality, use the Event Delivery Network database log page at http://host:port/soa-infra/events/edn-db-log. The EDN schema name is FUSION_EDN
.
Related Links
See the troubleshooting section in the chapter "Deploying SOA Composite Applications" of the Oracle SOA Suite Developer's Guide for more information.
Before you implement these design patterns, be aware of the following:
Run the sample provided before implementing your own version of this use case. Running the sample ensures that the EDN database queue works as expected.