Friday Dec 10, 2010

Monitoring Events in your BPEL Runtime - RSS Feeds?

@10g -

It had been a while since I'd tried something different. so here's what I did this week!
Whenever our Developers deployed processes to the BPEL runtime, or perhaps when a process gets turned off due to connectivity issues, or maybe someone retired a process, I needed to know.
So here's what I did.

Step 1: Downloaded Quartz libraries and went through the documentation to understand what it takes to schedule a recurring job.

Step 2: Cranked out two components using Oracle JDeveloper. [Within a new Web Project]

a) A simple Java Class named FeedUpdater that extends org.quartz.Job. All this class does is to connect to your BPEL Runtime [via opmn:ormi] and fetch all events that occured in the last "n" minutes.
events? - If it doesn't ring a bell - its right there on the BPEL Console. If you click on "Administration > Process Log" - what you see are events.
The API to retrieve the events is

//get the locator reference for the domain you are interested in.
Locator l = ....

//Predicate to retrieve events for last "n" minutes
WhereCondition wc = new WhereCondition(...)

//get all those events you needed.
BPELProcessEvent[] events = l.listProcessEvents(wc);

After you get all these events, write out these into an RSS Feed XML structure and stream it into a file that resides either in your Apache htdocs, or wherever it can be accessed via HTTP.
You can read all about RSS 2.0 here. At a high level, here is how it looks like.

<?xml version = '1.0' encoding = 'UTF-8'?>
<rss version="2.0">
  <channel>
    <title>Live Updates from the Development Environment</title>
    <link>http://soadev.myserver.com/feeds/</link>
    <description>Live Updates from the Development Environment</description>
    <lastBuildDate>Fri, 19 Nov 2010 01:03:00 PST</lastBuildDate>
    <language>en-us</language>
    <ttl>1</ttl>
    <item>
      <guid>1290213724692</guid>
      <title>Process compiled</title>
      <link>http://soadev.myserver.com/BPELConsole/mdm_product/administration.jsp?mode=processLog&amp;processName=&amp;dn=all&amp;eventType=all&amp;eventDate=600&amp;Filter=++Filter++</link>
      <pubDate>Fri Nov 19 00:00:37 PST 2010</pubDate>
      <description>SendPurchaseOrderRequestService: 3.0 Time : Fri Nov 19 00:00:37
                   PST 2010</description>
    </item>

  ......

</channel>

</rss>

For writing ut XML content, read through Oracle XML Parser APIs - [search around for oracle.xml.parser.v2]

b) Now that my "Job" was done, my job was half done. Next, I wrote up a simple Scheduler Servlet that schedules the above "Job" class to be executed ever "n" minutes. It is very straight forward.

Here is the primary section of the code.

        try {
        Scheduler sched = StdSchedulerFactory.getDefaultScheduler();

        //get n and make a trigger that executes every "n" seconds
        Trigger trigger = TriggerUtils.makeSecondlyTrigger(n);
        trigger.setName("feedTrigger" + System.currentTimeMillis());
        trigger.setGroup("feedGroup");       
        JobDetail job = new JobDetail("SOA_Feed" + System.currentTimeMillis(), "feedGroup", FeedUpdater.class);
        sched.scheduleJob(job,trigger);

        }catch(Exception ex) {
            ex.printStackTrace();
            throw new ServletException(ex.getMessage());
        }

Look up the Quartz API and documentation. It will make this look much simpler.

Now that both components were ready, I packaged the Application into a war file and deployed it onto my Application Server. When the servlet initialized, the "n" second schedule was set/initialized.

From then on, the servlet kept populating the RSS Feed file. I just ensured that my "Job" code keeps only 30 latest events within it, so that the feed file is small and under control. [a few kbs]

Next I opened up the feed xml on my browser - It requested a subscription - and Here I was - watching new deployments/life cycle events all popping up on my browser toolbar every 5 (actually n)  minutes!

rssfeed_image.JPG

Well, you could do it on a browser/reader of your choice - or perhaps read them like you read an email on your thunderbird!.

rssfeed_image_2.JPG


About

Principal Product Manager

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today