Oracle 11g SOA Suite – The Event Delivery Network – Publishing Business Events

Lucas Jellema 2
0 0
Read Time:3 Minute, 59 Second

In a previous post – Oracle 11g SOA Suite – Straightforward Mediator example (employees from file to database) – I demonstrated how we can quickly implemented a Service Composite that reads files with Employee data and turns them into new HR database records (well, simply creates records in the SCOTT.EMP table). In this article, we will start with that Composite and have it Publish Business Events. The Business Event of course is the arrival of a new employee. This composite that reads the initial ‘ new employee document’ is the first outpost in the enterprise to witness the event. And as such has the ability and responsibility to make that fact known to every interested party in the organization, without even knowing what the interested parties are. That is what the EDN is for and what Business Events help do: in a very loosely coupled way can one process inform others.

The ReadNewEmployees Mediator Component will be extended in this article to do one additional thing: it will publish an event whenever it reads a new employee file. The event is handed over to the EDN and is no longer the responsibility of the Mediator component. Whether anyone consumes the event – it does not know or care. Note: previously we could achieve something very similar using JMS Topics that ESB Services of BPEL Processes published to and other ESB Services or BPEL processes could be started from.....

1. Before we create the event definition, let’s first define the element that we base the event payload on.

In JDeveloper, create a new XSD document

Specify the name for the XSD document

 

Specify the Element – in this case NewEmployee – with its Child Elements and their types:

 

2. Now return to the Composite diagram. In the upper left hand corner, you will find an icon to click on for creating a new Event Definition File:

 

Enter a name for the event definition file – in which multiple event types can be created:

After pressing Finish, the event editor is opened.

 

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

Close the Add an Event dialog.

 

Add this point, the Business Event has been defined. No one produces it. No one consumes it. It sits in the middle – waiting for publishers and subscribers to start taking advantage of it.

Let’s introduce a Publisher of this event. The ReadNewEmployee Mediator Component discussed in the article referred to above is a likely candidate: by picking up a file with new employee details, it registers the fact of a new employee and can turn that fact into an event published for the benefit of others.

 

4. From the RMB menu on the Mediator Component, select the option Add Published Events

 

The Event Chooser dialog opens. This dialog allows us to choose the event type for which the component will be publishing events. Well, we only have the one event type to choose from – so select the NewEmployee event:

and press OK.

The Composite diagram shows with the little lightning icon that the Mediator Component publishes an (at least one type of) event. It also shows in the little Published Box which type of event it is: NewEmployee. 

 

5.  We now have to make sure that when that event is published, it has a proper payload. Double click on the Mediator component to edit the Routing Rule to the Business Event:

Click on the Mapping icon to create the mapping between the Employee data read from the File (passed in by the File Adapter Service) and the Business Event  payload (the NewEmployee element).

As the payload of the NewEmployee business event is seen as an AnyType, we cannot use the graphical mapper. Instead, we need to do some dirty XSL-T work ourselves.

In this case, the following piece of XSLT will do the job:

This template builds up the newEmployee element with child elements as specified in the XSD definition. It uses the xsl:value-of instructions to copy values from the children of the Employee element produced by the File Adapter Service to the newEmployee element.

With this mapping complete, we can redeploy the SCA Composite to the SOA runtime environment (the Integrated OC4J Server in this case).

When deployment is complete, every new employee whose file is read will also trigger a Business Event. At this point, sadly enough, there are no listeners to the event. But that is really part of the beauty of the decoupled approach of the Event Driven Architecture.

This look at the audit trail for an instance of the ReadNewEmployee composite demonstrates that the NewEmployee Event was published.

 

About Post Author

Lucas Jellema

Lucas Jellema, active in IT (and with Oracle) since 1994. Oracle ACE Director and Oracle Developer Champion. Solution architect and developer on diverse areas including SQL, JavaScript, Kubernetes & Docker, Machine Learning, Java, SOA and microservices, events in various shapes and forms and many other things. Author of the Oracle Press book Oracle SOA Suite 12c Handbook. Frequent presenter on user groups and community events and conferences such as JavaOne, Oracle Code, CodeOne, NLJUG JFall and Oracle OpenWorld.
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

2 thoughts on “Oracle 11g SOA Suite – The Event Delivery Network – Publishing Business Events

  1. Hi Lucas,
    Just one question, We are trying to capture error when EDN is down at the time of publishing the Event.
    How can we capture that error.
    Manish

  2. Lucas,
    Your note “Note: previously we could achieve something very similar using JMS Topics that ESB Services of BPEL Processes published to and other ESB Services or BPEL processes could be started from.”
    Does this mean that if the subscriber is down that the event it is interested in will be lost to it just like a JMS Topic subscriber?
     
    Brett

Comments are closed.

Next Post

Using SoapUI on Apache ODE to test your BPEL processes more quickly

On the SOA-training I’m following we’re using the Oracle SOA Suite, a very nice product, but the time needed between saving changes and deploying the process takes way too long. I also want to know exactly what’s happening and have control over the external web services. In this blog I […]
%d bloggers like this: