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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

inserted few records in to database as

INSERT INTO `mulesupport`.`moviedetails`
(`movieCode`,
`movieName`,
`director`,
`hero`,
`releaseDate`,
`status`)
VALUES
(<{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

db_select

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=”http://www.mulesoft.org/schema/mule/http&#8221; xmlns:tracking=”http://www.mulesoft.org/schema/mule/ee/tracking&#8221; xmlns=”http://www.mulesoft.org/schema/mule/core&#8221; xmlns:doc=”http://www.mulesoft.org/schema/mule/documentation&#8221;
xmlns:spring=”http://www.springframework.org/schema/beans&#8221;
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
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
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd”&gt;
<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″/>
</async>
<logger message=”In Flow1 after referncing flow2″ level=”INFO” doc:name=”Logger”/>
</flow>
<flow name=”flow-2″>
<component class=”syncasync.MyObj” doc:name=”Java”/>
<logger message=”In Flow2 executing the flow” level=”INFO” doc:name=”Logger”/>
</flow>
</mule>

Please find the demo projects available  at day-5 zip

https://drive.google.com/drive/folders/0B7kdTdRlWaF_TVhOaTk1cDVEYzQ

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s