Showing posts with label EDN. Show all posts
Use of Event Delivery Network (EDN) : Tutorial - POProcessing
You add a new mediator component called receivePO, which subscribes to an event called NewPO and sends the received PO to the routePO service.
1. Open the POProcessing application in JDeveloper and open composite.xml, and click on the Event Definition Creation icon:
2. In the Event Definition Creation window, enter POEvents as the name of the event definition. Accept the namespace value generated.
3. Add a new event by clicking on the + icon.
4. Select the PuchaseOrder element from the po.xsd file using the chooser.
5. Enter NewPO as the name of the event and click on OK to close the Add an Event window.
6. Click on OK to complete the event definition.
7. Close the POEvents.edl panel.
8. Save all.
Subscribing to the NewPO event
1. Drag-and-drop a Mediator component onto the composite.
2. Name the mediator receiveNewPO.
3. Select Subscribe to Events for the Template.
4. Click on the + to add an event. Select the NewPO event from the Event Chooser window.
5. Click on OK to accept and create the mediator.
6. Save all.
7. Connect the receiveNewPO mediator to the routePO mediator:
8. Double-click on the receiveNewPO mediator and define a new transformation map. In the transformation-map, map the all the fields from the source to the target.
9. Close the mediator and save all.
Deploying and testing
1. Deploy the POProcessing composite to the server.
2. Browse to the EM console at http://localhost:7001/em.
3. Right-click on folder soa-infra (soa_server1) under folder SOA:
4. Click on item Business Events.
5. You should see the Business Events management page with the NewPO event listed in the Events tab.
6. Select the event and click on the Test… button to publish the event.
7. In the pop-up window, enter the following XML and click on Publish:
<PurchaseOrder xmlns="http://xmlns.oracle.com/ns/order">8. You should get a "The Event published successfully" message.
<CustID>1111</CustID>
<ID>33412</ID>
<productName>Sony Bluray DVD Player</productName>
<itemType>Electronics</itemType>
<price>350</price>
<quantity>5</quantity>
<status>Initial</status>
<ccType>Mastercard</ccType>
<ccNumber>1234-1234-1234-1234</ccNumber>
</PurchaseOrder>
9. Click on soa-infra in the navigation panel on the left to get the soa-infra dashboard.
10. Click on the POProcessing composite to view new instances. You should see an instance created for processing the event you just published. Click on the instance ID to view the flow trace.
Event Delivery Network (EDN)
The Event Delivery Network (EDN) in Oracle SOA Suite 11g provides a declarative way to use a publish/subscribe model to generate and consume business events without worrying about the underlying message infrastructure.
Developers only need to produce or consume events without having to deal with any particular messaging API like JMS, AQ, and MQ, and so on.
EDN uses an XML-based Event Definition Language(EDL), which allows you to define the event and its associated, strongly typed data. This definition is then registered with the SOA Infrastructure and is available to all composites to publish or subscribe.
This allows for a fully-declarative, business-oriented, rather than developer-oriented approach for using events in a SOA application.
Another feature of EDN is the ability to publish and subscribe to these events from a variety of programming environments such as Java, PL/SQL, SOA Composites, and ADF-BC applications.
Creating and managing event definitions
Events are defined using an Event Definition Language (EDL), an XML schema used to build business event definitions.
An EDL consists of the following:
- A global name.
- Custom headers: These can be used for content-based routing without having to parse the XML payload and apply XPath queries to get at the value to be used for the routing decisions.
- Payload definition: Typically this is an XML schema for the business data that needs to accompany the event.
If you want to raise events on one or more database operations such as insertion of a new row or update of an existing one, you can use ADF-BC to define these events.
Registered events, their subscribers, and any faulted deliveries can all be tracked and monitored using the Oracle Enterprise Manager.
Consuming events from the Event Delivery Network
The first step to consume an event is to discover its definition. Event definitions can be stored locally in a composite or globally on the server—in either case, they can be discovered through the JDeveloper resource catalogue.
To subscribe to an event within an SOA composite application, you start by defining a Mediator component, selecting the event of interest from a list of registered events in the network.
To further refine a subscription, and narrow down the information you will receive, you can define an XPath-based filter on your subscriptions.
For example, for an event named "NewPOCreated", you could either subscribe to all "NewPOCreated" events (default when no filter is defined) or only those where the order amount is more than a million dollars (by defining an XPath-based filter on the order amount field within the payload).






