camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diether <diether.wu...@optis.be>
Subject RE: From bind to bind
Date Tue, 07 May 2013 12:00:54 GMT
There is a camel component for dozer: http://camel.apache.org/dozer-type-conversion.html
It allows you to simply use .convertBodyTo(...)
No custom processor needed!

Regards,
Diether

________________________________
Van: jeff [via Camel] [ml-node+s465427n5732116h43@n5.nabble.com]
Verzonden: dinsdag 7 mei 2013 13:45
To: Wuyts Diether
Onderwerp: Re: From bind to bind

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 <[hidden email]<UrlBlockedError.aspx>>

> Ho By the way , I am using JRE 1.7 and CAMEL 2.11
>
>
> 2013/5/7 Jean Francois LE BESCONT <[hidden email]<UrlBlockedError.aspx>>
>
>> 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
>>
>
>


________________________________
If you reply to this email, your message will be added to the discussion below:
http://camel.465427.n5.nabble.com/From-bind-to-bind-tp5732109p5732116.html
To start a new topic under Camel - Users, email ml-node+s465427n465428h15@n5.nabble.com
To unsubscribe from Camel - Users, click here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=ZGlldGhlci53dXl0c0BvcHRpcy5iZXw0NjU0Mjh8OTE4NjI3OTg5>.
NAML<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>




--
View this message in context: http://camel.465427.n5.nabble.com/From-bind-to-bind-tp5732109p5732118.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message