Oracle Event Delivery Network, produce events from within plsql

With the release of the soa suite 11g Oracle supplies us the EDN component, Event Delivery Network.
Basically it supplies us a publish/subscribe model to trigger and subscribe on defined business events.

For this little demo a created the next event definition

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://schemas.oracle.com/events/edl" targetNamespace="http://schemas.oracle.com/events/edl/TestEvent">
    <schema-import namespace="http://nl.xenta/events" location="xsd/TestEvent.xsd"/>
    <event-definition name="EventElement">
        <content xmlns:ns0="http://nl.xenta/events" element="ns0:TestEvent"/>
    </event-definition>
</definitions>

To ‘throw’ the events we can make use of both the java and plsql apis.
For this demo i will shorty show how to trigger them from bpel/the console and a plsql call.

The composite i created

The bpel interface will be used just for triggered the event.

In the bpel itself we will use the invoke activity to not invoke a partnerlink but to invoke/trigger the event.

The Mediator component will subscribe to the event and will just write it back to filesystem.

Or we can just use the Enterprise Manager console to trigger the events.
In the console go to the soa-infra application, rightmouseclick and go to ‘Business Events’.

Select the ‘Test Event’, click ‘Test’ and use for example the next payload

	<TestEvent xmlns="http://nl.xenta/events"> 
	   <action>action from console</action> 
	   <description>description from console</description> 
	</TestEvent>

Trigger from plsql

To be able to trigger the events from within plsql we just have to call a ready to use procedure from the soa_infra schema (DEV_SOAINFRA in my case).
Procedure to be called :

procedure edn_publish_event (
  namespace  in varchar2, 
  local_name in varchar2, 
  payload    in clob, 
  priority   in binary_integer default 5)

The procedure is a wrapper for the next call

  edn_internal_publish_event (namespace, local_name, payloadCopy, 'S', NULL, subject_info, priority); 

Which eventually will call

edn_enqueue_business_event (edn_business_event(namespace, local_name, 
      sys.xmltype.createXML(payload), NULL, NULL), source, subject_info, target, priority);

Create a stored procedure :

create or replace
procedure call_edn_test
 as
 begin
  edn_publish_event(
'http://schemas.oracle.com/events/edl/TestEvent',
'EventElement',
'<business-event xmlns:ns1="http://schemas.oracle.com/events/edl/TestEvent" xmlns="http://oracle.com/fabric/businessEvent">
   <name>ns1:EventElement</name>
   <id>d4cbd406-9c56-4f50-a8e5-2b59a0f02c87</id>
   <content>
	<TestEvent xmlns="http://nl.xenta/events">
	   <action>action from plsql</action>
	   <description>description from plsql</description>
	</TestEvent>
   </content>
</business-event>', '1');
end;

After triggering the event from the console, bpel and plsql we will have 3 files in the output directory

<?xml version="1.0" encoding="UTF-8" ?><ns0:TestEvent xmlns:ns0="http://nl.xenta/events" xmlns="http://nl.xenta/events">
   <ns0:action>action from plsql</ns0:action>
   <ns0:description>description from plsql</ns0:description>
</ns0:TestEvent>

<?xml version="1.0" encoding="UTF-8" ?><ns0:TestEvent xmlns:ns0="http://nl.xenta/events" xmlns="http://nl.xenta/events">
   <ns0:action>action from console</ns0:action>
   <ns0:description>description from console</ns0:description>
</ns0:TestEvent>

<?xml version="1.0" encoding="UTF-8" ?><ns0:TestEvent xmlns:ns0="http://nl.xenta/events" xmlns="http://nl.xenta/events">
   <ns0:action>action from bpel</ns0:action>
   <ns0:description>description from bpel</ns0:description>
</ns0:TestEvent>

Conclusion

To implement decoupling in the middleware, events are an important concept to be use. Event Driven Architectures are based on them and in the Oracle SOA Suite Oracles supplies us the EDN (Event Driven Network) to help us implement such an architecture. To eventually be able to produce events from within the database and consume the events from the Middleware we could have used Oracle AQ and one of the JCA Adapters Oracle supplies us. To process events from the database and consume those in the Middleware by use of the EDN functionality we can now just make use of a simple database procedure call. The EDN will just process the event like every other event produced in the Middleware.

Download : EventToFile.zip (Jdeveloper project)

Share this Post:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

4 Responses to “Oracle Event Delivery Network, produce events from within plsql”

[…] SOA Suite we can create events by use of the Event Driven Network (EDN). See my one of my last articles on how to produce such an event from with plsql or how to produce it from bpel. The next step in […]

commenter

This strategy requires a call to a stored procedure on the soa_infra schema. Not really feasible in the typical use case when capturing changes to tables in legacy databases. DBlink required!

commenter

Thanks a lot for the article.. its truly helpful for beginners..

I am also a beginner, and i understand the concept but still i did not get how to trigger the event by plsql call from console.. if you could provide steps for the same will be very helpful.

thanks for the article again.

Kranthi

commenter

Which console do you mean?
Eventually if you use a publish event in your composite (so this is a trigger moment) it will get handled by the plsql in the database.
What trigger moment do you mean by “console” ?

Leave a Reply:

Name (required):
Mail (will not be published) (required):
Website:
Comment (required):
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>