How to use For Each Component
By Akshay
Abstract
•
The main motto of this PPT is how to use For
Each component in our applications.
Introduction
•
 The Foreach scope splits a collection into 
elements and processes them iteratively 
through the processors embedded in the 
scope, then returns the original message to 
the flow.
Example
•
.mflow<?xml version="1.0" encoding="UTF-8"?>
•
<mule xmlns:jdbc-
ee="http://www.mulesoft.org/schema/mule/ee/jdbc"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/docume
ntation"
xmlns:spring="http://www.springframework.org/schema/bea
ns" version="EE-3.4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/sche
ma/beans
http://www.springframework.org/schema/beans/spring-
•
Output:INFO 2015-10-03 17:50:45,299 [main]
org.mule.DefaultMuleContext:
•
**************************************
********************************
•
* Application: Database Component
*
•
* OS encoding: Cp1252, Mule encoding: UTF-8
*
•
* *
•
* Agents Running:
•
Flow of execution:
1. URL to trigger the service from browser
http://localhost:8087/foreach
2. Database component connects to the specific
database, executes the select query and prints
the result (one by one) using for each
component
References
•
https://
docs.mulesoft.com/mule-user-guide/v/3.7/foreach

Howtouseforeachcomponent