15
Basic Example using FILE Connector in Anypoint Studio Prudhvi

Basic example using file connector in anypoint studio

Embed Size (px)

Citation preview

Page 1: Basic example using file connector in anypoint studio

Prudhvi

Basic Example using FILE

Connector in Anypoint Studio

Page 2: Basic example using file connector in anypoint studio

Prudhvi

Introduction The File connector allows your Mule

application to exchange files with a file system. You can implement the File connector as an inbound endpoint or as an outbound endpoint.

This endpoint implements a one-way exchange pattern only.

Page 3: Basic example using file connector in anypoint studio

Prudhvi

File Connector Basic Flow

Page 4: Basic example using file connector in anypoint studio

Prudhvi

Configuring File Connector

Page 5: Basic example using file connector in anypoint studio

Prudhvi

In File Connector Connection Configuring

Note: Auto Delete is optional

Page 6: Basic example using file connector in anypoint studio

Prudhvi

Set the PATH . If the file is needed set MOVE TO DIRECTORY also.

Set your required polling frequency and age

Page 7: Basic example using file connector in anypoint studio

Prudhvi

In Flow: Configuring the 1st Logger

To know what is coming ,we are printing the payload.

Page 8: Basic example using file connector in anypoint studio

Prudhvi

Configuring Transformer

No need to configure in this flow as the flow is sending a plain text.We need to configure the MIME Type as Text/Plain .

Page 9: Basic example using file connector in anypoint studio

2nd Logger

Prudhvi

Here to print the payload.Here the payload will be the characters in text file as we are converting byte to string by using transformer.

Page 10: Basic example using file connector in anypoint studio

Prudhvi

Text File

After running the application , Place this file in the path defined .The application will poll the file as per the polling frequency.

Page 11: Basic example using file connector in anypoint studio

Prudhvi

XML Configuration File<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:file="http://www.mulesoft.org/schema/mule/file"

xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"

xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" 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.6.1"

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/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd

http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd

http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-

ee.xsd">

<file:connector name="File" readFromDirectory="C:\Users\amma\Desktop\Read" autoDelete="true" streaming="true"

validateConnections="true" doc:name="File"/>

<flow name="BasicFileConnector">

<file:inbound-endpoint path="C:\Users\amma\Desktop\Read" connector-ref="File" responseTimeout="10000"

doc:name="File"/>

<logger message="#[payload]" level="INFO" doc:name="Logger"/>

<byte-array-to-string-transformer mimeType="text/plain" doc:name="Byte Array to String"/>

<logger message="#[payload]" level="INFO" doc:name="Logger"/>

</flow></mule>

Page 12: Basic example using file connector in anypoint studio

Prudhvi

Run the Application

Page 13: Basic example using file connector in anypoint studio

Prudhvi

Result

Successfully reading the file is completed as in the file the logger printed the text.

After the application has started ,place the file in the defined path.

Page 14: Basic example using file connector in anypoint studio

Prudhvi

Reference Mulesoft:

https://docs.mulesoft.com/mule-user-guide/v/3.7/file-connector

Page 15: Basic example using file connector in anypoint studio

Prudhvi

THANK YOU