Components are message processors which execute business logic on messages. They enable you to perform specific actions without writing any Mule-specific code. You can drop a component – a POJO, Spring bean, Java bean, or script – into a flow to perform almost any customized task within your Mule application. For example, you can use a component to verify that items on an invoice are in stock in a warehouse, or to update a database with a customer's order history.
Mule includes several scripting components that you can use in flows in order to execute custom business logic. These components enable you to drop a chunk of custom-written logic into your flow to act upon messages.
The example below illustrates the use of a Groovy script component. The script uses the value of
state to determine which of four sales regions to which to assign the lead.
Web Service Components
Also included are two components to facilitate exposing, consuming, and proxying Web services. The CXF component leverages the CXF framework Mule uses to support SOAP Web services; the REST component works with Jersey to support RESTful Web services; both are bound to HTTP.
|APIkit offers a new and improved way of building a REST API. Access the APIkit Documentation to learn how to build REST APIs in a few hours or days.|
Further, Mule provides two HTTP components to facilitate working with calls over HTTP. Use the HTTP Response Builder to convert a message into a format consistent with HTTP responses; use the HTTP Static Resource Handler to easily serve up static content when called.
Finally, Mule includes several other components designed to meet rather specific needs.
- 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 Invoke component to invoke the method of an object specified with a Mule expression.
- 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.
- Use a Batch Execute component to kick off processing of a batch job.
Groovy Script Component Example
REST Component Example
Echo, Logger, and HTTP Components Examples