DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Composite Source With Mule ESB

Composite Source With Mule ESB

This walkthrough will show you how to use the Composite Source with Mule Flow, for when you want to define multiple sources to receive incoming messages.

Jitendra Bafna user avatar by
Jitendra Bafna
CORE ·
Apr. 20, 17 · Tutorial
Like (3)
Save
Tweet
Share
9.94K Views

Join the DZone community and get the full member experience.

Join For Free

Composite source is a scope available with mule ESB which listens to multiple channels for incoming messages. If any of the receivers or inbound endpoints receive the message, it passes to the next processor and results in triggering the flow. A scope in Mule is also known as a wrapper.

There can be a case where you need to define multiple sources to receive the messages. For example, you can receive purchase orders from various customers and every one has to send a message through different channels like File Share, Web Service or REST Call, JMS, SFTP, etc. But the way of handling or business process defined for each customer is same, so we can use the Composite source in such a case.

Let's walk through how to use Composite source with Mule Flow.

Search for Composite source in Mule Pallette and place it to the source region of flow.

 <flow name="composite-flowFlow">
        <composite-source doc:name="Composite Source"/>
    </flow>

Now you can drag and drop multiple connectors under composite source (i.e. wrap the multiple connectors with Composite source). In this case, we will use two HTTP Listeners and one File Connector as inbound endpoints to receive messages from different sources.

  <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
    <http:listener-config name="HTTP_Listener_Configuration1" host="0.0.0.0" port="8082" doc:name="HTTP Listener Configuration"/>
    <flow name="composite-flowFlow">
        <composite-source doc:name="Composite Source">
            <http:listener config-ref="HTTP_Listener_Configuration" path="/cs" doc:name="HTTP" allowedMethods="POST"/>
            <http:listener config-ref="HTTP_Listener_Configuration1" path="/cs" doc:name="HTTP" allowedMethods="POST"/>
            <file:inbound-endpoint path="src/test/resources/in" responseTimeout="10000" doc:name="File"/>
        </composite-source>
    </flow>

Image title

Now, drag and drop the File connector in message processor region. Whenever an incoming message is received by any listener, it will pass to next processor. In this case, the message will be passed to File connector in message processor region.

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:file="http://www.mulesoft.org/schema/mule/file" 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" 
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/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd">
    <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
    <http:listener-config name="HTTP_Listener_Configuration1" host="0.0.0.0" port="8082" doc:name="HTTP Listener Configuration"/>
    <flow name="composite-flowFlow">
        <composite-source doc:name="Composite Source">
            <http:listener config-ref="HTTP_Listener_Configuration" path="/cs" doc:name="HTTP" allowedMethods="POST"/>
            <http:listener config-ref="HTTP_Listener_Configuration1" path="/cs" doc:name="HTTP" allowedMethods="POST"/>
            <file:inbound-endpoint path="src/test/resources/in" responseTimeout="10000" doc:name="File"/>
        </composite-source>
        <file:outbound-endpoint path="src/test/resources/out" responseTimeout="10000" doc:name="File"/>
    </flow>
</mule>

Image titleTesting The Application

You can use Postman to test the application. In this case, there are two HTTP Listeners and one File endpoint listening to incoming messages.

Image title

Similarly, you can use other receivers to trigger the flow.

Now, you know how to use the Composite source in Mule Flow.

Enterprise service bus

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Automated Testing With Jasmine Framework and Selenium
  • Low-Code Development: The Future of Software Development
  • 5 Steps for Getting Started in Deep Learning
  • A Deep Dive Into AIOps and MLOps

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: