Skip Headers
Oracle® Fusion Middleware Tutorial for Running and Building an Application with Oracle SOA Suite
11g Release 1 (11.1.1)

Part Number E10275-02
Go to Documentation Home
Go to Book List
Book List
Go to Table of Contents
Go to Index
Go to Feedback page
Contact Us

Go to previous page
Go to next page
View PDF

7 Adding the OrderPendingEvent Mediator Service Component

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:

This chapter contains the following sections:

7.1 Task 1: Create the NewOrderSubmitted Business Event

To create the NewOrderSubmitted business event:

  1. Click the composite.xml tab to view the SOA Composite Editor.

  2. Launch the Event Definition Creation wizard in either of two ways:

    1. In the SOA Composite Editor, click the Event Definition Creation icon above the designer:

      Description of bp_edn1.gif follows
      Description of the illustration bp_edn1.gif

    2. From the File main menu, select New > SOA Tier > Service Components > Event Definition.

    The Event Definition Creation dialog appears.

  3. In the Event Definition Name field, enter OrderEO. Oracle JDeveloper saves the NewOrderSubmitted event to the orderEO.edl file.

  4. Leave the default settings for the Namespace field.

  5. Click the Add an Event icon to add an event.

    The Add an Event dialog appears.

  6. Enter the following values.

    Element Value
    1. Click the Browse icon to select the payload.

      The Type Chooser dialog displays.

    2. Expand Project Schema Files > OrderEO.xsd and select NewOrderSubmittedInfo. You imported this schema file when you copied the services in Section 5.2, as you were creating the OrderProcessor BPEL process.

    3. Click OK.

    Name NewOrderSubmitted

  7. Click OK.

  8. In the Event Definition Creation dialog, click OK.

    The Business Events Editor displays with the NewOrderSubmitted event.

  9. Select Save All from the File main menu to save your work.

  10. 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.

7.2 Task 2: Create Mediator Service Component to Subscribe to NewOrderSubmitted Business Event

To subscribe to the NewOrderSubmitted business event and initiate the OrderProcessor BPEL process:

  1. Drag a Mediator service component into the SOA Composite Editor. This service component enables you to subscribe to the business event.

  2. In the Name field, enter OrderPendingEvent.

  3. From the Templates list, select Subscribe to Events.

    The window refreshes to display an events table.

  4. Click the Subscribe to a new event icon to display the Event Chooser dialog.

  5. With the NewOrderSubmitted event selected, click OK.

    You are returned to the Create Mediator dialog.

    Description of bp_edn3.gif follows
    Description of the illustration bp_edn3.gif

    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.

  6. 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.

    Description of bp_edn4.gif follows
    Description of the illustration bp_edn4.gif

  7. 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"/>
          <subscribe xmlns:sub1=""
                     name="sub1:NewOrderSubmitted" consistency="oneAndOnlyOne"

7.3 Task 3: Route OrderPendingEvent Mediator Service Component to OrderProcessor BPEL Process

To create a routing rule from the OrderPendingEvent mediator service component to the OrderProcessor BPEL process:

  1. Back in the Design tab, drag a wire from OrderPendingEvent to the OrderProcessor reference handle.

    Description of wire3.gif follows
    Description of the illustration wire3.gif

  2. Double-click OrderPendingEvent tab to see the rule in the Mediator Editor:

    Description of neworder.gif follows
    Description of the illustration neworder.gif

  3. Modify the transformation used for the OrderPendingEvent mediator service component so that the OrderProcessor BPEL process receives input from the NewOrderSubmitted business event:

    1. Click the transformation icon next to the Transform Using field.

      The Event Transformation Map dialog displays.

    2. 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.

    3. 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.

      Description of mapper6.gif follows
      Description of the illustration mapper6.gif

    4. Select Save All from the File main menu to save your work.

    5. 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:

      Description of neworder2.gif follows
      Description of the illustration neworder2.gif