SlideShare a Scribd company logo
1 of 7
Basic Example
using For Each
Component
Introduction
• The Foreach splits a collection into elements and
processes them iteratively through the processors
embedded in the scope, then returns the original
message to the flow.
FLOW
XML:
<?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/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd">
<jdbc-ee:mssql-data-source name="MS_SQL_Data_Source" user=“****" password=“****"
url="jdbc:sqlserver://localhost;databaseName=test1" transactionIsolation="UNSPECIFIED" doc:name="MS SQL Data
Source"/>
<jdbc-ee:connector name="Database" dataSource-ref="MS_SQL_Data_Source" validateConnections="true"
queryTimeout="-1" pollingFrequency="0" doc:name="Database"/>
<flow name="Database_ComponentFlow1" doc:name="Database_ComponentFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" path=“fe"
doc:name="HTTP"/>
<logger message="--main flow--" level="INFO" doc:name="Logger"/>
<jdbc-ee:outbound-endpoint exchange-pattern="request-response" queryKey="select" queryTimeout="-1" connector-
ref="Database" doc:name="Database">
<jdbc-ee:query key="select" value="select * from mytable"/>
</jdbc-ee:outbound-endpoint>
<foreach collection="#[payload]" doc:name="For Each">
<logger message="--In foreach loop" level="INFO" doc:name="Logger"/>
<logger message="--Result--#[payload]" level="INFO" doc:name="Logger"/>
</foreach>
</flow>
</mule>
Output:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Started app 'Database Component' +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO 2015-10-03 17:50:52,770 [[Database Component].connector.http.mule.default.receiver.02]
org.mule.api.processor.LoggerMessageProcessor: --main flow--
INFO 2015-10-03 17:50:52,778 [[Database Component].connector.http.mule.default.receiver.02]
org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'Database.dispatcher.424429501'. Object is:
EEJdbcMessageDispatcher
INFO 2015-10-03 17:50:52,779 [[Database Component].connector.http.mule.default.receiver.02]
org.mule.lifecycle.AbstractLifecycleManager: Starting: 'Database.dispatcher.424429501'. Object is: EEJdbcMessageDispatcher
INFO 2015-10-03 17:50:53,042 [[Database Component].connector.http.mule.default.receiver.02]
org.mule.api.processor.LoggerMessageProcessor: --In foreach loop
INFO 2015-10-03 17:50:53,046 [[Database Component].connector.http.mule.default.receiver.02]
org.mule.api.processor.LoggerMessageProcessor: --Result--{subj=Subject, marks=55, name=Name1, id=1}
INFO 2015-10-03 17:50:53,047 [[Database Component].connector.http.mule.default.receiver.02]
org.mule.api.processor.LoggerMessageProcessor: --In foreach loop
INFO 2015-10-03 17:50:53,049 [[Database Component].connector.http.mule.default.receiver.02]
org.mule.api.processor.LoggerMessageProcessor: --Result--{subj=Subject, marks=65, name=Name2, id=2}
INFO 2015-10-03 17:50:53,050 [[Database Component].connector.http.mule.default.receiver.02]
org.mule.api.processor.LoggerMessageProcessor: --In foreach loop
INFO 2015-10-03 17:50:53,052 [[Database Component].connector.http.mule.default.receiver.02]
org.mule.api.processor.LoggerMessageProcessor: --Result--{subj=Subject, marks=75, name=Name3, id=3}
INFO 2015-10-03 17:50:53,053 [[Database Component].connector.http.mule.default.receiver.02]
org.mule.api.processor.LoggerMessageProcessor: --In foreach loop
INFO 2015-10-03 17:50:53,056 [[Database Component].connector.http.mule.default.receiver.02]
org.mule.api.processor.LoggerMessageProcessor: --Result--{subj=Subject, marks=45, name=Name4, id=4}
Execution:
URL to trigger the service from browser
http://localhost:8080/fe
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

More Related Content

What's hot

How to get http query parameters in mule
How to get http query parameters in muleHow to get http query parameters in mule
How to get http query parameters in muleRamakrishna kapa
 
Expression filter in Mule
Expression filter in MuleExpression filter in Mule
Expression filter in MuleMohammed246
 
Message properties component in mule
Message properties component in muleMessage properties component in mule
Message properties component in muleKhan625
 
Filter expression in mule
Filter expression in muleFilter expression in mule
Filter expression in muleRajkattamuri
 
Quartz component in mule
Quartz component in muleQuartz component in mule
Quartz component in mulejaveed_mhd
 
For each component in mule
For each component in muleFor each component in mule
For each component in muleRajkattamuri
 
Quartz component in mule demo
Quartz component in mule demoQuartz component in mule demo
Quartz component in mule demoSudha Ch
 
Mule flow complete
Mule flow completeMule flow complete
Mule flow completeSon Nguyen
 
Choice component in mule
Choice component in mule Choice component in mule
Choice component in mule Rajkattamuri
 
Message properties component in mule
Message properties component in muleMessage properties component in mule
Message properties component in mulejaveed_mhd
 
MuleSoft ESB Routes first-successful
MuleSoft ESB Routes first-successfulMuleSoft ESB Routes first-successful
MuleSoft ESB Routes first-successfulakashdprajapati
 

What's hot (16)

How to get http query parameters in mule
How to get http query parameters in muleHow to get http query parameters in mule
How to get http query parameters in mule
 
Expression filter in Mule
Expression filter in MuleExpression filter in Mule
Expression filter in Mule
 
Message properties component in mule
Message properties component in muleMessage properties component in mule
Message properties component in mule
 
Filter expression in mule
Filter expression in muleFilter expression in mule
Filter expression in mule
 
Quartz component in mule
Quartz component in muleQuartz component in mule
Quartz component in mule
 
Wildcard Filter
Wildcard FilterWildcard Filter
Wildcard Filter
 
For each component in mule
For each component in muleFor each component in mule
For each component in mule
 
Quartz component in mule demo
Quartz component in mule demoQuartz component in mule demo
Quartz component in mule demo
 
How to use smtp endpoint
How to use smtp endpointHow to use smtp endpoint
How to use smtp endpoint
 
Mule flow complete
Mule flow completeMule flow complete
Mule flow complete
 
Choice component in mule
Choice component in mule Choice component in mule
Choice component in mule
 
How to use splitter component
How to use splitter componentHow to use splitter component
How to use splitter component
 
Message properties component in mule
Message properties component in muleMessage properties component in mule
Message properties component in mule
 
MuleSoft ESB Routes first-successful
MuleSoft ESB Routes first-successfulMuleSoft ESB Routes first-successful
MuleSoft ESB Routes first-successful
 
Sftplite
SftpliteSftplite
Sftplite
 
Configurare https mule
Configurare https muleConfigurare https mule
Configurare https mule
 

Similar to Basic example using for each component

Howtouseforeachcomponent
HowtouseforeachcomponentHowtouseforeachcomponent
Howtouseforeachcomponentakshay yeluru
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties componentprinceirfancivil
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties componentirfan1008
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties componentPhaniu
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties componentmdfkhan625
 
Message properties component
Message properties component Message properties component
Message properties component Sunil Komarapu
 
Message properties component
Message properties componentMessage properties component
Message properties componentF K
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties componentSunil Komarapu
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties componentAnand kalla
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties componentKhasim Saheb
 
Message properties component in Mule
Message properties component in MuleMessage properties component in Mule
Message properties component in MuleKhan625
 

Similar to Basic example using for each component (20)

Howtouseforeachcomponent
HowtouseforeachcomponentHowtouseforeachcomponent
Howtouseforeachcomponent
 
How to use splitter component
How to use splitter componentHow to use splitter component
How to use splitter component
 
Splitter
SplitterSplitter
Splitter
 
How to use wildcard filter
How to use wildcard filterHow to use wildcard filter
How to use wildcard filter
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties component
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties component
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties component
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties component
 
Message properties component
Message properties component Message properties component
Message properties component
 
Message properties component
Message properties componentMessage properties component
Message properties component
 
Choice component
Choice componentChoice component
Choice component
 
Expression
ExpressionExpression
Expression
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties component
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties component
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties component
 
Message properties component in Mule
Message properties component in MuleMessage properties component in Mule
Message properties component in Mule
 
How to use expression filter
How to use expression filterHow to use expression filter
How to use expression filter
 
Collection aggregator
Collection aggregatorCollection aggregator
Collection aggregator
 
Mule Message Properties Component
Mule Message Properties ComponentMule Message Properties Component
Mule Message Properties Component
 
Property place holder
Property place holderProperty place holder
Property place holder
 

More from prudhvivreddy

About Mule execution units
About Mule execution unitsAbout Mule execution units
About Mule execution unitsprudhvivreddy
 
Working with components
Working with componentsWorking with components
Working with componentsprudhvivreddy
 
About mule transformers
About mule transformersAbout mule transformers
About mule transformersprudhvivreddy
 
Generating the mule flow as html document
Generating the mule flow as html documentGenerating the mule flow as html document
Generating the mule flow as html documentprudhvivreddy
 
Basic example using vm component
Basic example using vm componentBasic example using vm component
Basic example using vm componentprudhvivreddy
 
Basic example using database component
Basic example using database componentBasic example using database component
Basic example using database componentprudhvivreddy
 
Basic example using choice component
Basic example using choice componentBasic example using choice component
Basic example using choice componentprudhvivreddy
 
Basic example using file connector in anypoint studio
Basic example using file connector in anypoint studioBasic example using file connector in anypoint studio
Basic example using file connector in anypoint studioprudhvivreddy
 
Basic example using quartz component in anypoint studio
Basic example using quartz component in anypoint studioBasic example using quartz component in anypoint studio
Basic example using quartz component in anypoint studioprudhvivreddy
 
Salesforce connector Example
Salesforce connector ExampleSalesforce connector Example
Salesforce connector Exampleprudhvivreddy
 
Munit junit test case
Munit junit test caseMunit junit test case
Munit junit test caseprudhvivreddy
 

More from prudhvivreddy (19)

About Mule execution units
About Mule execution unitsAbout Mule execution units
About Mule execution units
 
Working with components
Working with componentsWorking with components
Working with components
 
About mule transformers
About mule transformersAbout mule transformers
About mule transformers
 
About jms
About jmsAbout jms
About jms
 
Webservices
WebservicesWebservices
Webservices
 
Generating the mule flow as html document
Generating the mule flow as html documentGenerating the mule flow as html document
Generating the mule flow as html document
 
Sftp connector
Sftp connectorSftp connector
Sftp connector
 
Imap connector
Imap connectorImap connector
Imap connector
 
Ftp connector
Ftp connectorFtp connector
Ftp connector
 
Hdfs connector
Hdfs connectorHdfs connector
Hdfs connector
 
Ajax connector
Ajax connectorAjax connector
Ajax connector
 
Basic example using vm component
Basic example using vm componentBasic example using vm component
Basic example using vm component
 
Basic example using database component
Basic example using database componentBasic example using database component
Basic example using database component
 
Basic example using choice component
Basic example using choice componentBasic example using choice component
Basic example using choice component
 
Basic example using file connector in anypoint studio
Basic example using file connector in anypoint studioBasic example using file connector in anypoint studio
Basic example using file connector in anypoint studio
 
Basic example using quartz component in anypoint studio
Basic example using quartz component in anypoint studioBasic example using quartz component in anypoint studio
Basic example using quartz component in anypoint studio
 
Mule fundamentals
Mule fundamentalsMule fundamentals
Mule fundamentals
 
Salesforce connector Example
Salesforce connector ExampleSalesforce connector Example
Salesforce connector Example
 
Munit junit test case
Munit junit test caseMunit junit test case
Munit junit test case
 

Recently uploaded

PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 

Recently uploaded (20)

PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 

Basic example using for each component

  • 1. Basic Example using For Each Component
  • 2. Introduction • The Foreach splits a collection into elements and processes them iteratively through the processors embedded in the scope, then returns the original message to the flow.
  • 4. XML: <?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/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd"> <jdbc-ee:mssql-data-source name="MS_SQL_Data_Source" user=“****" password=“****" url="jdbc:sqlserver://localhost;databaseName=test1" transactionIsolation="UNSPECIFIED" doc:name="MS SQL Data Source"/> <jdbc-ee:connector name="Database" dataSource-ref="MS_SQL_Data_Source" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database"/> <flow name="Database_ComponentFlow1" doc:name="Database_ComponentFlow1"> <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" path=“fe" doc:name="HTTP"/> <logger message="--main flow--" level="INFO" doc:name="Logger"/> <jdbc-ee:outbound-endpoint exchange-pattern="request-response" queryKey="select" queryTimeout="-1" connector- ref="Database" doc:name="Database"> <jdbc-ee:query key="select" value="select * from mytable"/> </jdbc-ee:outbound-endpoint> <foreach collection="#[payload]" doc:name="For Each"> <logger message="--In foreach loop" level="INFO" doc:name="Logger"/> <logger message="--Result--#[payload]" level="INFO" doc:name="Logger"/> </foreach> </flow> </mule>
  • 5. Output: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Started app 'Database Component' + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ INFO 2015-10-03 17:50:52,770 [[Database Component].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: --main flow-- INFO 2015-10-03 17:50:52,778 [[Database Component].connector.http.mule.default.receiver.02] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'Database.dispatcher.424429501'. Object is: EEJdbcMessageDispatcher INFO 2015-10-03 17:50:52,779 [[Database Component].connector.http.mule.default.receiver.02] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'Database.dispatcher.424429501'. Object is: EEJdbcMessageDispatcher INFO 2015-10-03 17:50:53,042 [[Database Component].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: --In foreach loop INFO 2015-10-03 17:50:53,046 [[Database Component].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: --Result--{subj=Subject, marks=55, name=Name1, id=1} INFO 2015-10-03 17:50:53,047 [[Database Component].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: --In foreach loop INFO 2015-10-03 17:50:53,049 [[Database Component].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: --Result--{subj=Subject, marks=65, name=Name2, id=2} INFO 2015-10-03 17:50:53,050 [[Database Component].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: --In foreach loop INFO 2015-10-03 17:50:53,052 [[Database Component].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: --Result--{subj=Subject, marks=75, name=Name3, id=3} INFO 2015-10-03 17:50:53,053 [[Database Component].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: --In foreach loop INFO 2015-10-03 17:50:53,056 [[Database Component].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: --Result--{subj=Subject, marks=45, name=Name4, id=4}
  • 6. Execution: URL to trigger the service from browser http://localhost:8080/fe Database component connects to the specific database, executes the select query and prints the result (one by one) using for each component