Day-8 Configuring Exception strategies

There are different types of strategies available in mule to configure exceptions.


If we did not configure the exception strategy to the flow. then the exception will be handled by Mule Default Message exception strategy.

catchExceptionStrategy like similar to handling exception in Java using


}catch(Exception ex){



In flow:

<catch-exception-strategy doc:name=”CatchExceptionStrategy”>
<logger message=”Exception occured” level=”INFO” doc:name=”Logger”/>


It will handle all the exceptions.  if you want to handle each exception in a different manner then need to choose choiceExceptionStrategy.


if you define exception strategy inside flow the scope of strategy is up to the flow. the flow won’t be available in other flows.

To make the flow available to al flows, the strategy need to declare exception on global scope rather flow scope. the refer the strategy in the flow using ReferenceExceptionStrategy.


we can override Mule default exception strategy by declaring the exception strategy at global scope and marking it as default using configuration tag

  <configuration  defaultExceptionStrategy-ref=”myCatch”/> 

Code examples available at at



Day -7 Configuring SOAP web Services

In Mule ESB we can configure SOAP based web services through CXF component available in component palette.  we can develop services and clients for Simple and JAX-WS and proxy.

we can configure code first and contract first style web services.

  1. Exposing a method implementation as web service without JAX-WS
  2. Exposing a method implementation as web service with JAX-WS
  3. Exposing Contract first web service

Steps for Simple Service without JAX-WS.

  • configure HTTP component
  • Code the Service interface and implementation.

package simplesoap;
public interface WishService {
public String sayHello(String name);

package simplesoap;
public class WishServiceImpl implements WishService {
public String sayHello(String name) {
return “Hello” + name + “How are you ??” ;

  • Configure Java componentSOAP-1
  • Configure CXF component.SOAP-2
  • The configuration looks like
  • SOAP-3

2) Configuring service with JAX-WS

TO expose Jax-WS based web services, we need to annotate the service interface with @webservice

Steps are same as above service, only the service interface is annotated with @Webservice annotation

package jaxwssoap;
import javax.jws.WebService;
public interface EmployeeService {
public SalaryDetails getEmpSalDetails(Employee emp);

  1. Exposing Contract first web service, Please refer

Code examples find at at

Day-6 JMS and DB Insert

Configure JMS queue in Mule flow. we are using ActiveMQ JMS implementation for this demo.

  • Download  ActiveMQ from
  • Navigate to the path of activeMq
  • C:\xxxxx\apache-activemq-5.14.2-bin\apache-activemq-5.14.2\bin\win64
  • start ActiveMq messging server by giving command as >activemq
  • Configure ActiveMq to Anypoint studio
  • Drag and drop JMS icon to canvas
  • JMS
  • the properties as below. select the exchange pattern one-way or request-response based on requirement and provide queue namejms-2
  • Provide queue name and click on + icon
  • jms-3
  • provide username and password as admin/admin
  • Configuration complete

Demo-1: JMS as outbound endpoint.

send a request to mule flow where JMS queue configured as outbound endpoint


Import and execute the project, analyze the ActiveMQ console at


open the queues tab to see the queue details.

Demo-2 JMS as Inbound.

Design a flow that initiates from the JMS queue.


download and execute the project jmsreceiver.

Use ActiveMQ console to send the message to JMS queue. by clicking “Send” menu item on ActiveMQ home page




DB Insert Program:

Use Expression transformer to retrieve the fields from the payload. expression transformer will create new outbound endpoint properties. and populates them using Mule expression language.



Import the project DBInsertDemo  to the Anypoint  and run the flow

Test the flow with Postman or SOAPUI using the payload

<?xml version=”1.0″ encoding=”UTF-8″?>

makesure you selected mime type as application/xml while sending the request.

4) Analyze the Iterating the ResultSet and sending each record as JMS message in DBdemo projectDB-Iterate

The Demo projects available at

Day-5 Database connectivity and Sync & Async FLow concept

Concepts discussed today

  • Database connectivity and retrieving information
  • Sync-Async flows

Database connectivity:  MySql database has out of box support for Mule platform.

create Maven based mule project in order to manage database dependent jars. else create normal Mule project add mysql driver jar file to the build path.

DB setup:

created DB schema as :

CREATE DATABASE `mulesupport` /*!40100 DEFAULT CHARACTER SET utf8 */;

Created table in DB moviedetails in mulesupport schema as

CREATE TABLE `moviedetails` (
`movieCode` varchar(7) NOT NULL,
`movieName` varchar(50) DEFAULT NULL,
`director` varchar(45) DEFAULT NULL,
`hero` varchar(45) DEFAULT NULL,
`releaseDate` date DEFAULT NULL,
`status` varchar(14) DEFAULT NULL,
PRIMARY KEY (`movieCode`)

inserted few records in to database as

INSERT INTO `mulesupport`.`moviedetails`
(<{movieCode: }>,
<{movieName: }>,
<{director: }>,
<{hero: }>,
<{releaseDate: }>,
<{status: }>);

insert the date format as yyyy-MM-dd for release date field .

Application execution:

Design a flow that contains DB as message processor


execute the 3 modes of query processing.  execute the shared project and try to run the similar requirement in a customized way.

Sync and Async Flows:

Incase of Async caller won’t wait for the response from the calle. whereas in Sync mode caller blocks till the response received from the called flow.

execute the analyze the project and try to create your own customized implementation.

<?xml version=”1.0″ encoding=”UTF-8″?>

<mule xmlns:http=”; xmlns:tracking=”; xmlns=”; xmlns:doc=”;
<http:listener-config name=”HTTP_Listener_Configuration” host=”localhost” port=”8081″ doc:name=”HTTP Listener Configuration”/>
<flow name=”Flow-1″>
<http:listener config-ref=”HTTP_Listener_Configuration” path=”/” doc:name=”HTTP”/>
<logger message=”got request” level=”INFO” doc:name=”Logger”/>
<async doc:name=”Async”>
<flow-ref name=”flow-2″ doc:name=”flow1″/>
<logger message=”In Flow1 after referncing flow2″ level=”INFO” doc:name=”Logger”/>
<flow name=”flow-2″>
<component class=”syncasync.MyObj” doc:name=”Java”/>
<logger message=”In Flow2 executing the flow” level=”INFO” doc:name=”Logger”/>

Please find the demo projects available  at day-5 zip

Day-4 Flows and Variables

Discussed concepts

  • Connecting Flows
  • Passing properties between flows
  • Flow and session Variables
  • Flows, sub flows and private flows
  • Synchronous and Asynchronous flows

Connecting Flows:


Points to observe:

  • VM endpoint configuration
  • Properties flowing from first flow to second flow
  • what need to do if we want to copy all inbound properties of first flow to the second flow
  • download execute the project “connectingflows” in Anypoint studio
  • Test from the browser:  http://localhost:8081?name=abc&age=22
  • How to copy selected inbound properties to outbound. execute the demo project  “usingmessagetransformer”  to analyze this.

Using Flow-reference 


Debug the project and test with browser http://localhost:8085?name=abc&age=22

2. Flow and Session Variables:


Points to observe

  • Import the project and analyze how the flow and session variables are created.
  • Debug the demo and understand scope of flow and session variables

The projects available at

Mule Exercises( Day 1,2 and 3)

Please find course contents and demo projects  here

Lab -1:  Mule Basics

  • 1) Develop a flow that will display “HelloWorld”  to the browser.
  • 2) Install Postman plug-in to google  chrome and  send HTTP POST request,

“Hello World”  as Payload, print payload using logger component and observe Inbound and outbound properties in debug mode.

Lab-2: Configuring Java component to Mule Flow

  • 1) Configure component with Method Entry point resolver
  • 2) Configure Java component with three different types of method arguments with the Help of Invoke activity
  • 3) What is the difference between Configuring java component as Spring bean and configuring component as non-spring based?
  • 4) Develop a component implementing Callable Interface
  • 5) Develop a Java component using Annotations.


Lab-3: Mule Expression Language:

  • 1) What is syntax of retrieving inboundProperties of  Mule Message
  • 2) What is Mule Expression to Retrieve Http method? In how many ways we can define this expression?
  • 3) Develop  Xpath expression to extract data from payload
  • 4) Develop regular expression to extract data from Payload

Lab-4: Connecting Flows

  • 1) Connecting the flows using VM endpoints and flowref, observe inbound and outbound properties in both scenarios







MuleSoft: REST web Service Development

Learn about how to expose and consume simple RESTful web service in Mule Anypoint.


Steps required to execute:

  1. Configure Http endpoint in Anypoint studio
  2. Create Java implementation for service
  3. Configure the REST component
  4. Test the Rest Service

Configure Http endpoint in Anypoint studio:

create a Flow with Http endpoint, configure the HTTP endpoint with Host and port as localhost and 8081.


create a package under source folder src/main/java



Create Java implementation for service



public class SimpleRestTest {

public Response getWishes(@PathParam(“name”)String name){
String output = “Hi ” + name;
return Response.status(200).entity(output).build();


Configure the REST component

Drag and drop REST component from component pallette, and  configure the developed Java implementation as Spring bean.



Click ok, Finish and Finish.

Configuration is complete and ready to deploy the flow file as below

<?xml version=”1.0″ encoding=”UTF-8″?>

<mule xmlns:jersey=”; xmlns:http=”; xmlns=”; xmlns:doc=”;
<http:listener-config name=”HTTP_Listener_Configuration” host=”localhost” port=”8081″ doc:name=”HTTP Listener Configuration”/>
<spring:bean id=”Bean” name=”Bean” class=”” scope=”singleton”/>
<spring:bean id=”simpleRest” name=”simpleRest” class=””/>
<flow name=”restdemoFlow”>
<http:listener config-ref=”HTTP_Listener_Configuration” path=”/*” doc:name=”HTTP”/>
<jersey:resources doc:name=”REST”>
<spring-object bean=”Bean”/>

Test the Rest Service:

Deploy the Flow to Mule runtime from AnyPoint studio, Make sure the flow deployed properly

Open browser and hit the Url:  http://localhost:8081/users/sai

You can watch Response as Hi Sai in the browser:

Congragulations ! you configured simple Rest service in Mule Flow.