SlideShare a Scribd company logo
Choice Flow Control Reference
in Mulesoft
• The choice flow control dynamically routes messages based
on message payload or properties. It adds conditional
programming to a flow, similar to an if/then/else code
block.
• A choice flow control uses expressions to evaluate the
content of a message, then it routes the message to one of
the routing options within its scope (see image below). It
directs messages to the first routing option in the scope
that matches the routing configurations (evaluates to true).
If none of expressions evaluate to true, the choice flow
control directs the message to the default (else) route.
• Adding the Choice Flow Control
• Configuring the Choice Flow Control
• Changing the Default Route
• Complete Example Code
Adding the Choice Flow Control
• <flow name="New_Studio_ProjectFlow1"
doc:name="New_Studio_ProjectFlow1">
• <http:listener config-ref="HTTP_Listener_Configuration" path="/"
doc:name="HTTP"/>
• <expression-filter expression="#[message.inboundProperties.'http.request.uri'
!= '/favicon.ico']" doc:name="Expression"/>
• <set-variable variableName="language"
value="#[message.inboundProperties.'http.query.params'.language]"
doc:name="Set Language Variable"/>
• <choice doc:name="Choice">
• <when expression="">
• </when>
• <otherwise>
• </otherwise>
• </choice>
• <logger message="#[payload]" level="INFO" doc:name="Logger"/>
• </flow>
Configuring the Choice Flow Control
• To configure the choice flow control, you need to
determine the following message routing details:
• Content the choice flow router should evaluate to
determine routing
• Number of routing options with which to supply
the choice flow control
• What processing Mule should perform for each
routing option
• Default routing option
Changing the Default Route
• You can change the choice flow control configuration
to identify a different default routing option
• Adjust your XML configuration to swap the contents of
a when element and the otherwise element.
• The code sample below has been adjusted to make the
Spanish language the default routing option and
change the English language to a when element. Note
that the otherwise element requires no further
configuration, but we defined a new expression for the
new when element.
Example
• <choice doc:name="Choice">
• <when expression="#[flowVars.language == 'french']">
• <set-payload value="Bonjour!" doc:name="Reply in French"/>
• </when>
• <when expression="#[flowVars.language == 'spanish']">
• <set-payload value="Hola!" doc:name="Reply in Spanish"/>
• </when>
• <otherwise >
• <set-variable variableName="language" value="English"
doc:name="Set Language to English"/>
• <set-payload value="Hello!" doc:name="Reply in English"/>
• </otherwise>
• </choice>

More Related Content

What's hot

Mule java part-1
Mule java part-1Mule java part-1
Mule java part-1
Karnam Karthik
 
Mule overview
Mule overviewMule overview
Mule overview
Praneethchampion
 
Routing in mule
Routing in muleRouting in mule
Routing in mule
vasanthii9
 
Hyperfun with hyperloop - Ihor Strumetskyi
Hyperfun with hyperloop - Ihor StrumetskyiHyperfun with hyperloop - Ihor Strumetskyi
Hyperfun with hyperloop - Ihor Strumetskyi
Ruby Meditation
 
Mule expression component
Mule expression componentMule expression component
Mule expression component
Karnam Karthik
 
INTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE AND JSP PROCESSING
INTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE  AND JSP PROCESSINGINTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE  AND JSP PROCESSING
INTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE AND JSP PROCESSING
Aaqib Hussain
 
9780538745840 ppt ch01 PHP
9780538745840 ppt ch01 PHP9780538745840 ppt ch01 PHP
9780538745840 ppt ch01 PHP
Terry Yoast
 
Mule xml to-object transformer
Mule xml to-object transformerMule xml to-object transformer
Mule xml to-object transformer
Ankush Sharma
 
9780538745840 ppt ch02
9780538745840 ppt ch029780538745840 ppt ch02
9780538745840 ppt ch02
Terry Yoast
 

What's hot (11)

Mule java part-1
Mule java part-1Mule java part-1
Mule java part-1
 
Mule overview
Mule overviewMule overview
Mule overview
 
servlets and jsp
servlets and jspservlets and jsp
servlets and jsp
 
Routing in mule
Routing in muleRouting in mule
Routing in mule
 
Hyperfun with hyperloop - Ihor Strumetskyi
Hyperfun with hyperloop - Ihor StrumetskyiHyperfun with hyperloop - Ihor Strumetskyi
Hyperfun with hyperloop - Ihor Strumetskyi
 
Mule expression component
Mule expression componentMule expression component
Mule expression component
 
INTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE AND JSP PROCESSING
INTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE  AND JSP PROCESSINGINTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE  AND JSP PROCESSING
INTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE AND JSP PROCESSING
 
9780538745840 ppt ch01 PHP
9780538745840 ppt ch01 PHP9780538745840 ppt ch01 PHP
9780538745840 ppt ch01 PHP
 
Mule xml to-object transformer
Mule xml to-object transformerMule xml to-object transformer
Mule xml to-object transformer
 
9780538745840 ppt ch02
9780538745840 ppt ch029780538745840 ppt ch02
9780538745840 ppt ch02
 
Jsp tutorial (1)
Jsp tutorial (1)Jsp tutorial (1)
Jsp tutorial (1)
 

Similar to Choice flow control reference

Choice flow control
Choice flow controlChoice flow control
Choice flow control
Ramakrishna kapa
 
Mule esb and_relevant_components
Mule esb and_relevant_componentsMule esb and_relevant_components
Mule esb and_relevant_components
Paaras Baru
 
Muleesbcomponents1 160625154208
Muleesbcomponents1 160625154208Muleesbcomponents1 160625154208
Muleesbcomponents1 160625154208
ppts123456
 
MuleSoft ESB CSV to XML
MuleSoft ESB CSV to XMLMuleSoft ESB CSV to XML
MuleSoft ESB CSV to XML
akashdprajapati
 
MuleSoft ESB XML to CSV
MuleSoft ESB XML to CSVMuleSoft ESB XML to CSV
MuleSoft ESB XML to CSV
akashdprajapati
 
MVCL pattern, web flow, code flow, request and response in OpenCart
MVCL pattern, web flow, code flow, request and response in OpenCartMVCL pattern, web flow, code flow, request and response in OpenCart
MVCL pattern, web flow, code flow, request and response in OpenCart
Self
 
M expression
M expressionM expression
M expression
Vasanthii Chowdary
 
Server Scripting Language -PHP
Server Scripting Language -PHPServer Scripting Language -PHP
Server Scripting Language -PHP
Deo Shao
 
An introduction to Apache Camel
An introduction to Apache CamelAn introduction to Apache Camel
An introduction to Apache Camel
Kapil Kumar
 
Mule ESB Interview or Certification questions
Mule ESB Interview or Certification questionsMule ESB Interview or Certification questions
Mule ESB Interview or Certification questions
TechieVarsity
 
Total ODFB Migration Process through SPMT Tool
Total ODFB Migration Process through SPMT ToolTotal ODFB Migration Process through SPMT Tool
Total ODFB Migration Process through SPMT Tool
IT Industry
 
Mule esb overview
Mule esb overviewMule esb overview
Mule esb overview
Gunjan Deshmukh
 
Mule data weave_2
Mule data weave_2Mule data weave_2
Mule data weave_2
kunal vishe
 
4. Web programming MVC.pptx
4. Web programming  MVC.pptx4. Web programming  MVC.pptx
4. Web programming MVC.pptx
KrisnaBayu41
 
Srilekha mule esb
Srilekha mule esbSrilekha mule esb
Srilekha mule esb
srilekha2820
 
Mule connectors
Mule connectorsMule connectors
Mule connectors
Krishna_in
 
Es_module2ppt.pptx
Es_module2ppt.pptxEs_module2ppt.pptx
Es_module2ppt.pptx
RohanAM1
 
Anypoint connectors
Anypoint connectorsAnypoint connectors
Anypoint connectors
Ramakrishna kapa
 
Integration Solution Patterns
Integration Solution Patterns Integration Solution Patterns
Integration Solution Patterns WSO2
 
AdroitLogic UltraESB
AdroitLogic UltraESBAdroitLogic UltraESB
AdroitLogic UltraESB
AdroitLogic
 

Similar to Choice flow control reference (20)

Choice flow control
Choice flow controlChoice flow control
Choice flow control
 
Mule esb and_relevant_components
Mule esb and_relevant_componentsMule esb and_relevant_components
Mule esb and_relevant_components
 
Muleesbcomponents1 160625154208
Muleesbcomponents1 160625154208Muleesbcomponents1 160625154208
Muleesbcomponents1 160625154208
 
MuleSoft ESB CSV to XML
MuleSoft ESB CSV to XMLMuleSoft ESB CSV to XML
MuleSoft ESB CSV to XML
 
MuleSoft ESB XML to CSV
MuleSoft ESB XML to CSVMuleSoft ESB XML to CSV
MuleSoft ESB XML to CSV
 
MVCL pattern, web flow, code flow, request and response in OpenCart
MVCL pattern, web flow, code flow, request and response in OpenCartMVCL pattern, web flow, code flow, request and response in OpenCart
MVCL pattern, web flow, code flow, request and response in OpenCart
 
M expression
M expressionM expression
M expression
 
Server Scripting Language -PHP
Server Scripting Language -PHPServer Scripting Language -PHP
Server Scripting Language -PHP
 
An introduction to Apache Camel
An introduction to Apache CamelAn introduction to Apache Camel
An introduction to Apache Camel
 
Mule ESB Interview or Certification questions
Mule ESB Interview or Certification questionsMule ESB Interview or Certification questions
Mule ESB Interview or Certification questions
 
Total ODFB Migration Process through SPMT Tool
Total ODFB Migration Process through SPMT ToolTotal ODFB Migration Process through SPMT Tool
Total ODFB Migration Process through SPMT Tool
 
Mule esb overview
Mule esb overviewMule esb overview
Mule esb overview
 
Mule data weave_2
Mule data weave_2Mule data weave_2
Mule data weave_2
 
4. Web programming MVC.pptx
4. Web programming  MVC.pptx4. Web programming  MVC.pptx
4. Web programming MVC.pptx
 
Srilekha mule esb
Srilekha mule esbSrilekha mule esb
Srilekha mule esb
 
Mule connectors
Mule connectorsMule connectors
Mule connectors
 
Es_module2ppt.pptx
Es_module2ppt.pptxEs_module2ppt.pptx
Es_module2ppt.pptx
 
Anypoint connectors
Anypoint connectorsAnypoint connectors
Anypoint connectors
 
Integration Solution Patterns
Integration Solution Patterns Integration Solution Patterns
Integration Solution Patterns
 
AdroitLogic UltraESB
AdroitLogic UltraESBAdroitLogic UltraESB
AdroitLogic UltraESB
 

More from Krishna_in

Validations module
Validations moduleValidations module
Validations moduleKrishna_in
 
Mule maven Plugin
Mule maven PluginMule maven Plugin
Mule maven PluginKrishna_in
 
Splitter flow control reference
Splitter flow control referenceSplitter flow control reference
Splitter flow control reference
Krishna_in
 
Scatter gather flow control
Scatter gather flow controlScatter gather flow control
Scatter gather flow control
Krishna_in
 
Datasense
DatasenseDatasense
Datasense
Krishna_in
 
Soa(service oriented architecture)
Soa(service oriented architecture)Soa(service oriented architecture)
Soa(service oriented architecture)
Krishna_in
 
Soa project fundamentals
Soa project fundamentalsSoa project fundamentals
Soa project fundamentals
Krishna_in
 
Soa planning
Soa planningSoa planning
Soa planning
Krishna_in
 
Soa methodology
Soa methodologySoa methodology
Soa methodology
Krishna_in
 
Soa governance
Soa governanceSoa governance
Soa governance
Krishna_in
 
Principles of soa
Principles of soaPrinciples of soa
Principles of soa
Krishna_in
 
Mule transformers
Mule transformersMule transformers
Mule transformers
Krishna_in
 
Mule exception strategies
Mule exception strategiesMule exception strategies
Mule exception strategies
Krishna_in
 
Mule components
Mule componentsMule components
Mule components
Krishna_in
 
Mule agent architecture
Mule agent architectureMule agent architecture
Mule agent architecture
Krishna_in
 
Message state
Message stateMessage state
Message state
Krishna_in
 
Global elements
Global elementsGlobal elements
Global elements
Krishna_in
 
Flows and subflows
Flows and subflowsFlows and subflows
Flows and subflows
Krishna_in
 

More from Krishna_in (20)

Validations module
Validations moduleValidations module
Validations module
 
Mule maven Plugin
Mule maven PluginMule maven Plugin
Mule maven Plugin
 
API Policies
API PoliciesAPI Policies
API Policies
 
Data Weave
Data WeaveData Weave
Data Weave
 
Splitter flow control reference
Splitter flow control referenceSplitter flow control reference
Splitter flow control reference
 
Scatter gather flow control
Scatter gather flow controlScatter gather flow control
Scatter gather flow control
 
Datasense
DatasenseDatasense
Datasense
 
Soa(service oriented architecture)
Soa(service oriented architecture)Soa(service oriented architecture)
Soa(service oriented architecture)
 
Soa project fundamentals
Soa project fundamentalsSoa project fundamentals
Soa project fundamentals
 
Soa planning
Soa planningSoa planning
Soa planning
 
Soa methodology
Soa methodologySoa methodology
Soa methodology
 
Soa governance
Soa governanceSoa governance
Soa governance
 
Principles of soa
Principles of soaPrinciples of soa
Principles of soa
 
Mule transformers
Mule transformersMule transformers
Mule transformers
 
Mule exception strategies
Mule exception strategiesMule exception strategies
Mule exception strategies
 
Mule components
Mule componentsMule components
Mule components
 
Mule agent architecture
Mule agent architectureMule agent architecture
Mule agent architecture
 
Message state
Message stateMessage state
Message state
 
Global elements
Global elementsGlobal elements
Global elements
 
Flows and subflows
Flows and subflowsFlows and subflows
Flows and subflows
 

Recently uploaded

Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 

Recently uploaded (20)

Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 

Choice flow control reference

  • 1. Choice Flow Control Reference in Mulesoft
  • 2. • The choice flow control dynamically routes messages based on message payload or properties. It adds conditional programming to a flow, similar to an if/then/else code block. • A choice flow control uses expressions to evaluate the content of a message, then it routes the message to one of the routing options within its scope (see image below). It directs messages to the first routing option in the scope that matches the routing configurations (evaluates to true). If none of expressions evaluate to true, the choice flow control directs the message to the default (else) route.
  • 3. • Adding the Choice Flow Control • Configuring the Choice Flow Control • Changing the Default Route • Complete Example Code
  • 4. Adding the Choice Flow Control • <flow name="New_Studio_ProjectFlow1" doc:name="New_Studio_ProjectFlow1"> • <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/> • <expression-filter expression="#[message.inboundProperties.'http.request.uri' != '/favicon.ico']" doc:name="Expression"/> • <set-variable variableName="language" value="#[message.inboundProperties.'http.query.params'.language]" doc:name="Set Language Variable"/> • <choice doc:name="Choice"> • <when expression=""> • </when> • <otherwise> • </otherwise> • </choice> • <logger message="#[payload]" level="INFO" doc:name="Logger"/> • </flow>
  • 5. Configuring the Choice Flow Control • To configure the choice flow control, you need to determine the following message routing details: • Content the choice flow router should evaluate to determine routing • Number of routing options with which to supply the choice flow control • What processing Mule should perform for each routing option • Default routing option
  • 6. Changing the Default Route • You can change the choice flow control configuration to identify a different default routing option • Adjust your XML configuration to swap the contents of a when element and the otherwise element. • The code sample below has been adjusted to make the Spanish language the default routing option and change the English language to a when element. Note that the otherwise element requires no further configuration, but we defined a new expression for the new when element.
  • 7. Example • <choice doc:name="Choice"> • <when expression="#[flowVars.language == 'french']"> • <set-payload value="Bonjour!" doc:name="Reply in French"/> • </when> • <when expression="#[flowVars.language == 'spanish']"> • <set-payload value="Hola!" doc:name="Reply in Spanish"/> • </when> • <otherwise > • <set-variable variableName="language" value="English" doc:name="Set Language to English"/> • <set-payload value="Hello!" doc:name="Reply in English"/> • </otherwise> • </choice>