Composite Source Scope in Mule
A special scope known as a Composite Source Scope allows you to encapsulate two or more connectors that receive the same type of data (for example, email, files, database maps, or HTML) into a single message processing block. Each embedded connector listens on its specific channel for incoming messages. Whichever connector receives a message first becomes the message source for that particular instance of the flow.
Composite source is when multiple inbound endpoints are configured to listen to the request or work as a message source. Composite source is a collection of inbound endpoints which listen for the request on different endpoints, and when any of the inbound endpoints receives a message, it triggers the flow.
We can have n endpoints, which are configured as composite source and ready to accept messages on any inbound endpoint.
Working of Composite Source :
To accept incoming messages from multiple input channels, place two or more message sources (also known as receivers) into a composite source. A message entering the composite source on any supported channel triggers the processing flow.
Here we are using Message Enricher in mule 3 in Anypoint studio 6.2
Composite source scope can contain multiple message sources composed of multiple inbound endpoints.
Here in our flow we have HTTP connector with different resource name.
So from both url we can hit the API.
http://localhost:8085/api/source
http://localhost:8085/api/source2
method : GET
Output is set payload is set to : Hello Himanshu
output :
XML project code :
<?xml version="1.0" encoding="UTF-8"?>
<mule 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:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8085" doc:name="HTTP Listener Configuration" basePath="/api"/>
<flow name="test_composite_sourceFlow">
<composite-source doc:name="Composite Source">
<http:listener config-ref="HTTP_Listener_Configuration" path="/source2" doc:name="HTTP"/>
<http:listener config-ref="HTTP_Listener_Configuration" path="/source" doc:name="HTTP"/>
</composite-source>
<set-payload value="Hello Himanshu" doc:name="Set Payload"/>
</flow>
</mule>
I have read your blog its very attractive and impressive.
ReplyDeleteMule soft Training in Bangalore