Create dynamic file Name in mediation component cSplitter?

Five Stars

Create dynamic file Name in mediation component cSplitter?

Hi

I am new to Talend. I want to create a dynamic name for writing the files. The flow is like cFile is consuming Four files from the directory then aggregate to one File on the basis of the file name and in cProcessor again  get the list of file name and folllowed by csplitter and then again cfile genertaes 4 files with source file name and the body.

here is the code for cProcessor:

     

 

List<String> fileList = new ArrayList<String>();
fileList = (List<String>)exchange.getProperty("CamelFileName");
System.out.println("After aggregation the fileName: "+
fileList);

List<String> listBody = new ArrayList<String>();
listBody = (List<String>)exchange.getProperty("body");
System.out.println("After aggregation the body: "+ listBody);


 exchange.setProperty("FileName",fileList);

Eight Stars

Re: Create dynamic file Name in mediation component cSplitter?

You should use a java bean and use a static list of string to store your filenames, then after the split, according to the message number (1,2,3 or 4) set it the name in the list (the correct header is CamelFileName)

15TH OCTOBER, COUNTY HALL, LONDON

Join us at the Community Lounge.

Register Now

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

An API-First Approach to Modernizing Applications

Learn how to use an API-First Approach to Modernize your Applications

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now