Senin, 16 Januari 2017

For each action in Oracle Service BUS 12c

In Oracle Service Bus 12c you can use the for-each action to iterate multiple elements in your payload.

I want this post to show you how we can use for each component of the OSB 12c to iterate through a list of users.

Suppose we have the payload

<USERS>
<USER>
<ID>1</ID>
<NAME>Ankur</NAME>
</USER>
<USER>
<ID>2</ID>
<NAME>Ankit</NAME>
</USER>
</USERS>

and want to log the USER node.

Let's go through an example and see how For Each component works:

1) Create a Service Bus application with Service Bus project

2) Create a pipeline




3) Double click on the pipeline and drag and drop the pipeline pair node. Drag and drop the For Each component from the component pallet under the Request stage:


4) Configure the For Each properties like below:


Let's see the properties:

  • For Each Value: Configure the variable that need to iterate. In our case we have configured body as we have the payload in our body only.
  • Expression: Which node you need to iterate. In our case we have configured ./USERS/USER as we need to iterate each USER node from the payload.
  • Value Variable: You can leave it blank, not required.
  • Index Variable: This is the variable that keeps the track of current index.
  • Counter Variable: This is the variable that contains the total no of nodes available in the payload.
5) Drag the log activity from the component pallet under the For Each and put the expression:

$body/USERS/USER[xs:int($currIndex)]



Let's run the pipeline and see the logs




That's it !!

Tidak ada komentar:

Posting Komentar