Skip Headers
Oracle® BPEL Process Manager Developer's Guide
10g (10.1.3.1.0)

Part Number B28981-03
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

10 Events and Timeouts

This chapter describes how to use events and timeouts. Because Web services can take a long time to return a response, a BPEL process must be able to time out and continue with the rest of the flow after a period of time.

This chapter contains the following topics:

10.1 Use Case for Events and Timeouts

In this use case, you program a BPEL process to wait one minute for a response from the Star Loan Web service. If Star Loan does not respond in one minute, then the BPEL process automatically selects the United Loan offer. In the real world, the time limit is more like 48 hours. However, for this example, you do not want to wait that long to see if your BPEL process is working properly.

See Also:

The following sample file:
  • SOA_Oracle_Home\bpel\samples\tutorials\108.Timeouts

10.2 Overview of Event and Timeout Concepts

Because asynchronous Web services can take a long time to return a response, a BPEL process must be able to time out, or give up waiting, and continue with the rest of the flow after a certain amount of time. You can use the pick activity to configure a BPEL flow to either wait a specified amount of time or to continue performing its duties. To set an expiration period for the time, you can use the wait activity.

If you plan to set timeouts for synchronous processes that connect to a remote database, you need to set the syncMaxWaitTime timeout property in the domain.xml file.

10.3 Using the Pick Activity to Select Between Continuing a Process or Waiting

The pick activity provides two branches, each one with a condition. The branch that has its condition satisfied first is executed. In the following example, one branch's condition is to receive a loan offer, and the other branch's condition is to wait a specified amount of time.

Figure 10-1 provides an overview. The following activities take place:

  1. An invoke activity initiates a service, in this case, a request for a loan offer from Star Loan.

  2. The pick activity begins next. It has the following conditions:

    • onMessage: This condition has code for receiving a reply in the form of a loan offer from the Star Loan Web service. The onMessage code is the same as the code for receiving a response from the Star Loan Web service before a timeout was added.

    • onAlarm: This condition has code for a timeout of one minute. This time is defined as PT1M, which means to wait one minute before timing out. In this timeout setting, S stands for seconds, M for one minute, H for hour, D for day, and Y for year. In the unlikely event that you want a time limit of 1 year, 3 days, and 15 seconds, you enter it as PT1Y3D15S. The remainder of the code sets the loan variables selected and approved to false, sets the annual percentage rate (APR) at 0.0, and copies this information into the loanOffer variable.

      For more detailed information on the time duration format, see the duration section of the most current XML Schema Part 2: Datatypes document at:

      http://www.w3.org/TR/xmlschema-2/#duration
      
      
  3. The pick activity condition that completes first is the one that the BPEL process executes. The other branch then is not executed.

Figure 10-1 Overview of the Pick Activity

Description of bpmdg001.gif follows
Description of the illustration bpmdg001.gif

The following code segment defines the pick activity for this operation:

<pick>
        <!--  receive the result of the remote process -->
        <onMessage partnerLink="LoanService"
            portType="services:LoanServiceCallback"
            operation="onResult" variable="loanOffer">
            
        <assign>
        <copy>
            <from variable="loanOffer" part="payload"/>
            <to variable="output" part="payload"/>
        </copy>
        </assign> 
        
       </onMessage>
       <!--  wait for one minute, then timesout -->
       <onAlarm for="PT1M">
            <assign>
                <copy>
                    <from>
                        <loanOffer xmlns="http://www.autoloan.com/ns/autoloan">
                            <providerName>Expired</providerName> 
                            <selected type="boolean">false</selected> 
                            <approved type="boolean">false</approved> 
                            <APR type="double">0.0</APR> 
                        </loanOffer>
                    </from> 
                    <to variable="loanOffer" part="payload"/>
                </copy>
            </assign>
       </onAlarm>
</pick>

See Also:

The following samples:

10.4 Using the Wait Activity to Set an Expiration Time

The wait activity allows a process to wait for a given time period or until a time limit has been reached. Exactly one of the expiration criteria must be specified.

<wait (for="duration-expr" | until="deadline-expr") standard-attributes>
    standard-elements
  </wait>

See Also:

The following documentation for examples of defining a wait activity:

10.5 Setting Timeouts for Synchronous Processes

For synchronous processes that connect to a remote database, you must increase the syncMaxWaitTime timeout property in the SOA_Oracle_Home\bpel\domains\default\config\domain.xml file:

<property id="syncMaxWaitTime"> 
        <name>Delivery result receiver maximum wait time</name> 
        <value>45</value> 
        <comment> 
        <![CDATA[The maximum time the process result receiver will wait for a 
result before returning.  Results from asynchronous BPEL processes are 
retrieved synchronously via a receiver that will wait for a result from the 
container. 
        <p/> 
        The default value is 45 seconds.]]> 
        </comment> 
    </property> 

10.6 Defining a Timeout

To define a timeout, follow these steps:

  1. Drag and drop a Pick activity into a BPEL process.

    The Pick activity includes the onMessage (envelope icon) and onAlarm (alarm clock icon) branches.

    Description of pick2.gif follows
    Description of the illustration pick2.gif

  2. Double-click the OnAlarm branch of the onAlarm activity and set its time limit to 1 minute instead of 1 hour.

    Description of pick3.gif follows
    Description of the illustration pick3.gif

  3. Click OK.

  4. Double-click the onMessage activity, and edit its attributes to receive the response from the loan service.

    Description of pick4.gif follows
    Description of the illustration pick4.gif

See Also:

"Pick Activity"

10.7 Summary

Instead of performing multiple operations at the same time as with the flow attribute, you can use the pick activity to define a number of operations such that only the first one to complete is executed. The example in this chapter is of a pick activity where one branch is an asynchronous callback from a loan service, and the other branch is a timeout set at one minute.