Until now we have seen how to do parallel activity execution with a <flow>
activity. We also learned about the <while>
and <repeatUntil>
activities, which support for repetitive executions. Suppose the BPEL process needs to read 10 data entries from a database. The BPEL process should execute the same data retrieval command with a different index in each command. This is a repetitive task, so we can use <while>
or <repeatUntil>
to achieve it. However, this can be parallelized as well. Each data retrieval command is executed in a parallel manner than in a sequential repetitive manner. How can a BPEL process execute a set of repetitive tasks in parallel?
The <forEach>
activity comes to the rescue. It lets us define repetitive tasks in sequential or in parallel. Let's see how it works.
In this chapter, we will cover the following topics:
<invoke>
activity within a <forEach>
activity<forEach>
activity<forEach>
activity<forEach>
activity and its execution semanticsIn this section, we introduce a new sample named book querying process that reads a book name as input, searches it across all the bookstores (Bookstore A, Bookstore B, and Bookstore C), and returns the bookstores in which the book is available. The sample is as shown in the following screenshot:
Let's move on to the creation of the <forEach>
activity creation. Within the <forEach>
activity, we use the <invoke>
activity to send search requests. During the <invoke>
creation process, the input and output variable creation also can be configured. First of all, let's create a new asynchronous BPEL 2.0 process named Book_Querying_Process. We illustrated creating an asynchronous BPEL process in Chapter 5, Interaction Patterns in BPEL.