An Enterprise Service Bus (ESB) is a set of rules and principles for integrating numerous applications together over a bus-like infrastructure. The central concept is that the ESB provides the middleware and interfaces that allow businesses to connect their applications without writing code.
Mule ESB is a lightweight Java-based ESB and integration platform that allows developers to connect applications together quickly and easily, enabling them to exchange data. It’s scalable messaging framework, capability to operate over complex topologies, flexible configuration to run on distributed environment and wide range of connector led us to choose it over other ESB framework.
MuleESB with Liferay
Create Liferay connector for Mule ESB if you want to integrate entire liferay services. That can easily be developed using Liferay JSON API instead creating hook to hit Mule ESB HTTP endpoint. Read more about How to develop connector.
There is another approach mentioned in MuleESB integration Liferay forum thread to integrate Liferay with MuleESB using LMB. I haven’t tried it yet but you can give it a try.
CMIS cloud connector can be used if you wants to synchronize Liferay document library. CMIS connector defines an abstraction layer for managing multiple document management systems and repositories using web protocols. read more about CMIS Connector.
In this article we are going to build simple example of Mule ESB integration with Liferay which post a tweet when a blog is published on Liferay.
Following task need to be performed in order to accomplish this example.
Create hook in liferay which hits Mule ESB HTTP endpoint.
Create Mule App flow to handle request from Liferay.
We are going to use below version of tools for this example
Twitter Connector 3.2.0
Mule ESB Server 3.5.0 CE
Let’s start with creating hook in liferay
We are going to create service wrapper hook to override Liferay’s blog publishing method. HTTPclient from hook will hit Mule HTTP endpoint with username of user who published blog, blog name and blog URL.
You can download war file for hook from attachment.
Second step is to create mule application to handle HTTP request from Liferay and post it to Twitter. Twitter app is necessary in order to communicate with the Twitter account from Mule ESB application. Follow steps described in this article to create Twitter application.
We will need following components and connectors HTTP endpoint, JSON to Object, Set Payload and Twitter Connector. Watch Video demo on Twitter Connector and read tutorial on Twitter Integration for more detail. Now configure flow as given in the below image to handle request and post tweet to the twitter. You can download mule application from attachment.
<twitter:config name="Twitter" accessKey="***************" accessSecret="**************" consumerKey="*********************" consumerSecret="****************" doc:name="Twitter"/>
<flow name="blogNotificationFlow">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="senduserdetail" doc:name="HTTP"/>
<json:json-to-object-transformer returnClass="java.lang.Object" doc:name="JSON to Object"/>
<set-payload value="#[message.payload.name] has published blog about #[message.payload.blogTitle] on http://surekhatech.com . Check it out. " doc:name="Set Payload"/>
<twitter:update-status config-ref="Twitter" status="#[payload]" doc:name="Twitter"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>
</mule>
Testing and Observation
Deploy the Liferay hook
Deploy the Mule application
Publish blog into Liferay.
If credentials are correct then mule will post tweet to the Twitter with blog name, blog url and user who posted blog. It will look like following image.
We use cookies to deliver personalized content, analyze trends, administer the site, track user movements on the site, and collect demographic information about our user base as a whole. Accept all cookies for the best possible experience on our website or manage your preferences.
What For?