Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

MuleSoft ESB - CSV File to Database

2,225 views

Published on

Polling data from CSV and Insert records into DB

Published in: Education

MuleSoft ESB - CSV File to Database

  1. 1. MuleSoft ESB Transfer data from CSV File to Database By AKASH PRAJAPATI
  2. 2. Transfer data from CSV File to Database Topics : • How to work with Mule and transfer data from CSV file to database Pre-requisites : • Basic under standing of Mule ESB • JDK 1.8 or above • Anypoint Studio v 6.0.0 or above • MySQL connector • Mule Server v 3.8.0 EE or above • Create database & Schema or use existing one
  3. 3. Create DB Schema & Table • Create Table CREATE TABLE test.`EMP_DATA` ( `emp_id` int(11) DEFAULT NULL, `emp_first_name` varchar(50) DEFAULT NULL, `emp_last_name` varchar(50) DEFAULT NULL, `email` varchar(50) DEFAULT NULL, `dept_id` int(11) DEFAULT NULL, PRIMARY KEY (`emp_id`,`dept_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  4. 4. Process Flow
  5. 5. Component details • File : Define Source Path and Move to Directory with Polling frequency • Transformer ( Object to String ) : Nothing to do here, as it converts object to String internally • Splitter : Split multiples records (#[StringUtils.split(message.payload, 'nr')] ) • Expression : comma separated record (#[StringUtils.split(message.payload, ',')] ) • Choice : Validating the first row to make sure that there is no header, as expected in the CSV file. CSV File contains only related data and do not expect to have header row. • Valid condition: Invoke the Database insert flow • Default condition : Do not perform any action – Default logging. • DB Insert Flow: Each single record will be inserted into Database.
  6. 6. MySQL DB
  7. 7. CSV File Records Header Row : empId,empFirstname,empLastname,email,deptId
  8. 8. Records in Database : Employee Record
  9. 9. Thank You

×