Wednesday, December 16, 2009

Scheduling BPEL Service

If you would like to schedule a BPEL service every few hours then there is no direct support provided by the BPEL engine or Oracle Application Server to do this. This may be required when the service/process has to run as a batch process.

I have read about solutions using File Adapter, Database Adapter, process running in loop, etc.

The most elegant solution(in my view) is to develop a Java solution using Quartz Scheduler(open source) and deploy it as a war application in the Oracle Weblogc Server. You may want to externalize(from war) the jobs.xml so that the schedule time can be altered. You may also want to externalize the end points so that they can be modified as suited.

WS-Addressing

Typically,  Web Services communicate over SOAP through Http. Since Http is stateless in nature, there can be a maximum of 1 complete conversation at a time. This suits well for short request-response messages where the conversation is complete. But for conversations that span multiple asynchronous or  synchronous message exchanges , there should be more information packed so that there is a callback information and a context for the message. This is standardized by the WS-Addressing specification by w3 which is available here

 
When an asynchronous process is invoked, the BPEL engine either invokes a new process or resumes a running process. It does this by looking at the Address information in the header of the SOAP message. A sample header can be seen below (it is taken from the w3 spec referred above).

 
Request
<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
<S:Header>
<wsa:MessageID>uuid:6B29FC40-CA47-1067-B31D-00DD010662DA </wsa:MessageID>
<wsa:ReplyTo>
<wsa:Address>http://business456.example/client1</wsa:Address>
</wsa:ReplyTo>
<wsa:To>http://fabrikam123.example/Purchasing</wsa:To>
<wsa:Action>http://fabrikam123.example/SubmitPO</wsa:Action>
</S:Header>
<S:Body>
...
</S:Body>
</S:Envelope>

 
Note that the request has ReplyTo as the response end point and the context for the conversation as MessageID.

 
Response
<S:Envelope xmlns:f123="http://www.fabrikam123.example/svc53">
<S:Header>
<wsa:MessageID>uuid:aaaabbbb-cccc-dddd-eeee-wwwwwwwwwww</wsa:MessageID>
<wsa:RelatesTo>uuid:6B29FC40-CA47-1067-B31D-00DD010662DA </wsa:RelatesTo>
<wsa:To S:mustUnderstand="1">
http://business456.example/client1
</wsa:To>
<wsa:Action>http://fabrikam123.example/mail/DeleteAck</wsa:Action>
</S:Header>
<S:Body>
<f123:DeleteAck/>
</S:Body>
</S:Envelope>

 
Note that the response has RelatesTo as the context for the conversation.

 
All additional message exchanges in this conversations only require the RelatesTo element as the BPEL engine can invoke the process instance with this information.

Other informative artciles

Tuesday, December 15, 2009

Service Specification Template

If you are looking for a Service defnition template then the following should be a good place to start with and customize it accordingly
  1. This is available from CBDI