You are on page 1of 27

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)

Abstract The objective is to implement an Oracle Service Composite to read and insert new events from a File into database using the mediator service in Oracle SOA Suite 11g. Table of contents 1. 2. 3. 4. 5. 6. Introduction Related Work Prerequisites Process Description Conclusion References

1) Introduction

Today Oracle SOA Suite 11g offers new Service Component Architecture (SCA) and Service Data Objects (SDO) which are new standards simplifying service-oriented architecture (SOA) and are also the key enabler of the service platform. SCA gives developers and architects the ability to represent business logic as reusable components that can be easily integrated into any SCA-compliant application or solution. The resulting application is known as a composite application. SDO specify a standard way to access data and can be used to modify business data regardless of how it is physically accessed. Developers and architects do not need to know the technical details of how to access a particular back-end data source in order to use SDO in their composite applications. Consequently, they can use static or dynamic programming styles and obtain connected as well as disconnected access. SOA composite is a standards-based deployment unit that leverages the SCA assembly model and can mix variety of components like ESB routing (Mediator), BPEL, Human Workflow, etc. This Technology Preview release (TP4) of Oracle SOA Suite 11g showcases the support for the Service Component Architecture (SCA) standard in Oracle SOA Suite through the new composite assembly editor in JDeveloper as well as a unified service engine foundation for the full set of SOA Suite components.

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 1 of 27

2) Related Work

The most important service from SOA Suite 11g is the Event Delivery Network (EDN) that uses Event Definition Language (EDL), which is fully declarative and can build decoupled applications. One of things I wanted to look into was the Event Delivery Network (EDN) that allows an Event Driven Architecture (EDA) to loosely couple different processes. The events that occur in one process can be published asynchronously and can be consumed at another end on the EDN. The consumed end will typically be Mediator services. In this article I will implement a File Adapter service to get information for Employee details using a file, the data from this file is transformed and routed by Database Adapter to insert the values directly into the database using Oracle JDeveloper 11g as this new IDE supports EDN. Here the new Employees are considered as new events that we are going to publish. 3) Prerequisites This guide assumes that:

You have installed Oracle JDeveloper 11g TP4 and get enabled for Oracle SOA Suite 11g.
You have access to Oracle Database.

4) Process Description

Lets look at the implementation steps below: Start JDeveloper 11g TP4 (check before Configuring SOA under tools tab and start Integration Server)

Create a new application EventMediatorService.


Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 2 of 27

Create empty project as ReceiveEvents

Select SOA Composite from, SOA Tier categories

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 3 of 27

In create SOA Composite select Composite with Mediator.

Name the Mediator Component as ReadNewEvent.

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 4 of 27

Drag a File Adapter Service into Exposed Services pallet.

As service name enter ReadNewEventFile


Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved. Page 5 of 27

Select Define from operation and schema (specified later) radio button.

Select Read File operation. Give Operation name as ReadNewEventFile.

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 6 of 27

Click Next and give directory where the files will appear and read from. Also give the archive directory where files are stored after been processed. Click

Press Next again. Specify the file filtering details.


Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved. Page 7 of 27

Press Next again. Specify the polling frequency in seconds. Press Next. On this page we can specify the Schema (XSD) for the file we will read, or we can use the Native Format wizard for creating an XSD that we can use as representation for the file that will be read.

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 8 of 27

Select the "Define Schema for Native Format button.

Give emp.txt as an example that contains single record in CVS format.

Choose the File contains only one record option and click next.

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 9 of 27

Name the element as Employee in the enter element name field.

Indicate the type of delimiter. Press Next.

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 10 of 27

Enter the names for the columns that can be used as the names for the child elements in the Schema that will be created.

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 11 of 27

Press Next. Set the name of the XSD file that gets created. We can Test the Schema by pressing the Test button.

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 12 of 27

We can select a file with the expected input format and press the Play (Run) button. The XML document that results from the read operation using our configuration details is presented on the right side. Press OK to return to the File Adapter Wizard.

Press next and press Finish. The File Adapter Service is shown in Exposed Services swim lane for our (SCA) composite.

Next we configure the Database Adapter for inserting records into the Employee table
Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 13 of 27

Drag the Database Adapter and drop in the External References swim lane.

Specify a Name under Service Name.

Select a Database Name under connection.

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 14 of 27

If database not specified create a new Connection and select it.

Specify the Operation: Insert only from perform an Operation on a table option.

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 15 of 27

Add and select the EMP table as the object for different operation.

Specify which of the Table Attributes (columns) will be included in the insert operation as shown above.
Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved. Page 16 of 27

Press Next and press Finish. Now the composite looks like this:

Create a wire from ReadNewEventsFile to the ReadNewEvent Mediator component. And next to InsertNewEmployee as shown above.

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 17 of 27

Create the Routing Rule and Transformation mapping in the Mediator Component. Double click the ReadNewEvent component. Expand the Routing Rule as shown which connects the File Adapter Service input via the Mediator to the Database Adapter Service Reference. Click on the Transformation Map icon.

Create New Mapper File. Give some name for the XSL file. Then press OK. The XSL Mapper window opens.

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 18 of 27

Connect the input elements to the appropriate output elements as shown in the picture. Now we can deploy our SCA Composite to the Bundled OC4J server - and then see it in action. Copy a file with new employee details to the configured directory (c:\temp\hr).

Click on the ReadNewEvent from components to see the new events and click on each instance to see their details. Next we perform to create XML Schemas to map the existing records in the file to database records and invoke the business events.

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 19 of 27

Lets first define the element that we base the event payload on. In JDeveloper, create a new XSD document

Name the XSD document as NewEvent.xsd

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 20 of 27

Develop the elements as shown below as newEvent - with its Child Elements and their types:

Now return to the Composite diagram. In the upper left hand corner, click on for creating a new Event Definition File:

Enter a name for Event Definition from which multiple event types can be created and click Finish.

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 21 of 27

Click on the Add Event icon. Next enter the name for the event type and find the Element from an XSD document to base the event on.

Go to NewEmployeeEvent.eld to view the newly created event.

Right click the ReadNewEvent Mediator Component and select Add publish Events.

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 22 of 27

Create a Transformation using Transform Map icon

under NewEmployee event as shown below

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 23 of 27

Click mapping icon to create the mapping between the Employee data read from the File and the Business Event payload (NewEmployee element).

write a custom XSLT by switching the perspective to sorce view and add the following code for mapping.

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 24 of 27

Deploy the project on to BundleOC4JServer

The Input Payload from the server is shown below

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 25 of 27

Conclusion

This custom XSL code creates newEmployee with sub-elements as given in the XSD definition. It uses the xsl:valueof elements to copy values from Employee element produced by the File Adapter Service to the newEmployee element. Now we can redeploy into the Integrated OC4J Server that is oc4jbundle server in this case. After deployment every new employee file is automatically triggered for every new event. This publishes the new employee events on to the server at consumer end.

References

Oracle JDeveloper 11g - Technology Preview http://www.oracle.com/technology/products/jdev/11 Design an SOA Composite Application http://www.oracle.com/technology/products/jdev/11/cuecards/soa_set_72/ccset72_ALL.html Oracle JDeveloper 11g Technology Preview 4 tutorials
http://www.oracle.com/technology/products/jdev/11/cuecards/index.html

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 26 of 27

About the authors:


Ramesh Nambala Email: rnambala@miraclesoft.com / 1-248-233-1816

Ramesh Nambala is an Integration Specialist & Fusion Developer at Miracle Software Systems, Inc. His primary focus has been on the SOA Integration space using Oracle Fusion Middleware Technologies. He has several years of experience helping various customers across Telecom, Manufacturing, and Retail banking domains using Oracle Business Integration Tools.

Sharma Raj Marella Email: smarella@miraclesoft.com / 1-248-233-1816

Sharma Raj Marella is a specialist in and passionate exponent of standards based Service Oriented Architecture and in particular Oracle BPEL & ESB. He has several years of experience in troubleshooting and managing critical j2ee/soa projects within Miracle Software Systems Inc. supporting POCs & takes care the overall cross-product integration.

Copyright 2008 Miracle Software System, Inc. Miracle acknowledges the proprietary rights of the trademarks and product name of the other companies mentioned in this paper. The information provided in this document is intended for the sole use of the recipient and for educational purposes only. Miracles make no express of implied warranties relating to the information contained in this document or to any derived results obtained by the recipient from the use of the information in the document. Miracle further does not guarantee the sequence, timeliness, accuracy or completeness of the Information and will not be liable in any way to the recipient for any delays, inaccuracies, errors in, or omissions of, any of the information of in the transmission thereof, of for any damages arising there from. Opinions and forecasts constitute our judgment at the time of release and are subject to change without notice. This document does not contain information provided to us in confidence by our clients.

Oracle Adapter for Event Mediation Service (Oracle SOA Suite 11g)
Copyright 1994 - 2008 Miracle Software Systems, Inc. All rights reserved.

Page 27 of 27

You might also like