mule esb
TRANSCRIPT
![Page 1: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/1.jpg)
MULE ESB
MULE ESB DEMO.
![Page 2: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/2.jpg)
MULE REQUIRED S/WMULE BUILDING BLOCKSSET UP IDE/SWDEMO EXAMPLES
AGENDA
![Page 3: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/3.jpg)
› What is Mule ESB?
Enterprise Service Bus (ESB) Easily perform integration of existing systems, Regardless of
technology.Service creation and hosting — expose and host reusable services. Service mediation- service mediator aids communication between
system-level service consumers and service providersMessage routing - route, filter, aggregate, and re-sequence messages
based on content and rules. Data transformation — exchange data across varying formats and
transport protocols
MULE ESB RECAP
![Page 4: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/4.jpg)
Building blocks
![Page 5: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/5.jpg)
› Components: are flexible tools which perform business logic implemented in Java and other scripting languages for e.g java component, javascript, groovy, echo, logger.
› Filters: only allow certain messages to continue to be processed in a flow for e.g .
› Routers: control message flow to route, resequence, or split and aggregate messages in a flow for e.g All flow, Choice flow.
› Scopes wrap other messages processors so as to enable them to perform together as a group. for e.g Async, Message Enricher, foreach.
› Transformers convert message payload type and data format to facilitate communication between systems converters. Object to String,Body to Parameter Map.
Message Processors
![Page 6: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/6.jpg)
› To make decisions about routing, filtering, and other common tasks. The logic of these decisions often relies on evaluating expressions.
› Mule Expression Language (MEL) is the primary language used for formulating such expressions throughout Mule ESB.
SIGNIFICANCE MEL
![Page 7: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/7.jpg)
› The message header, which contains metadata about the message › The message payload, which contains your business-specific data.
MULE MESSAGE
![Page 8: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/8.jpg)
#[message.header.get()] This expression calls the "get" method and performs it on the object,
#[message.payload[4]] the expression returns the value of the 5th item in the list.
#[message.payload['type'].equals('XML')]
Check if param type is equals to XML
#[message.id] This expression accesses a particular attribute associated with the specified context object.
#[message.payload] Returns payload.
#[2 + 2 == 4] This expression uses an operator to perform a comparison. It evaluates to true.
MULE EXPRESSION LANGUAGE
![Page 9: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/9.jpg)
› EndPoints› Ajax: this allows mule events to be asynchronously
received to and from web.› File: Allows mule application to read and write into local file
system.› Http: Allow mule events to be connected with http protocol.› Jms: Allow mule events to read and send message to
queue with JMS API.
Components
![Page 10: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/10.jpg)
› Commonly Used Component› Use a Logger component to log activities in the flow as they occur. › Use an Expression component to evaluate a particular expression upon a
message in a flow.› Use an Echo component to return the payload of a message as a call
response.› Use a Flow Ref component to access another flow from within a flow.
Component cont.
![Page 11: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/11.jpg)
› Mule message filters are message processors that follow the enterprise integration pattern called Message Filter.
Message Filters
![Page 12: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/12.jpg)
› A filter that discards incoming HTTP requests
› ………<flow name="filteredFlow2">
<http:inbound-endpoint host="localhost" port="8000" path="orders"/><expression-filter expression="message.inboundProperties['Authorization'] != null"/><component class="org.my.OrderProcessingComponent" />
</flow>…..
Message filters cont.
![Page 13: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/13.jpg)
› A choice router is a message processor that decides where to send a message based on their contents.
› A choice exception strategy is a way of deciding which way to route a message that must deviate from the normal processing path. Choice exception strategies use MEL expressions.
Choice routers
![Page 14: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/14.jpg)
Choice routers cont.
![Page 15: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/15.jpg)
› <flow name="downloadsSorterFlow">› <file:inbound-endpoint path="/home/me/downloads" />› <choice>› <when expression="#[message.inboundProperties['filename'].endsWith('.jpg']">› <file:outbound-endpoint path="/home/me/photos" />› </when>› <when expression="#[message.inboundProperties['filename'].endsWith('.doc')]">› <file:outbound-endpoint path="#[/home/me/docs" />› </when>› <otherwise>› <file:outbound-endpoint path="/home/me/misc"/>› </otherwise>› </choice>› </flow>
XML CONFIGURATION
![Page 16: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/16.jpg)
› Mule invokes a Messaging Exception Strategy whenever an exception is thrown within a flow.
Exception STRATEGY
![Page 17: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/17.jpg)
› An expression transformer is a message processor that executes expressions on the current message. The results of the expressions replace the payload.
› This transformer transforms the message by appending “Received !” to the message payload.
› <expression-transformer expression="#[message.payload + 'Received!']"/>
Expression transformers
![Page 18: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/18.jpg)
› A logger is a message processor that logs message via Mules logging sub-system.
› The message to be logged is configured as an attribute of the logger. This message attribute supports tokens (placeholders). The tokens can contain MEL expressions.
<loggermessage="File Received (size = #[message.inboundProperties['fileSize']/1024] kb)"level="INFO"
/>
Loggers
![Page 19: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/19.jpg)
› Extract the downloaded MuleStudio binary into a folder› Go to bin folder Run MuleStudio.exe› To create new project file->mule project
SETUP IDE
![Page 20: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/20.jpg)
Project structure
![Page 21: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/21.jpg)
• CONTENT BASED ROUTING• JMS EXAMPLE• STRATEGIC EXCEPTION
DEMO
![Page 22: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/22.jpg)
› Flow
Choice example
![Page 23: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/23.jpg)
• Import a project into a mule studio choice example.• Right click on the project –start as mule project• Watch the logs whether project is deployed successfully.• Execute following url to get XML response• http://localhost:1001/?
name=Muley&amount=20000&term=48&ssn=1234&type=XML• Execute following url to get different response• http://localhost:1001/?
name=Muley&amount=20000&term=48&ssn=1234&type=othervalue
How to run
![Page 24: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/24.jpg)
JMS Example
![Page 25: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/25.jpg)
› Start Apache mq› Import jmsexample into mule studio, deploy the project.› Open http://localhost:8161/admin/queues.jsp . click on send tab,
Message gui will appear, select queue as queue1 and set body content either 1001 or 1002 or 1003 for valid content or other value to set error messages .
› Watch console logs, payload for each flow will appear.› Success message will enqueue in customerqueue› Error message will enqueue in errorqueue
Steps to run
![Page 26: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/26.jpg)
CATCH EXCEPTION
![Page 27: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/27.jpg)
› Start Apache mq› Import catchexception strategy into mule studio, deploy the
project by running project as mule application.› Open http://localhost:8161/admin/queues.jsp . click on
send tab, Message gui will appear, select queue as queue1 and set body content either ERROR OR TEST OR othervalue
› Watch console logs, payload for each flow will appear.
Steps to run
![Page 28: Mule esb](https://reader035.vdocuments.net/reader035/viewer/2022070603/586fdcd81a28ab18428b6673/html5/thumbnails/28.jpg)
› MEL http://www.mulesoft.org/documentation/display/current/Introduction+to+Expressions+in+Mule
› Cheat Sheatttp://www.mulesoft.org/documentation/display/current/MEL+Cheat+Sheet› Transformershttp://www.mulesoft.org/documentation/display/current/Transformers
ESB References