viernes, 20 de mayo de 2016

Mule ESB Example

Example: Hello World

In this example, we will create a simple Mule application to implement the following flow:

Mule-ESB-Hello-World-Example-1

The flow accepts HTTP requests, sets a payload on the message, applies some transformation on the payload, and finally returns a response to the end user.
So we will use  :
  • HTTP endpoint : it allows, in the beginning of the flow, to receive request from the end user, and, in the end of the flow, to return the message as response to the end user.
  • Java Transformer : to apply a custom transformation on the payload : "Hello " + {payload}
  • Echo component : to display the message payload.

1. Technologies used

  • Anypoint Studio
  • JDK 1.7

2. Mule XML Editor

The following is the flow in XML representation:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.5.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
    <flow name="mulehelloworldexampleFlow1" doc:name="mulehelloworldexampleFlow1">
        <http:inbound-endpoint exchange-pattern="request-response"
            host="localhost" port="8081" doc:name="HTTP" />
        
        <custom-transformer class="com.keylesson.transformer.KeyTransformer"
            doc:name="Key Transformer" />
        
        <echo-component doc:name="Echo" />
    </flow>
</mule>

3. Java Transformer

To apply a custom transformation on the message payload, we have used Java Transformer.

The following is the class called by the Java Transformer :

package com.keylesson.transformer;
import org.mule.api.transformer.TransformerException;
import org.mule.transformer.AbstractTransformer;
public class KeyTransformer extends AbstractTransformer {
    @Override
    protected Object doTransform(Object src, String enc)
            throws TransformerException {
        return "Hello " + src.toString().substring(1);
    }
}

martes, 17 de mayo de 2016

My first experience using Mulesoft ESB

First time I used Mulesoft ESB, I used Spring security with Spring dao and JPA.

The Multitenant which I implemented is separate schema per tenant.

I created a Tenant Routing Datasource which has key value pair of varous tenants schema credentials and i resolve the tenant from SpringSecurityContextHolder or from a Threadlocal TenantContextHolder.

While logging in, I set these parameters by writing a separate Cookie Processing Filter as part of SpringSecurity Filter chain.

The positive experience is that you can keep on adding datasource at runtime during your SpringSecurity filter chain processing.

Not positive as such if you are registering a new datasource, and you create schema for it on runtime it takes sometime for first login on a normal harddisk.
Also, as part of design is the number of open datasource connections which you should carefully look into as you gonna have more datasources.

Anyway, good experience.


I will continue working with Mulesoft ESB.

Mulesoft ESB

Mule is an ESB* (Enterprise Service Bus) framework. It is an scalable object manager that handles interactions with services and applications that uses different technologies for transport and messaging like web service or sockets.

*:An enterprise service bus (ESB) is a software architecture model used for designing and implementing communication between mutually interacting software applications in a service-oriented architecture (SOA).

Mule was designed to be easily implemented into Java applications, or to be able to run it as an stand alone service. Mule supports a lot of tools like: Mule Management Console, Anypoint Studio, Anypoint Enterprise Security, Mule IDE, Mule Healthcare Toolkit, ...

Mule also has a JBI container that is distributed with the eclipse-based muleIDE, which is a set of plugins for eclipse that is used to develop, deploy and manage projects.
Also provides message auditing defined by the enterprise integration patterns book.


Mulesoft Champions program

All you known me, you know that I love working with Mule ESB. So for the beginning you have to know about something incredible that comes from Mulesoft.

It is the Mulesoft Champions Program!


And of course, you will ask, what is it?



It's an incredible program created by MuleSfot to spread awareness about its platform.
Signing up at champions.mulesoft.com you will start to engaging with the platform and completing a lot of funny challenges that will let you get on awesome perks!

You really have to try it!