I have found a trick with dozer :

<dependency>
<groupId>net.sf.dozer</groupId>
<artifactId>dozer</artifactId>
<version>5.4.0</version>
</dependency>


with a processor which convert from Ticket  to TicketOUT

new Processor() {

   public void process(Exchange exchange) throws Exception {
      Ticket ticket = (Ticket) exchange.getIn().getBody();
      TicketOUT ticketOUT = dozerBeanMapper.map(ticket, TicketOUT.class);
      exchange.getIn().setBody(ticketOUT);
}
})

With :

@CsvRecord(separator = ";" )
public class Ticket {

@DataField(pos = 1, required = true)
@Mapping("TCK_TYPE2")
public String TCK_TYPE;
[...]
}

And

@CsvRecord(separator = ";" )
public class TicketOUT {

@DataField(pos = 2, required = true)
public String TCK_TYPE2;

[...]
}


Not necessary the best intergration solution but it is fast and pretty
clean. With 20 fields per class, the route convert 68 000 body per second.

Jeff




2013/5/7 Jean Francois LE BESCONT <[email protected]>

> Ho By the way , I am using JRE 1.7 and CAMEL 2.11
>
>
> 2013/5/7 Jean Francois LE BESCONT <[email protected]>
>
>> Hi !
>>
>> I would like to know if someone has already found a clean solution to
>> this point.
>>
>> I have a directory with CSV file with :
>>
>> A;1
>> B;2
>> ...
>>
>> The bind is like :
>>
>> @CsvRecord(separator = ";" )
>> public class BindFileCSV {
>>
>> @DataField(pos = 1)
>> public String COL1;
>>
>> @DataField(pos = 2 )
>>  public String COL2;
>>
>> }
>>
>> Classic...
>>
>> i would like to bind output with differents schemas regarding to a header
>> value
>>
>>    from("file://C:/Temp/camel/rep1/?noop=true")
>>             .routeId("ROUTE_1")
>>             .id("ROUTE_1")
>>             .split().tokenize("\n")
>>             .streaming()
>>                 .unmarshal()
>>                 .bindy(BindyType.Csv, Ticket.class)
>>                 .choice()
>>                     .when( header("PROP").isEqualTo("1"))
>>                         .marshal()
>>                         .bindy(BindyType.Csv, TicketOUT1.class)
>>
>> .recipientList(simple("stream:file?fileName=C:/Temp/camel/rep1/out/yop.csv"))
>>                     .end()
>>                     .when( header("PROP").isEqualTo("2"))
>>     .marshal()
>>                         .bindy(BindyType.Csv, TicketOUT2.class)
>>
>> .recipientList(simple("stream:file?fileName=C:/Temp/camel/rep2/out/yop.csv"))
>>                     .end()
>>                     .otherwise()
>>
>>             .end()
>>             .log("fin")
>>         .end()
>>         ;
>>
>> I there an elegant way of to do the conversion from Ticket to TicketOUT1
>>  ?
>>
>> Thanks !
>>
>> JF
>>
>
>

Reply via email to