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


Wednesday Apr 07, 2010

weblogic.socket.MaxMessageSizeExceededException: Incoming message of size: '10000080' bytes exceeds the configured maximum of: '10000000' bytes for protocol: 't3'.

If you are using BPEL Client APIs against WLS 9.2, and if you run into this exception, pass the following JVM argument to get things going,

-Dweblogic.MaxMessageSize=value

Make the value high enough for all that data to come through and you should be good.

Wednesday Mar 31, 2010

Calling Web Services with HTTP Basic Authentication from BPEL 10.1.3.4

Are you using BPEL 10.1.3.4 and hunting for the property names in the partnerlinkBindings that will work for outbound HTTP Basic Authentication?
Here's the answer.

<partnerLinkBinding ...>

  <property name="basicHeaders">credentials</property>

  <property name="basicUsername">WhoAmI</property>

  <property name="basicPassword">thatsASecret</property>

</partnerLinkBinding>

The drop down options in JDeveloper dont seem to work.

Friday Jul 17, 2009

Writing Non-ASCII Content into MQ

[Read More]

Tuesday Mar 03, 2009

Tackling "Failed to evaluate correlation query"

Problem observed on BPEL PM 10.1.3.3.

I developed a simple BPEL process that uses BPEL correlation to receive callbacks into the process.
For this purpose, I altered the process WSDL to add one more operation.
The initiating operation was named "processOrder". I decided to name the callback operation as "processOrderCallback".
I promptly defined two properties on the correlation set and provided aliases for both for the invocation and callback messages.
When I invoke the process, it throws up a CubeException and goes to recovery mode.
Why? Possibly because the callback operation name is a "superstring" of the invocation operation name.
When I looked at the logs, I could see that the engine was trying to evaluate the correlation query for the callback on the initiating message.
What I did next - just renamed the operation to "receiveOrderCallback" and re-ran the instance.
Bingo! - it worked.

Friday Feb 20, 2009

XML Parsing failed because of "" Potential fix N/A

If you run into this error while compiling your BPEL project, open up your build.properties file and set verbose=true. Then run the compilation from the ant build, instead of the jdev compile/deploy.
You will get a stack trace from the ant build log that will give you some hints on the reasons for the compilation error.

Monday Nov 26, 2007

Miscellaneous Ant tasks for Managing the BPEL Server

The serverAdmin ANT task

This news item describes a simple ant task that I had come up named serverAdmin that allows you to

  • Selectively undeploy BPEL Processes
  • Selectively purge BPEL process instances.
  • Cancel and Recover Invocation Messages
  • Cancel and Recover Callback Messages
  • Get one or more domain configuration properties
  • Set one or more domain configuration properties
  • Fetch the latest domain log from the Server
  • Create/delete a domain on the BPEL server

Setup and Usage


To setup this task, perform the following steps.

  • Copy the admintasks.jar from http://blogs.oracle.com/ramkumarMenon/gems/admintasks.jar into $ORACLE_HOMEintegrationlib directory.

  • Open up ant-orabpel.xml in $ORACLE_HOMEbpelutilities directory and paste the following piece of code into the file within the element.

<path id="admin.tasks.class.path">
   <pathelement location="${bpel.home}/../lib/admintasks.jar"/>
  </path>
  <property name="admin.tasks.class.path" refid="admin.tasks.class.path"/>
  <taskdef name="serverAdmin" classname="com.collaxa.cube.ant.taskdefs.ServerAdmin">
    <classpath>
      <pathelement path="${admin.tasks.class.path}"/>
    </classpath>
  </taskdef>

Illustrative Command Syntax

      <serverAdmin  providerURL="opmn:ormi://<hostName>:<opmnRequestPort>:<oc4jInstanceName>/orabpel"  userName="oc4jadmin" providerURL="opmn:ormi://::/orabpel">
      <serverAdmin  providerURL="opmn:ormi://<hostName>:<opmnRequestPort>:<oc4jInstanceName>/orabpel" userName="oc4jadmin" password="<pwdforoc4jadmin>">
       <createDomain domainName="testDomain"/>
       <deleteDomain domainName="testDomain"/>
       <manageDomain domain="default">
              <undeployProcesses select="BPELProcess.*"  type="all" revision="all"/>
              <undeployProcesses select="TestXPath"  type="retired" revision="all"/>
             <undeployProcesses select="Sample.*" type="all" revision="2.0"/>
             <undeployProcesses select="SampleProcess" type="active" revision="1.0"/>
         <!--example dateTime format "yyyy-MM-dd'T'HH:mm:ss Z"   "1994-11-05T08:15:30 -0800-->
         <!--example date format "yyyy-MM-dd"   "1994-11-05"-->
          <purgeInstances select="TestXPath" type="all" fromDateTime="2007-10-29T11:21:03 -0800" toDateTime="2007-10-31T13:21:03 -0800"/>
          <purgeInstances select="TestJMS" type="closed.stale" fromDateTime="2007-10-29T11:21:03 -0800" toDateTime="2007-10-31T13:21:03 -0800"/>
             <getProperties propertyNames="dspMinThreads,dspMaxThreads,syncMaxWaitTime"/>
              <setProperty name="dspMinThreads" value="5"/>
              <cancelInvocations select="PurchaseOrderProcess" revision="1.0" fromDateTime="2007-11-05T17:45:56 -0800" toDateTime="2007-11-05T17:45:58 -0800"/>
              <recoverInvocations select="OrderCreationProcess" revision="1.0" fromDateTime="2007-11-05T17:21:10 -0800" toDateTime="2007-11-05T17:21:15 -0800"/>
              <cancelCallbacks select="OrderCreationProcess" revision="2.0" fromDate="2007-11-05" toDate="2007-11-06"/>
              <recoverCallbacks select="OrdeUpdateProcess" revision="2.0" fromDate="2007-11-05" toDate="2007-11-06"/>
              <printLog outFile="D:\\temp\\latest_domain.log" lineCount="2000"/>
          <purgeInstances select="all" type="closed.stale" fromDate="2007-10-29" toDate="2007-10-31"/>
          <purgeInstances fromDate="2007-10-29" toDate="2007-10-31"/>
          <purgeInstances select="SampleProcess" type="closed.completed"  toDateTime="2007-10-31"/>
          <purgeInstances select="SampleProcess2" fromDateTime="2007-10-29T11:21:03 -0800"/>
          <purgeInstances select="TestXPath" type="closed.stale" fromDate="2007-10-29" />
         <purgeInstances/>
        </manageDomain>
      </serverAdmin>

Short Description


1. UnDeployProcesses subtask


The select argument for "undeployProcesses" subtask accepts both exact process names, as well as java regex expressions. For instance, the above example shows undeployment for all processes whose name starts with the string "BPELProcess".
All arguments are mandatory.If you wish to specify "all" values for one or more arguments, specify them in the format ="all". For instance, you can specify type="all" or revision="all" or select="all" to indicate selection of all process states, all revisions or all processes.

2. PurgeInstances subtask


If fromDateTime/fromDate is omitted, it purges every matching instance upto and including the "toDateTime/toDate". Note that in case you specify a date as opposed to a dateTime, the time is defaulted to the beginning of the date. [i.e. 12 AM]
If the "toDateTime/toDate" is omitted, it purges every matching instance till the present.
If both are specified, the task purges all matching instances including and between the given timespan.
If both are omitted, the task purges all matching instances irrespective of the time.
The dateTime has to be specified in the format given in the above example.
The "type" attribute, if omitted, is equivalent to "all". The other values are

  • closed.aborted
  • closed.cancelled
  • closed.completed
  • closed.faulted
  • closed.stale
  • closed.pendingCancel
  • initiated
  • open.running
  • open.faulted
  • open.suspended

Each serverAdmin task can be used to administer a different BPEL runtime.
Within each serverAdmin, you can provide multiple tasks, one for each domain to purge and undeploy processes and instances in each domain.


3. Print Log Subtask


Prints the domain log

4. SetProperty subtask


Sets a domain property. e.g. dspMaxThreads

5. GetProperties subtask


Gets the property values for the given set of domain properties.[comma separated]

6. Recovery/Cancellation/Deletion of Invocation or callback subtasks


Recovers, deletes or cancels invocations/callback. Arguments to this task are the processName, revision, the from/to date or dateTimes in the given format as specified in the example. [yyyy-MM-dd'T'HH:mm:ss Z or yyyy-MM-dd]

7. Create Domain subtask


Creates a domain with the given name.

8. Delete Domain subtask


Deletes the domain with the given name.
Notes:
Ensure that BPEL_HOME and ORACLE_HOME are properly set.
Sample Build File

<?xml version="1.0" encoding="iso-8859-1"?>
<project name="ServerAdminBuild" default="deploy" basedir=".">
    <!--=============================-->
    <!-- Process deployment targets  -->
    <!--=============================-->
    <!-- Set bpel.home from developer prompt's environment variable BPEL_HOME -->
    <condition property="bpel.home" value="${env.BPEL_HOME}">
        <available file="${env.BPEL_HOME}/utilities/ant-orabpel.xml"/>
    </condition>
    <!-- If bpel.home is not yet using env.BPEL_HOME, set it for JDev -->
    <property name="bpel.home" value="${oracle.home}/integration/bpel"/>
    <!-- First override from build.properties in process.dir, if available -->
    <property file="${process.dir}/build.properties"/>
    <!-- import custom ant tasks for the BPEL PM -->
    <import file="${bpel.home}/utilities/ant-orabpel.xml"/>
    <target name="adminTasks">
      <serverAdmin  providerURL="opmn:ormi://server.host.com:6004:oc4j_soa/orabpel" userName="oc4jadmin" password="welcome1">
        <manageDomain domain="default">
              <undeployProcesses select="BPELProcess.*"  type="all" revision="all"/>
             <getProperties propertyNames="dspMinThreads"/>
              <setProperty name="dspMinThreads" value="5"/>
              <cancelInvocations select="PurchaseOrderProcess" revision="1.0" fromDateTime="2007-11-05T17:45:56 -0800" toDateTime="2007-11-05T17:45:58 -0800"/>
              <recoverlInvocations select="OrderCreationProcess" revision="1.0" fromDateTime="2007-11-05T17:21:10 -0800" toDateTime="2007-11-05T17:21:15 -0800"/>
              <cancelCallbacks select="OrderCreationProcess" revision="2.0" fromDate="2007-11-05" toDate="2007-11-06"/>
              <recoverCallbacks select="OrdeUpdateProcess" revision="2.0" fromDate="2007-11-05" toDate="2007-11-06"/>
              <printLog outFile="D:\\temp\\latest_domain.log" lineCount="2000"/>
              <undeployProcesses select="TestXPath"  type="retired" revision="all"/>
             <undeployProcesses select="Sample.*" type="all" revision="2.0"/>
             <undeployProcesses select="SampleProcess" type="active" revision="1.0"/>
         <!--example dateTime format "yyyy-MM-dd'T'HH:mm:ss Z"   "1994-11-05T08:15:30 -0800-->
         <!--example date format "yyyy-MM-dd"   "1994-11-05"-->
          <purgeInstances select="TestXPath" type="all" fromDateTime="2007-10-29T11:21:03 -0800" toDateTime="2007-10-31T13:21:03 -0800"/>
          <purgeInstances select="TestJMS" type="closed.stale" fromDateTime="2007-10-29T11:21:03 -0800" toDateTime="2007-10-31T13:21:03 -0800"/>
          <purgeInstances select="all" type="closed.stale" fromDate="2007-10-29" toDate="2007-10-31"/>
          <purgeInstances fromDate="2007-10-29" toDate="2007-10-31"/>
          <purgeInstances select="SampleProcess" type="closed.completed"  toDateTime="2007-10-31"/>
          <purgeInstances select="SampleProcess2" fromDateTime="2007-10-29T11:21:03 -0800"/>
          <purgeInstances select="TestXPath" type="closed.stale" fromDate="2007-10-29" />
         <purgeInstances/>
        </manageDomain>
      </serverAdmin>
    </target>
</project>














     

About

Principal Product Manager

Search

Archives
« July 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
31
  
       
Today