Download - 02 basics
![Page 1: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/1.jpg)
Module 2: Building Integration Applications
l All contents Copyright © 2015, MuleSoft Inc.
Integration Applications with Anypoint Studio
![Page 2: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/2.jpg)
Goal
l All contents Copyright © 2015, MuleSoft Inc.2
![Page 3: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/3.jpg)
• In this module, you will learn:
- About Mule applications, flows, messages, and message processors
- To use Anypoint Studio to create flows graphically using connectors, transformers, components, scopes, and flow
Objectives
l All contents Copyright © 2015, MuleSoft Inc.3
connectors, transformers, components, scopes, and flow control elements
- To build, run, test, and debug Mule applications
- To read and write message properties
- To write expressions with Mule Expression Language (MEL)
- To create variables
![Page 4: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/4.jpg)
Introducing Mule applications
l All contents Copyright © 2015, MuleSoft Inc.4 l All contents Copyright © 2015, MuleSoft Inc.
![Page 5: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/5.jpg)
• Accept and process messages through a series of message processors plugged together in a flow- A message can be initiated by an events like
∙ A consumer request from a mobile device
∙ A change to data in a database
Mule applications
l All contents Copyright © 2015, MuleSoft Inc.5
∙
∙ The creation of a new customer ID in a SaaS application
![Page 6: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/6.jpg)
• Are written in XML (primarily)- Under the hood, are Java applications using Spring
• Can be created and tested visually with Anypoint Studio- Available as a stand-alone or as an Eclipse plug-in
• Are deployed to a Mule Server Runtime
Mule applications
l All contents Copyright © 2015, MuleSoft Inc.6
• Are deployed to a Mule Server Runtime - A standalone app to a Mule runtime(typically)
- A WAR file with an embedded Mule instance to an app server
![Page 7: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/7.jpg)
• A JVM server that- Can handle many concurrent requests for different Java
(Mule) applications in a single JVM - Decouples point-to-point integrations by having all (non-
Mule) applications talk to the bus (to a Mule app) instead of directly to each other
Mule Server Runtime
l All contents Copyright © 2015, MuleSoft Inc.7
directly to each other- Decouples applications by using
∙ Protocol adaption• Communication can be over different protocols, like HTTP or FTP
∙ A canonical data format• A common format all messages are transformed to
![Page 8: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/8.jpg)
• Enterprise and community editions- Mule ESB Server runtime EE- Mule ESB Server runtime CE
• CE is open-source• EE is a hardened code line with support and additional
Mule runtime editions
l All contents Copyright © 2015, MuleSoft Inc.8
• EE is a hardened code line with support and additional capabilities
• By default, Anypoint Studio uses EE- You can install other versions and select which one to use
• http://www.mulesoft.com/platform/soa/mule-esb-enterprise
![Page 9: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/9.jpg)
• 24/7 global support• Additional connectors� Visual debugging� DataMapper and DataSense� Batch module
Mule runtime EE
l All contents Copyright © 2015, MuleSoft Inc.9
� Batch module• Caching and transaction support• Performance monitoring• Security module• Templates� Deployment and performance management
![Page 10: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/10.jpg)
• Mule applications accept and process messages through a series of message processors plugged together in a flow
Mule applications and flows
Message Flow
Message Source
l All contents Copyright © 2015, MuleSoft Inc.10
Message Processors
Error Handling
![Page 11: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/11.jpg)
• A typical flow has - A message source
∙ Accepts a message from an external source triggering the execution of the flow
- Message processors∙ Transform, filter, enrich, and process the message
Mule flows
l All contents Copyright © 2015, MuleSoft Inc.11
∙ Transform, filter, enrich, and process the message
• An application can consist of- A single flow - Multiple flows - Multiple flows connected together
![Page 12: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/12.jpg)
Set from the message source
Added by message processor
Mule messages
Inbound Properties
Outbound Properties
Mule Message
l All contents Copyright © 2015, MuleSoft Inc.12
The core of the message
Ancillary info to the message
12
Payload
Attachments
![Page 13: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/13.jpg)
Creating Mule applications with Anypoint Studio
l All contents Copyright © 2015, MuleSoft Inc.13 l All contents Copyright © 2015, MuleSoft Inc.
![Page 14: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/14.jpg)
• Anypoint Studio is an Eclipse-based integration development environment - Two-way editing between graphical and XML views- Visual debugging (EE)- Pre-built tooling to connect to
∙ Many popular services (Salesforce, Workday, Facebook, more!)
Creating Mule applications with Anypoint Studio
l All contents Copyright © 2015, MuleSoft Inc.14
∙ Many popular services (Salesforce, Workday, Facebook, more!)∙ Many standard protocols (HTTP, HTTPS, FTP, SMTP, more!)∙ Any SOAP or RESTful API
- A data transformation framework and language (EE)- One-click deployment of applications- Templates for common integration patterns (EE)- Integration with Maven for continuous build processes
![Page 15: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/15.jpg)
Anatomy of a flow: Visual
Message SourceMessage Processors
l All contents Copyright © 2015, MuleSoft Inc.15
Message Processors
Error Handling
* Each flow operates on its own thread pool
![Page 16: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/16.jpg)
Anatomy of a flow: XML
<flow name="SampleFlow" doc:name="SampleFlow">
<jms:inbound-endpoint doc:name="JMS" connector-ref="GlobalJMS”
queue="queue1" exchange-pattern="request-response" />
<expression-filter expression="#[message.inboundProperties]”
l All contents Copyright © 2015, MuleSoft Inc.16 16
Error Handling
* Each flow operates on its own thread pool
<expression-filter expression="#[message.inboundProperties]”
doc:name="Expression "/>
<data-mapper:transform doc:name="DataMapper" />
<set-property name="ProcessedByJMS" value="true" doc:name="Property”
propertyName=”escalated"/>
<catch-exception-strategy doc:name="Catch Exception Strategy">
<logger level="INFO" doc:name="Logger"/>
<jms:outbound-endpoint queue="dlq" connector-ref="glConn”
doc:name="JMS"/>
</catch-exception-strategy>
</flow>
![Page 17: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/17.jpg)
Anypoint Studio anatomy
PackageExplorer
Canvas
l All contents Copyright © 2015, MuleSoft Inc.17 1717
Explorer
Palette
Console
![Page 18: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/18.jpg)
• Create a new Mule project with Anypoint Studio• Add a connector to receive requests at an endpoint• Display a message in the Anypoint Studio console• Set the message payload
Walkthrough 2-1: Create your first Mule application
l All contents Copyright © 2015, MuleSoft Inc.18
![Page 19: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/19.jpg)
Understanding Mule application building blocks
l All contents Copyright © 2015, MuleSoft Inc.19 l All contents Copyright © 2015, MuleSoft Inc.
![Page 20: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/20.jpg)
• Mule applications accept and process messages through a series of message processors plugged together in a flow
• Message sources are usually Anypoint Connectors• Connectors provide connectivity to external resources
Message sources
l All contents Copyright © 2015, MuleSoft Inc.20
• Connectors provide connectivity to external resources - Such as databases, protocols, or APIs- Standard protocols like HTTP, FTP, SMTP, AMQP - Third-party APIs like Salesforce.com, Twitter, or MongoDB
• The first building block of most flows is a receiver that receives new messages and places them in the queue for processing
![Page 21: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/21.jpg)
• Anypoint Platform has over 120 pre-built connectors- 30 bundled with Anypoint Studio- Full library at
https://www.mulesoft.com/exchange
Anypoint Connectors
l All contents Copyright © 2015, MuleSoft Inc.21
https://www.mulesoft.com/exchange
• There are 2 main types- Endpoint-based connectors- Operation-based connectors
![Page 22: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/22.jpg)
• Are either inbound or outbound endpoints in a flow• Inbound endpoints serve as a message source for a flow• Outbound endpoints send information to external systems
- Can occur mid-flow or at the end of flows (or at the beginning in a poll)
Endpoint-based connectors
l All contents Copyright © 2015, MuleSoft Inc.22
beginning in a poll)
![Page 23: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/23.jpg)
• Require the specification of an operation for that connector to perform
• Includes most connectors not based on a standard communication protocol
Operation-based connectors
l All contents Copyright © 2015, MuleSoft Inc.23
![Page 24: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/24.jpg)
• A connector is a Mule-specific connection to an external resource of any kind
• An endpoint is a flow-level element that is configured to receive and/or send messages from and/or to external resources
Terminology: Connector vs endpoint vs transport
l All contents Copyright © 2015, MuleSoft Inc.24
resources• Transports provide connectivity to a data source or
message channel by implementing one of a variety of standard connection protocols that are bundled with Studio
![Page 25: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/25.jpg)
• A connector is a Mule-specific connection to an external resource of any kind
• Resources may be- A generic protocol like HTTP or FTP- A Java-based database
Connectors
l All contents Copyright © 2015, MuleSoft Inc.25
- A Java-based database- A specific third-party API like Salesforce or Workday
• Connectors may be operation-based or endpoint-based- This distinction refers to a difference in configuration details,
not in functionality- Endpoint-based connectors are often constructed around a
transport
![Page 26: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/26.jpg)
• An endpoint is a flow-level element that is configured to receive and/or send messages from and/or to external resources
• Any connector (whether endpoint-based or operation-based) can function as an endpoint
Endpoints
l All contents Copyright © 2015, MuleSoft Inc.26
based) can function as an endpoint• But some connectors can only act as inbound endpoints,
others can only act as outbound endpoints
![Page 27: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/27.jpg)
• When you drag a connector from the Studio palette, an endpoint is created
• For most endpoints, a lot of the configuration is encapsulated in a separate global element- A reusable object that can be used by many endpoints
Connectors and endpoints and global elements
l All contents Copyright © 2015, MuleSoft Inc.27
- A reusable object that can be used by many endpoints- Defines a connection to a network resource- These are referred to as
∙ Connectors ∙ Global Mule configuration
elements
![Page 28: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/28.jpg)
• Can send and receive HTTP and HTTPS requests over a selected host, port, and address
• Can be either a listener or a requester depending upon where you add it in a flow
• HTTP Listener connector (inbound)
HTTP connector
l All contents Copyright © 2015, MuleSoft Inc.28
- Listens for HTTP requests that arrive at a certain address and provides an HTTP response to these
- By default, host is set to 0.0.0.0∙ A shortcut to simultaneously listen on all active IP addresses
(including localhost)
• HTTP Request connector (outbound)- Sends HTTP requests to a certain address and receives
the returned response
![Page 29: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/29.jpg)
• Components - Execute specific logic upon a message, including
custom-logic in Java, JavaScript, Groovy, Python or Ruby
- Logger component
Message processors
l All contents Copyright © 2015, MuleSoft Inc.29
• Transformers - Convert data types and formats so as to "translate"
messages between applications or systems- Set Payload transformer
![Page 30: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/30.jpg)
• Scopes - Wrap snippets of code to define fine-grained behavior
within a flow
• Filters- Limit processing of messages based on set criteria
Message processors
l All contents Copyright © 2015, MuleSoft Inc.30
- Limit processing of messages based on set criteria
• Flow control- Direct messages through different pathways in an
application depending upon content or other criteria
• Error handling- Handle any errors that occur during message processing
![Page 31: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/31.jpg)
Running, testing, and debugging Mule applications
l All contents Copyright © 2015, MuleSoft Inc.31 l All contents Copyright © 2015, MuleSoft Inc.
![Page 32: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/32.jpg)
• Anypoint Studio comes complete with an embedded Mule runtime to test applications without leaving it
• The console outputs application logs and information
Running applications
l All contents Copyright © 2015, MuleSoft Inc.32
![Page 33: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/33.jpg)
• There are several options for making requests to an endpoint- A browser- A cURL command-line utility- A browser extension like Postman (for Google Chrome)
Testing applications
l All contents Copyright © 2015, MuleSoft Inc.33
- A browser extension like Postman (for Google Chrome)
![Page 34: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/34.jpg)
Debugging applications with the Mule Debugger
• Can add breakpoints to processors and step through the application- Watch message and variable values- Watch and evaluate expressions
• Debugger listens for incoming TCP
l All contents Copyright © 2015, MuleSoft Inc.34
• Debugger listens for incoming TCPconnections on localhost port 6666
![Page 35: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/35.jpg)
• Run a Mule application using the embedded Mule runtime• Make an HTTP request to the endpoint via a web browser or a
tool like cURL or Postman• Receive a response with the text Hello World• Redeploy an application• Use the Mule Debugger to debug an application
Walkthrough 2-2: Run, test, and debug a Mule application
l All contents Copyright © 2015, MuleSoft Inc.35
• Use the Mule Debugger to debug an application
![Page 36: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/36.jpg)
Reading and writing Mule messages
l All contents Copyright © 2015, MuleSoft Inc.36 l All contents Copyright © 2015, MuleSoft Inc.
![Page 37: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/37.jpg)
Set from the message source
Added by message processor
Mule messages
Inbound Properties
Outbound Properties
Mule Message
l All contents Copyright © 2015, MuleSoft Inc.37
The core of the message
Ancillary info to the message
37
Payload
Attachments
![Page 38: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/38.jpg)
• Inbound properties- Set from the message source- Read-only access- Persist throughout the flow
Message properties
Inbound Properties
Outbound Properties
Mule Message
l All contents Copyright © 2015, MuleSoft Inc.38
• Outbound properties- Added by message processor- Read/write access- Can set, remove, copy
38
Payload
Attachments
![Page 39: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/39.jpg)
• Payload- The core of the message- Contains primary info to be
processed - Contains a Java Object
Message payload and attachments
Inbound Properties
Outbound Properties
Mule Message
l All contents Copyright © 2015, MuleSoft Inc.39
- Contains a Java Object
• Attachments- Ancillary info to the message- Similar to an email attachment
39
Payload
Attachments
![Page 40: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/40.jpg)
• Raw data often of type- String- InputStream- Byte[] (Byte array)
Payload representation
Payload
<order>
<id>ed921739-99c1-4e09</id>
<custId>49e377ed-bc72-4523</custId>
<itemsTotal>200.34</itemsTotal>
</order>
org.java.lang.String
Raw Data
l All contents Copyright © 2015, MuleSoft Inc.40
• Structured data often of type- Map- Structured Java Object
∙ Order, Account, etc.
4040
Payload
id: ed921739-99c1-4e09
custId: 49e377ed-bc72-4523
itemsTotal: 200.34
org.java.util.HashMap
Structured Data
![Page 41: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/41.jpg)
Inbound message properties
Inbound Properties
Outbound Properties
Mule Message
HTTP Request
HeadersContent-Type = text/html
Method = POST
Inbound properties Content-Type = text/html
Method = POST
Host = mulesoft.org
l All contents Copyright © 2015, MuleSoft Inc.41
Payload
Attachments
Method = POST
Host = mulesoft.org
Data<order>
<id>ed921739-99c1-4e09</id>
<custId>49e377ed-bc72-4523</custId>
<itemsTotal>200.34</itemsTotal>
…
Payload
<order>
<id>ed921739-99c1-4e09</id>
<custId>49e377ed-bc72-4523</custId>
<itemsTotal>200.34</itemsTotal>
…
![Page 42: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/42.jpg)
Outbound message properties
Inbound Properties
Content-Type = text/html
Method = POST
Host = mulesoft.org
Mule Message
HTTP Request
HeadersContent-Type = text/html
Method = POST
Host = mulesoft.org
Inbound Properties
l All contents Copyright © 2015, MuleSoft Inc.42
Payload
Attachments
Host = mulesoft.org
Data<order>
<id>ed921739-99c1-4e09</id>
<custId>49e377ed-bc72-4523</custId>
<itemsTotal>200.34</itemsTotal>
…
<order>
<id>ed921739-99c1-4e09</id>
<custId>49e377ed-bc72-4523</custId>
<itemsTotal>200.34</itemsTotal>
…
![Page 43: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/43.jpg)
• Sets the value of the message payload
• Sets, removes, or copies properties on the
Setting message properties
Set Payload
l All contents Copyright © 2015, MuleSoft Inc.43
• Sets, removes, or copies properties on the outbound scope of a message- message.outboundProperties
43
Property
![Page 44: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/44.jpg)
Writing Mule expressions
l All contents Copyright © 2015, MuleSoft Inc.44 l All contents Copyright © 2015, MuleSoft Inc.
![Page 45: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/45.jpg)
• MEL is a lightweight, Mule-specific expression language• Use it to access and evaluate the data in the payload,
properties, and variables of a Mule message• Accessible and usable from within virtually every
message processor in Mule
The Mule Expression Language (MEL)
l All contents Copyright © 2015, MuleSoft Inc.45
message processor in Mule- Is used to modify the way the processors act upon the
message such as routing or filtering
• Makes use of Mule-specific context objects• Case-sensitive• Easy to use with auto-complete everywhere
![Page 46: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/46.jpg)
Basic MEL syntax
#[]
#[message]
Encapsulates all Mule expressions
l All contents Copyright © 2015, MuleSoft Inc.46
#[message]
#[message.payload]
Holds a context object
Dot notation to access fields or methods
![Page 47: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/47.jpg)
Context objects
server
mule
Operating system that message processor is
running
The Mule instance that the application is
running
l All contents Copyright © 2015, MuleSoft Inc.47
mule
application
message
running
User application the current flow
is deployed in
The Mule message that the message
processer is processing
![Page 48: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/48.jpg)
#[message.inboundProperties.host]
mulesoft.org
#[message.inboundProperties['http.method’ ]]
POST
Accessing message data
Mule Message
Inbound Properties
Method: POST
Host: mulesoft.org
Outbound PropertiesContent-Type = text/htmlMethod = POSTHost = mulesoft.org
l All contents Copyright © 2015, MuleSoft Inc.48
POST
#[message.outboundProperties['content-type’ ]]
48
Attachments[null]
Payload
id: ed921739-99c1-4e09
custId: 49e377ed-bc72-4523
itemsTotal: 200.34java.util.HashMap
![Page 49: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/49.jpg)
#[message.payload.id]
#[message.payload['id']]
ed921739-99c1-4e09
#[message.payload.itemsTotal]
200.34
Accessing message payload data
Mule Message
Inbound Properties
Method: POST
Host: mulesoft.org
Outbound PropertiesContent-Type = text/htmlMethod = POSTHost = mulesoft.org
l All contents Copyright © 2015, MuleSoft Inc.49
200.34
#[message.payload.toString()]
#[payload.id]
Is a shortcut for #[message.payload]This shortcut only works with payload
49
Attachments[null]
Payload
id: ed921739-99c1-4e09
custId: 49e377ed-bc72-4523
itemsTotal: 200.34java.util.HashMap
![Page 50: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/50.jpg)
Accessing relational map data
John Muley Boston Ohio
FirstName LastName City State
Mark Dailer Cleveland Ohio
Bill Muley Avon Ohio
l All contents Copyright © 2015, MuleSoft Inc.50
#[message.payload[1]['LastName']]Dailer
Bill Muley Avon Ohio
#[message.payload[0].City]Boston
![Page 51: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/51.jpg)
• Operators- Arithmetic: +, -, /, *, %- Evaluation: ==, !=, >, <, >=, <=, contains, is
#[message.inboundProperties.'http.query.params'.lastname != null]
Writing expressions
l All contents Copyright © 2015, MuleSoft Inc.51
• Testing for emptiness- The literal empty tests the emptiness of a value
∙ Null, boolean false, “”, “ ”, zero, empty collections
• Data extraction- XPath: #[xpath('expression')]- RegEx: #[regex('expression')]
![Page 52: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/52.jpg)
• Write MEL expressions• Use the Debugger to read inbound and outbound message
properties• Use the Property transformer to set outbound message
properties
Walkthrough 2-3: Read and write message properties
l All contents Copyright © 2015, MuleSoft Inc.52
![Page 53: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/53.jpg)
• MEL expression reference- http://www.mulesoft.org/documentation/display/current/Mul
e+Expression+Language+Reference
• MEL language tips- http://www.mulesoft.org/documentation/display/current/Mul
MEL references
l All contents Copyright © 2015, MuleSoft Inc.53
- http://www.mulesoft.org/documentation/display/current/Mule+Expression+Language+Tips
![Page 54: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/54.jpg)
Creating variables
l All contents Copyright © 2015, MuleSoft Inc.54 l All contents Copyright © 2015, MuleSoft Inc.
![Page 55: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/55.jpg)
Context variables
flowVars
sessionVar
l All contents Copyright © 2015, MuleSoft Inc.55
sessionVarsrecordVars
#[flowVars.ticketNum]
![Page 56: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/56.jpg)
• Sets or removes flow variables- Variables on the message tied to the current- Reference as flowVars
∙ The flowVars reference is optional∙ #[flowVars.foo] or #[foo]
Setting variables
Variable
l All contents Copyright © 2015, MuleSoft Inc.56
• Sets or removes session variables- Variables tied to a message for its lifecycle
across flows, applications, and servers- They are persisted across some but not all
transport barriers- Reference as sessionVars
∙ #[sessionVars.foobar]56
Session
![Page 57: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/57.jpg)
Variable persistence
Flow
Message Processor(s)
Connector Endpoint
Message Source
Message Processor(s)
Inbound Scope
l All contents Copyright © 2015, MuleSoft Inc.57
Flow Variable Scope
Outbound Scope
Session Variable Scope
![Page 58: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/58.jpg)
• Use the Variable transformer to create flow variables• Use the Session transformer to create session variables
Walkthrough 2-4: Read and write variables
l All contents Copyright © 2015, MuleSoft Inc.58
![Page 59: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/59.jpg)
Summary
l All contents Copyright © 2015, MuleSoft Inc.59 l All contents Copyright © 2015, MuleSoft Inc.
![Page 60: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/60.jpg)
• In this module, you learned to build integration applications graphically with Anypoint Studio
- Two-way editing between graphical and XML views
- An embedded Mule runtime for testing applications
Summary
l All contents Copyright © 2015, MuleSoft Inc.60
- A Visual Debugger (EE) for debugging applications
• Mule applications accept and process messages through a series of message processors plugged together in a flow
• Mule messages have inbound properties, outbound properties, a payload, and attachments
![Page 61: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/61.jpg)
• Message processors include connectors, transformers, components, scopes, and flow control elements
• Connectors are inbound or outbound and endpoint or operation based
• When you drag out a connector, an endpoint is created
Summary
l All contents Copyright © 2015, MuleSoft Inc.61
• When you drag out a connector, an endpoint is created
• For most endpoints, a lot of the configuration is encapsulated in a separate, reusable global element
![Page 62: 02 basics](https://reader031.vdocuments.mx/reader031/viewer/2022030214/588af1021a28abf8548b4d19/html5/thumbnails/62.jpg)
• Use the HTTP Listener connector as an inbound endpoint to trigger a flow with an HTTP request
• Use the Property transformer to set, remove, or copy message outbound properties
• Use the Set Payload transformer to set the payload
Summary
l All contents Copyright © 2015, MuleSoft Inc.62
• Use the Set Payload transformer to set the payload
• Use the Logger component to display data in the console
• Use the Mule Expression Language (MEL) to write expressions #[]
• Use the Variable transformer to create flow variables