Oracle® Fusion Middleware Tutorial for Running and Building an Application with Oracle SOA Suite 11g Release 1 (11.1.1) Part Number E10275-02 |
|
|
View PDF |
Business events consist of message data sent as the result of an occurrence in a business environment. When a business event is published, other service components can subscribe to it.
In this chapter, you learn how to subscribe to a business event using Oracle Mediator. At a high-level, you perform the following tasks:
Create OrderPendingEvent
mediator service component to subscribe to the NewOrderSubmitted
business event and initiate the OrderProcessor
BPEL process through a routing rule to process the order through a routing rule.
This chapter contains the following sections:
To create the NewOrderSubmitted
business event:
Click the composite.xml tab to view the SOA Composite Editor.
Launch the Event Definition Creation wizard in either of two ways:
In the SOA Composite Editor, click the Event Definition Creation icon above the designer:
From the File main menu, select New > SOA Tier > Service Components > Event Definition.
The Event Definition Creation dialog appears.
In the Event Definition Name field, enter OrderEO
. Oracle JDeveloper saves the NewOrderSubmitted
event to the orderEO.edl
file.
Leave the default settings for the Namespace field.
Click the Add an Event icon to add an event.
The Add an Event dialog appears.
Enter the following values.
Element | Value |
---|---|
Element |
|
Name | NewOrderSubmitted |
Click OK.
In the Event Definition Creation dialog, click OK.
The Business Events Editor displays with the NewOrderSubmitted
event.
Select Save All from the File main menu to save your work.
Click X in the OrderEO.edl tab to close the definition file.
The business event is published to MDS and you are returned to the SOA Composite Editor.
To subscribe to the NewOrderSubmitted
business event and initiate the OrderProcessor
BPEL process:
Drag a Mediator service component into the SOA Composite Editor. This service component enables you to subscribe to the business event.
From the Templates list, select Subscribe to Events.
The window refreshes to display an events table.
Click the Subscribe to a new event icon to display the Event Chooser dialog.
With the NewOrderSubmitted event selected, click OK.
You are returned to the Create Mediator dialog.
one and only one specifies that events are delivered to the subscriber in its own global (that is, JTA) transaction. Any changes made by the subscriber within the context of that transaction are committed when the event processing is complete. If the subscriber fails, the transaction is rolled back. Failed events are retried a configured number of times before being delivered to the hospital queue.
$publisher specifies the event requires a security role.
In the Create Mediator dialog, click OK.
The OrderPendingEvent
mediator displays in the SOA Composite Editor. The icon on the left side that indicates that mediator is configured for an event subscription.
Click Source.
The following source code provides details about the subscribed event of the mediator service component.
<component name="OrderPendingEvent"> <implementation.mediator src="OrderPendingEvent.mplan"/> <business-events> <subscribe xmlns:sub1="http://schemas.oracle.com/events/edl/OrderEO" name="sub1:NewOrderSubmitted" consistency="oneAndOnlyOne" runAsRoles="$publisher"/> </business-events> </component>
To create a routing rule from the OrderPendingEvent
mediator service component to the OrderProcessor
BPEL process:
Back in the Design tab, drag a wire from OrderPendingEvent to the OrderProcessor reference handle.
Double-click OrderPendingEvent tab to see the rule in the Mediator Editor:
Modify the transformation used for the OrderPendingEvent
mediator service component so that the OrderProcesso
r BPEL process receives input from the NewOrderSubmitted
business event:
Click the transformation icon next to the Transform Using field.
The Event Transformation Map dialog displays.
Select Create New Mapper File, use the default name NewOrderSubmitted_To_WarehouseRequest.xsl
in the accompanying field, and then click OK.
The Data Mapper displays.
On the Source:OrderEO.xsd (left) side, click and drag OrderID to ns1:WarehousreRequest > ns1:orderId on the XSLT File: OrderProcessor.wsdl (right) side. The namespace number values (for example, ns1, ns2) can vary.
The Data Mapper dialog should look like the following now.
Select Save All from the File main menu to save your work.
Click X in the NewOrderSubmitted_To_WarehouseRequest.xsl tab to close the Data Mapper.
With the OrderPendingEvent.mplan tab back in focus, in the Routing Rules section, you should see the transformation updated as follows: