Tuesday Sep 09, 2008

Announcing Scheduler Service Engine

Ever wanted to kick off your BPEL to do something like send a loan approval status to a customer every so often?  Now you can easily do so in OpenESB with the advent of the Scheduler (powered by OpenSymphony Quartz) Service Engine (SE)!  With a few simple steps, you can create schedule files that will trigger your BPEL provider endpoint with a message and begin a new Business Process instance that subsequently performs some task like sending status to loan applicants.  The following instructions assume you have some familiarity with how to use components in OpenESB, but if not please click here to get more acquainted.

  1. Create a new Scheduler project in NetBeans by going to File | New Project and choosing SOA category and Scheduler Module project type and then selecting Next:
  2. Enter an apropos name for the Scheduler project and select Finish:
  3. Create a schedule file that can contain one or more triggers by right-clicking in the Process Files folder of the newly created Scheduler project and selecting New | Schedule File menu item:
  4. Enter a meaningful name for the schedule file (the project and schedule file names form the prefix to the name of the Scheduler SE consumer endpoint—in this example, it will be schedLoansRUs-sendLoanStatusPort—that will be sending a message to your BPEL provider endpoint) and press Finish:
  5. A Table view editor for the schedule file appears and now simply click on the Simple Trigger toolbar button (just a clock) to create a new trigger (currently only Quartz SimpleTrigger has been implemented; CronTrigger will follow soon).  You can double-click in the Name cell to give the trigger a more meaningful name, as well as provide a Description:
  6. or if you're a diehard  XML fan, there's the XML Source view:


  7. With the respective trigger table row highlighted (note, the Selected checkbox is used for indicating selected triggers for deletion), you can specify the various parameters for that trigger.  Changes to a field are registered when either focus is lost or an Enter key is pressed (except for the Message text area since it will accept newlines as part of the data):
    • The Starting and Ending Date & Time entries delineate when this trigger will be active.  Until a date/time chooser is implemented (very soon; or please donate if you have a good free open-source one), you'll need to enter one manually in the default locale format (Java SimpleDateFormat is used); the first item in the Job Date Format exemplifies the default locale format.  Alternatively, if you want the trigger to be active immediately after the Composite Application has been deployed, choose Now and similarly select Never if the active period has no end.
    • A simple trigger basically repeats after a certain time interval so specify the Repeat Count or Indefinite and the various time units that comprise the overall time interval.
    • Finally, the Job section pertains to the Message that will be sent when the trigger fires and will contain a metadata part that details the appointed date and time the trigger was configured to fire (note, this may precede the actual time the message is received due to network latency) in the specified Date Format.  Moreover, the metadata will also contain the trigger's name and group to which it belongs.
  8. Save your work and right-click over the Scheduler project and select Build Project to generate the corresponding abstract WSDL file for the schedule:
  9. The abstract WSDL can be used to define a BPEL service to receive the trigger message and so we'll now go to File | New Project and select the SOA category, BPEL Module project type and press Next:
  10. Key in an apropos name for the BPEL project and press Finish:
  11. We need to copy and paste the abstract WSDL generated for the schedule from the Scheduler project into the BPEL project's Process Files folder (XML catalog referencing will be supported soon):
  12. To simulate sending a loan application status to a customer, we're just going to write to a file on disk.  Thus, we need to create a concrete WSDL for the File Binding Component (BC) and start by right-clicking the BPEL project's Process Files and selecting New | WSDL Document:
  13. Supply a meaningful name for the WSDL file and press Next (don't press Finish yet):
  14. Choose a One-Way Operation for the Operation Type and press Next:
  15. Then choose FILE Binding Type and now at last, press Finish:
  16. We're almost there and now have to define the BPEL process that is to be triggered by the schedule.  Right-click the BPEL project's Process Files folder and select New | BPEL Process:
  17. In the ensuing BPEL editor, drag and drop the Scheduler's abstract WSDL from the BPEL's Process Files folder to somewhere approximately the middle of the left gray column until you select a hotspot target dot:
  18. Now do analogously for the File concrete WSDL but to the right gray column:
  19. Next, drag and drop these activities from the BPEL Palette onto the canvas area at appropriate hotspot locations: a Receive, an Assign, and an Invoke:
  20. Select the edit icon (one with a pencil) of the Receive activity and specify the appropriate fields as illustrated below, remembering to create an Input Variable:
  21. Similarly, edit the Invoke activity and specify the fields as illustrated below, again remembering to create an Input Variable:
  22. Now double-click on the Assign activity to configure the Mapper for it, to do something similar to the following (note the use of the message metadata):
  23. "Are we there yet, are we there yet?"  Yup, almost.  We just need to dump both projects into a Composite Application project, build and deploy.  Thus, go to File | New Project and select SOA category, Composite Application project type and press Next:
  24. As always, enter a meaningful name for the Composite App and press Finish:
  25. Drag and drop both Scheduler and BPEL projects onto the Comp App editor canvas and press the Build (hammer) toolbar button (might need to press the Build button again to dismiss the Reloading progress meter):
  26. Connect the Scheduler consumer endpoint chevron to the BPEL provider endpoint (this will be enhanced soon to be automatically done); when there are multiple schedules defined and hence multiple scheduler consumer endpoints, it's prudent to choose meaningful names for the Scheduler project and schedule file because together, they help form the endpoint names as seen here:
  27. Save all your work and we're almost ready for deployment.  But first we must verify that the GlassFish Application Server and Scheduler SE are up and running by going to the Services window (tab):
  28. Alas, go back to the Projects tab and right-click the Composite App project and select Deploy:
  29. The Comp App project will start running and you should see a test.xml file in your OS temp directory (ex. C:\\temp on Windows) with content something like this (hint, you'll need to configure the File BC to use append mode):



  30. Voilà, you're done!  Happy trails!
  31. P.S. If you want to take a test drive, click here for the OpenESB installer and here for this Scheduler demo projects.

About

Edward Wong

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