What You May Need to Know About Using Dynamic Routing Rules How to Define Default Routing Rules

Creating Oracle Mediator Routing Rules 19-47

19.2.5.5 Default Rule: Oracle Mediator .mplan File

To set a routing rule as the default one, click the Set as Default Routing Rule icon shown on Figure 19–2 . The .mplan file changes, as shown in Figure 19–36 . Figure 19–36 .mplan File of an Oracle Mediator with a Default Routing Rule

19.3 Creating an Oracle Mediator for Routing Messages

The CustomerRouter use case provides an overview of how to use an Oracle Mediator in a SOA composite sample application to route messages. For downloading the sample files mentioned in this section, visit the following URL: https:soasamples.samplecode.oracle.com The files are provided in the Basic Routing Sample for Oracle Mediator. The CustomerRouter use case consists of the following steps:

1. Legacy customer files are retrieved from a directory by an adapter service named

ReadCust.

2. The ReadCust adapter service sends the file data to the CustomerRouter Oracle

Mediator.

3. The CustomerRouter Oracle Mediator applies a filter to the XML message payload

to determine whether the message should be routed to the USCustomer reference or CanadaCustomer reference.

4. The CustomerRouter Oracle Mediator then transforms the message to the

structure required by the adapter reference. 19-48 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite 5. The external reference delivers the message to its associated external application. Figure 19–37 provides an overview of the CustomerRouter use case. Figure 19–37 Overview of CustomerRouter Use Case

19.3.1 How to Create the CustomerRouter Use Case

This section provides the design-time tasks for creating, building, and deploying the use case.

19.3.1.1 Task 1: How to Create an Oracle JDeveloper Application and a Project

To create an Oracle JDeveloper application and a project: 1. In Oracle JDeveloper, click File and select New. The New Gallery dialog appears.

2. In the New Gallery, expand the General node, and select the Applications

category.

3. In the Items list, select SOA Application and click OK.

The Create SOA Application wizard appears.

4. In the Application Name field, enter CustomerRouter and then click Next.

The Name your project page appears.

5. In the Project Name field, enter CustomerRouterProject and click Next.

The Configure SOA settings page appears.

6. From the Composite Template list, select Empty Composite and then click Finish.

Creating Oracle Mediator Routing Rules 19-49 The Application Navigator of Oracle JDeveloper is populated with the new application and the project, and the SOA Composite Editor contains a blank palette.

7. From the File menu, select Save All.

19.3.1.2 Task 2: How to Create the CustomerRouter Oracle Mediator Service Component

To create the CustomerRouter Oracle Mediator service component: 1. From the Component Palette, select SOA. 2. Drag and drop a Mediator icon in the Components section. The Create Mediator dialog is displayed.

3. In the Name field, enter CustomerRouter.

4. From the Templates list, select Define Interface Later.

5. Click OK.

A Oracle Mediator with name CustomerRouter is created.

19.3.1.3 Task 3: How to Create a File Adapter Service

You must create a file adapter service named ReadCust to read the XML files from a directory. To create a file adapter service: 1. From the Component Palette, select SOA. 2. Select File Adapter and drag it to the Exposed Services swimlane. The Adapter Configuration wizard Welcome page is displayed.

3. Click Next.

The Service Name page is displayed.

4. In the Service Name field, enter ReadCust.

5. Click Next.

The Adapter Interface page is displayed.

6. Select Define from operation and schema specified later and click Next.

The Operation page is displayed.

7. In the Operation Type field, select Read File.

8. In the Operation Name field, replace Read with ReadFile.

9. Click Next.

The File Directories page is displayed. Note: Oracle Mediator may process the same file twice when run against Oracle Real Application Clusters Oracle RAC planned outages. This is because a file adapter is a non-XA compliant adapter. Therefore, when it participates in a global transaction, it may not follow the XA interface specification of processing each file only once. 19-50 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite

10. In the Directory for Incoming Files physical path field, enter the directory from

which you want to read the files. For example, enter C:\Customer\In.

11. Click Next.

The File Filtering page is displayed.

12. In the Include Files with Name Pattern field, enter .xml, and then click Next.

The File Polling page is displayed.

13. Change the Polling Frequency field value to 10 seconds, and then click Next.

The Messages page is displayed.

14. To the right of the URL field, click Search.

The Type Chooser dialog is displayed.

15. Click Import Schema File.

The Import Schema File dialog is displayed.

16. To the right of the URL field, click Search and select the LegacyCustomer.xsd file

present in the Samples folder. 17. Click OK. 18. Expand the navigation tree to Type Explorer\Imported Schemas\LegacyCustomer.xsd and select CustomerData, as shown in Figure 19–38 . Figure 19–38 Type Chooser - CustomerData

19. Click OK.

The Adapter Configuration wizard appears, as shown in Figure 19–39 .