med rr tutorial

20
1 Oracle Mediator Routing Rule Use Cases The following two tutorials give you step-by-step instructions for creating two of the Mediator sample projects provided on the Oracle SOA Suite samples page. They illustrate how to define routing rules for the Mediator components you create. This document includes the following scenarios: Creating a Mediator for Routing Messages Creating an Asynchronous Request and Response Using Mediator 1.1 Creating a Mediator for Routing Messages The CustomerRouter use case provides an overview of how to use a Mediator in a SOA composite sample application to route messages. The files are provided in the Basic Routing Sample for 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 Mediator. 3. The CustomerRouter 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 Mediator then transforms the message to the structure required by the adapter reference. 5. The external reference delivers the message to its associated external application. Figure 1–1 provides an overview of the CustomerRouter use case.

Upload: sivakrishna

Post on 18-Apr-2015

12 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Med Rr Tutorial

1Oracle Mediator Routing Rule Use Cases

The following two tutorials give you step-by-step instructions for creating two of the Mediator sample projects provided on the Oracle SOA Suite samples page. They illustrate how to define routing rules for the Mediator components you create.

This document includes the following scenarios:

n Creating a Mediator for Routing Messages

n Creating an Asynchronous Request and Response Using Mediator

1.1 Creating a Mediator for Routing MessagesThe CustomerRouter use case provides an overview of how to use a Mediator in a SOA composite sample application to route messages.

The files are provided in the Basic Routing Sample for 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 Mediator.

3. The CustomerRouter 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 Mediator then transforms the message to the structure required by the adapter reference.

5. The external reference delivers the message to its associated external application.

Figure 1–1 provides an overview of the CustomerRouter use case.

Page 2: Med Rr Tutorial

Creating a Mediator for Routing Messages

Oracle Mediator Routing Rule Use Cases

Figure 1–1 Overview of CustomerRouter Use Case

1.1.1 How to Create the CustomerRouter Use Case

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

Task 1 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.

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.

Page 3: Med Rr Tutorial

Creating a Mediator for Routing Messages

Oracle Mediator Routing Rule Use Cases

Task 2 Create the CustomerRouter 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 Mediator with name CustomerRouter is created.

Task 3 Create a File Adapter Service

You must create a file adapter service named ReadCust to read the XML files from a directory.

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.

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.

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

Page 4: Med Rr Tutorial

Creating a Mediator for Routing Messages

Oracle Mediator Routing Rule Use Cases

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

Figure 1–2 Type Chooser - CustomerData

19. Click OK.

The Adapter Configuration wizard appears, as shown in Figure 1–3.

Page 5: Med Rr Tutorial

Creating a Mediator for Routing Messages

Oracle Mediator Routing Rule Use Cases

Figure 1–3 Adapter Configuration Wizard – Messages page

20. Click Next.

The Finish page is displayed.

21. Click Finish.

22. From the File menu, select Save All.

Task 4 Create a File Adapter Reference

1. From the Component Palette, select SOA.

2. Select File Adapter and drag it to the External References 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 USCustomer.

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. Click Next.

The Operation page is displayed.

8. In the Operation Type field, select Write File.

9. In the Operation Name field, enter WriteFile.

10. Click Next.

Page 6: Med Rr Tutorial

Creating a Mediator for Routing Messages

Oracle Mediator Routing Rule Use Cases

The File Configuration page is displayed.

11. In the Directory for Outgoing Files (physical path) field, enter the name of the directory in which you want to write the files.

For example, C:\Customer\out.

12. In the File Naming Convention field, enter customer_%SEQ%.xml and click Next.

The Messages page is displayed.

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

The Type Chooser dialog is displayed.

14. Click Import Schema File.

The Import Schema File dialog is displayed.

15. To the right of the URL field, click Search and select the USCustomer.xsd file present in the Samples folder.

16. Click OK.

17. Expand the navigation tree to Type Explorer\Imported Schemas\USCustomer.xsd, and then select Customer.

18. Click OK.

19. Click Next.

The Finish page is displayed.

20. Click Finish.

21. From the File menu, click Save All.

22. Create another file adapter reference named CanadaCustomer in a similar way by using the CanCustomer.xsd file.

Figure 1–4 shows how the SOA Composite Editor appears after performing this task.

Page 7: Med Rr Tutorial

Creating a Mediator for Routing Messages

Oracle Mediator Routing Rule Use Cases

Figure 1–4 Mediator Service Component with Adapter Services and References

Task 5 Specify Routing Rules

You must specify the path that messages take from the ReadCust adapter service to external references.

1. Connect the ReadCust service to the CustomerRouter Mediator, as shown in Figure 1–5.

This specifies the file adapter service to invoke the CustomerRouter Mediator while reading a file from the input directory.

Page 8: Med Rr Tutorial

Creating a Mediator for Routing Messages

Oracle Mediator Routing Rule Use Cases

Figure 1–5 Connecting the ReadCust Service to the CustomerRouter Mediator

2. Double-click the CustomerRouter Mediator in the Mediator Editor.

3. In the Routing Rules section, click Add to the extreme right side of ReadFile, and then click static routing rule.

The Target Type dialog is displayed.

4. Click Service.

The Target Services dialog is displayed.

5. Navigate to CustomerRouterProject > References > USCustomer and select WriteFile, as shown in Figure 1–6.

Figure 1–6 Target Services Dialog

6. Click OK.

The Routing Rules section is displayed.

7. Next to the <<Filter Expression>> field, click the filter icon to create a filter expression for this routing rule.

The Expression Builder dialog is displayed.

Page 9: Med Rr Tutorial

Creating a Mediator for Routing Messages

Oracle Mediator Routing Rule Use Cases

8. In the Variables field, navigate to Variables> in > body > imp1:CustomerData, and then select Country.

9. Double-click Country.

The Country node is added in the Expression field, as shown in Figure 1–7.

Figure 1–7 Expression Builder Dialog

10. Modify the expression as follows:

$in.CustomerData/imp1:CustomerData/Country=’US’

11. Click OK.

The <<Filter Expression>> field of the Routing Rules section is populated with the expression.

12. To the right of the Transform Using field, click the icon.

The Request Transformation Map dialog is displayed, as shown in Figure 1–8.

Figure 1–8 Request Transformation Map

Page 10: Med Rr Tutorial

Creating a Mediator for Routing Messages

Oracle Mediator Routing Rule Use Cases

13. Select Create New Mapper File and click OK.

A CustomerData_To_Customer.xsl file is added, as shown in Figure 1–9.

Figure 1–9 CustomerData_To_Customer.xsl File – Initially

14. Drag and drop the imp1:CustomerData source element to the imp1:Customer target element.

The Auto Map Preferences dialog is displayed.

15. From the During Auto Map options, deselect Match Elements Considering their Ancestor Names.

The Auto Map Preferences dialog is shown in Figure 1–10.

Figure 1–10 Auto Map Preferences Dialog

Page 11: Med Rr Tutorial

Creating a Mediator for Routing Messages

Oracle Mediator Routing Rule Use Cases

16. Click OK.

The CustomerData_To_Customer.xsl file appears, as shown in Figure 1–11.

Figure 1–11 CustomerData_To_Customer.xsl Tab – Auto Mapped Connections

17. From the File menu, select Save All.

18. Repeat the procedures mentioned in Step 3 through Step 17 to create a CanadaCustomer reference as the target service. In the Expression Builder dialog, specify the following expression:

$in.CustomerData/imp1:CustomerData/Country=’CA’

After performing all the steps described in this section, the SOA Composite Editor appears, as shown in Figure 1–1.

Task 6 Create an Application Server Connection

An application server connection is required for deploying your SOA composite application.

Task 7 Deploy the CustomerRouterProject

Deploying the CustomerRouterProject composite application to an application server consists of following steps:

n Creating an application deployment profile

n Deploying the application deployment profile to an application server

Note: For repeating the steps, you must re-enter the Mediator Editor by closing it or by clicking the CustomerRouter.mplan tab above the editor.

Page 12: Med Rr Tutorial

Creating an Asynchronous Request and Response Using Mediator

Oracle Mediator Routing Rule Use Cases

Task 8 Run and Monitor the CustomerRouterProject Application

After deploying the CustomerRouterProject application, you can run it by copying the input XML files to the input folder. The payload files are written to the specified output directories.

For monitoring the running instance, you can use Oracle Enterprise Manager Fusion Middleware Control at the following URL:

http://hostname:port_number/em

where hostname is the host on which you installed the Oracle SOA Suite infrastructure and port_number is the port of the server on which Oracle Enterprise Manager Fusion Middleware Control is installed.

1.2 Creating an Asynchronous Request and Response Using MediatorThis sample demonstrates an asynchronous request response scenario using Mediator. This composite has a client BPEL process invoking a Mediator, which invokes a server BPEL process. All the invocations are done as an asynchronous request response.

Figure 1–12 provides an overview of the AsyncMediator use case.

Figure 1–12 Overview of AsyncMediator Use Case

1.2.1 How to Create the AsyncMediator Use Case

This section provides the design-time tasks for creating, building, and deploying the use case. These tasks should be performed in the order in which they are presented.

Task 1 Create an Oracle JDeveloper Application and Project

1. In Oracle JDeveloper, click File and select New.

The New Gallery dialog appears.

Page 13: Med Rr Tutorial

Creating an Asynchronous Request and Response Using Mediator

Oracle Mediator Routing Rule Use Cases

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 AsyncMediator and then click Next.

The Name your project page appears.

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

The Configure SOA settings page appears.

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

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, click Save All.

Task 2 Create a Server BPEL Process

1. In the Application Navigator, double-click composite.xml. The SOA Composite Editor is displayed.

2. From the Component Palette, select SOA.

3. Drag and drop a BPEL Process into the Components section.

The Create BPEL Process dialog is displayed.

4. In the Name field, enter ServerBPELProcess.

5. From the Template list, select Asynchronous BPEL Process.

6. Deselect Expose as a SOAP service and click OK. The ServerBPELProcess is created in the SOA Composite Editor.

Task 3 Create a Mediator Service Component

1. From the Component Palette, select SOA.

2. Drag and drop a Mediator into the Components section.

The Create Mediator dialog is displayed.

3. In the Name field, enter Mediator.

4. From the Template list, select Asynchronous Interface.

5. Deselect Create Composite Service with SOAP Bindings.

6. Click OK.

A Mediator with name Mediator is created, as shown in Figure 1–13.

Page 14: Med Rr Tutorial

Creating an Asynchronous Request and Response Using Mediator

Oracle Mediator Routing Rule Use Cases

Figure 1–13 Mediator and ServerBPELProcess in the Composite Window

7. Double-click the Mediator Mediator.

The Mediator Editor is displayed.

8. In the Routing Rules section, click Add to the far right side of execute and then select static routing rule.

The Target Type dialog is displayed.

9. Select Service.

The Target Services dialog is displayed.

10. Navigate to AsyncMediatorSample > BPEL Processes > ServerBPELProcess > Services > serverbpelprocess_client > process, as shown in Figure 1–14.

Figure 1–14 Target Services Dialog

11. Click OK.

Page 15: Med Rr Tutorial

Creating an Asynchronous Request and Response Using Mediator

Oracle Mediator Routing Rule Use Cases

12. Below the <<Filter Expression>> field, click the icon to the right of the Transform Using field.

The Request Transformation Map dialog is displayed.

13. Select Create New Mapper File and click OK.

The XSLT Mapper is displayed and a target file named singleString_To_process.xsl is added.

14. Drag and drop the cb1:input source element to the client:input target element.

The Auto Map Preferences dialog is displayed.

15. From the During Auto Map options, deselect Match Elements Considering their Ancestor Names and click OK.

The XSLT Mapper displays, as shown in Figure 1–15.

Figure 1–15 singleString_To_process.xsl Window

16. In the Routing Rules section, under Callback, click the icon to the right of the Transform Using field.

The Request Transformation Map dialog is displayed.

17. Select Create New Mapper File and click OK.

The XSLT Mapper is displayed and a target file named processResponse_To_singleString.xsl is added.

18. Drag and drop the client:processResponse source element to the cb1:singleString target element.

The Auto Map Preferences dialog is displayed.

19. From the During Auto Map options, deselect Match Elements Considering their Ancestor Names and click OK.

Task 4 Create a Client BPEL Process

1. In the Application Navigator, double-click composite.xml. The SOA Composite Editor is displayed.

Page 16: Med Rr Tutorial

Creating an Asynchronous Request and Response Using Mediator

Oracle Mediator Routing Rule Use Cases

2. From the Component Palette, select SOA.

3. Drag and drop a BPEL Process to the Components section.

The Create BPEL Process dialog is displayed.

4. In the Name field, enter ClientBPELProcess.

5. From the Template list, select Asynchronous BPEL Process.

6. Click OK.

ClientBPELProcess is created in the SOA Composite Editor.

7. Drag and drop the ClientBPELProcess BPEL process to the Mediator Mediator. The SOA Composite Editor appears, as shown in Figure 1–12.

Task 5 Create the Invoke Activity

1. Double-click ClientBPELProcess. The Oracle BPEL Designer is displayed.

2. Drag and drop an Invoke activity from the Component Palette to the design area.

3. Double-click the Invoke activity. The Invoke dialog is displayed.

4. In the Name field, enter InvokeMediator.

5. Next to the Partner Link field, click Browse Partner Links. The Partner Link Chooser dialog is displayed.

6. Select Operation - execute, and click OK.

7. To the right of the Variable field in the Invoke dialog, click the Auto-Create Variable icon. The Create Variable dialog is displayed.

8. In the Variable field, enter InvokeMediator_execute_InputVariable_1 and click OK. The Invoke dialog is displayed.

9. Click OK. The Oracle BPEL Designer appears.

Task 6 Create the Receive Activity

1. Drag and drop a Receive activity from the Component Palette to the design area.

2. Double-click the Receive activity. The Receive dialog is displayed.

3. In the Name field, enter ReceiveFromMediator.

4. Next to the Partner Link field, click Browse Partner Links. The Partner Link Chooser dialog is displayed.

5. Select Operation - callback, and click OK.

6. To the right of the Variable field in the Receive dialog, click the Auto-Create Variable icon. The Create Variable dialog is displayed.

7. Select the default variable name and click OK. The Variable field is populated with the default variable name.

8. Check Create Instance, and click OK. The Oracle BPEL Designer appears.

Task 7 Create the Assign Activity

1. Drag and drop an Assign activity from the Component Palette between the ReceiveFromMediator and InvokeMediator activities in the design area.

2. Double-click the Assign activity. The Assign dialog is displayed.

3. In the Name field, enter AssignRequest.

Page 17: Med Rr Tutorial

Creating an Asynchronous Request and Response Using Mediator

Oracle Mediator Routing Rule Use Cases

4. Click the Copy Operation tab. The Assign dialog is displayed.

5. Select Copy Operation. The Create Copy Operation dialog is displayed.

6. Create the copy operation between the triggers file name and the file variable, as shown in Figure 1–16.

Figure 1–16 The Create Copy Operation Dialog

7. Click OK in the Create Copy Operation dialog.

8. Click OK to return to the Oracle BPEL Designer, as shown in Figure 1–17.

Page 18: Med Rr Tutorial

Creating an Asynchronous Request and Response Using Mediator

Oracle Mediator Routing Rule Use Cases

Figure 1–17 The Oracle JDeveloper - ClientBPELProcess.bpel

9. From the File menu, select Save All.

Task 8 Create the Assign Activity in the ServerBPELProcess

1. Double-click the ServerBPELProcess BPEL process. The Oracle BPEL Designer is displayed.

2. Drag and drop an Assign activity from the Component Palette between the receiveInput and callbackClient activities in the design area.

3. Double-click the Assign activity. The Assign dialog is displayed.

4. Click the Copy Operation tab.

5. Select Copy Operation. The Create Copy Operation dialog is displayed.

6. Create the copy operation between the triggers file name and the file variable, as shown in Figure 1–18.

Page 19: Med Rr Tutorial

Creating an Asynchronous Request and Response Using Mediator

Oracle Mediator Routing Rule Use Cases

Figure 1–18 The Create Copy Operation Dialog

7. Click OK in the Create Copy Operation dialog.

8. Click OK to return to the Oracle BPEL Designer, as shown in Figure 1–19.

Figure 1–19 The Oracle JDeveloper - ServerBPELProcess.bpel

9. From the File menu, select Save All.

Page 20: Med Rr Tutorial

Creating an Asynchronous Request and Response Using Mediator

Oracle Mediator Routing Rule Use Cases

Task 9 Configure an Application Server Connection

An application server connection is required for deploying your SOA composite application.

Task 10 Deploy the SOA Composite Application

Deploying the EventMediatorApp composite application to Oracle WebLogic Server consists of following steps:

n Creating an application deployment profile

n Deploying the application to an application server