mule

Getting started with mule

Remarks#

This section provides an overview of what mule is, and why a developer might want to use it.

It should also mention any large subjects within mule, and link out to the related topics. Since the Documentation for mule is new, you may need to create initial versions of those related topics.

Installation or Setup on MS windows OS

Detailed instructions on getting mule set up or installed.

  1. Before going to start with mule we have to insure that java home is set.
  2. Mule CE runtime don’t need installation.
  3. We have to just unzip the downloaded file and go to bin directory of mule runtime.
  4. In MS windows Operating system we have to run mule.bat file with admin privilege.
  5. Mule will deploy default app and up now.
  6. Now you can manually deploy mule app by just past mule app zip file at app directory of runtime and check log in log directory.

Mule flow xml for simple hello example

    <?xml version="1.0" encoding="UTF-8"?>
    
    <mule xmlns:http="https://www.mulesoft.org/schema/mule/http" xmlns="https://www.mulesoft.org/schema/mule/core"
        xmlns:doc="https://www.mulesoft.org/schema/mule/documentation"
        xmlns:spring="https://www.springframework.org/schema/beans" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="https://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-current.xsd
    https://www.mulesoft.org/schema/mule/core https://www.mulesoft.org/schema/mule/core/current/mule.xsd
    https://www.mulesoft.org/schema/mule/http https://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
        <http:listener-config name="HTTP_Listener_Configuration"
            host="0.0.0.0" port="8082" doc:name="HTTP Listener Configuration" />
        <flow name="helloworldFlow">
            <http:listener config-ref="HTTP_Listener_Configuration"
                path="/Hello" allowedMethods="GET" doc:name="HTTP" />
            <set-payload value="Hello #[message.inboundProperties.'http.query.params'.name]" doc:name="Set Payload" />
            <logger message="#[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger" />
        </flow>
    </mule>
    

Basic example to access a database and select all records in the database using anypoint studio

<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="${http.port}" doc:name="HTTP Listener Configuration"/>

<db:mysql-config name="MySQL_Configuration" host="${db.host}" port="${db.port}" user="${db.user}" password="${db.password}" database="${db.database}" doc:name="MySQL Configuration"/>

<context:property-placeholder location="prop.properties"/>

<flow name="Total">
    <http:listener config-ref="HTTP_Listener_Configuration" path="/" allowedMethods="GET" doc:name="HTTP"/>

    <db:select config-ref="MySQL_Configuration" doc:name="Database">
        <db:parameterized-query><![CDATA[SELECT * FROM TableName]]></db:parameterized-query>
    </db:select>

    <json:object-to-json-transformer doc:name="Total"/>

</flow>https://stackoverflow.com/documentation/mule/4147/getting-started-with-mule/28752/mule-flow-xml-for-simple-hello-example#

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow