In Oracle Service Bus 12c you can use the for-each action to iterate multiple elements in your input.
I want this post to show you how we can use for each component of the OSB 12c to iterate through a list of EMPLOYS.
Suppose we have the input,
<EMPLOYS>
<EMPLOY>
<ID>1</ID>
<NAME>Manohar</NAME>
</EMPLOY>
<EMPLOY>
<ID>2</ID>
<NAME>Ram</NAME>
</EMPLOY>
<EMPLOY>
<ID>3</ID>
<NAME>AnkaBabu</NAME>
</EMPLOY>
<EMPLOY>
<ID>4</ID>
<NAME>SAI</NAME>
</EMPLOY>
</EMPLOYS>
and want to log the EMPLOY node.
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:
I want this post to show you how we can use for each component of the OSB 12c to iterate through a list of EMPLOYS.
Suppose we have the input,
<EMPLOYS>
<EMPLOY>
<ID>1</ID>
<NAME>Manohar</NAME>
</EMPLOY>
<EMPLOY>
<ID>2</ID>
<NAME>Ram</NAME>
</EMPLOY>
<EMPLOY>
<ID>3</ID>
<NAME>AnkaBabu</NAME>
</EMPLOY>
<EMPLOY>
<ID>4</ID>
<NAME>SAI</NAME>
</EMPLOY>
</EMPLOYS>
and want to log the EMPLOY 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 ./EMPLOYS/EMPLOY as we need to iterate each EMPLOY 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/EMPLOYS/EMPLOY[xs:int($currentIndex)]
Let’s run the pipeline and see the logs
No comments:
Post a Comment