Re: How to relay different parts of message to different endpoints

2014-08-26 Thread dermoritz
shit happens here the link: http://stackoverflow.com/questions/25488026/split-csv-file-by-number-of-fields-each-line-different-to-different-target-end -- View this message in context: http://camel.465427.n5.nabble.com/How-to-relay-different-parts-of-message-to-different-endpoints-tp5754836p5755

Re: How to relay different parts of message to different endpoints

2014-08-26 Thread dermoritz
for sake of completeness here a link to stackoverflow, my answer is based on pkmcculloch's solution the accepted answer is another way. -- View this message in context: http://camel.465427.n5.nabble.com/How-to-relay-different-parts-of-message-to-different-endpoints-tp5754836p5755679.html Sent

Re: How to relay different parts of message to different endpoints

2014-08-25 Thread dermoritz
Thanks, the problem with this solution is i need a 2nd processor or a custom predicate that could be used in choice().when(). Since each "pair" must be routed to a different set of endpoints i need the "when" to use the integer. I think it would be much better to let the first producer just send

Re: How to relay different parts of message to different endpoints

2014-08-07 Thread Paul McCulloch
You could implement this in many different ways. One example would be List> or just declare your own class with a count of fields & a byte[]. I think a custom splitter looks like a much neater solution though. On 7 August 2014 09:20, dermoritz wrote: > Thanks > but please tell what this is "Li

Re: How to relay different parts of message to different endpoints

2014-08-07 Thread dermoritz
Thanks but please tell what this is "List of pairs (fieldcount,byte[])" or how to create it and use with splitter? -- View this message in context: http://camel.465427.n5.nabble.com/How-to-relay-different-parts-of-message-to-different-endpoints-tp5754836p5754882.html Sent from the Camel - User

Re: How to relay different parts of message to different endpoints

2014-08-06 Thread Paul McCulloch
I guess you could return a List of pairs (fieldcount,byte[]), then split & then use the CBR to look at the field count & dispatch accordingly. A simpler approach would be to do what the MySplitterBean example does in http://camel.apache.org/splitter.html. In your case return the byte[] in each of

Re: How to relay different parts of message to different endpoints

2014-08-06 Thread dermoritz
process() is a void method but do you mean instead of a byte[] i just List into "exchange.getOut().setBody(returnVal)? The split would then automatically split into 2 byte[]? but how to know the number of fields in each one? -- View this message in context: http://camel.465427.n5.nabble.com/Ho

Re: How to relay different parts of message to different endpoints

2014-08-06 Thread Paul McCulloch
If your processor does something like byte[] a = ... byte[] b = ... List returnVal = new ... returnVal.add(a); returnVal.add(b); return returnVal Then you can use split(body()) to get one message for each of your byte[] On 6 August 2014 14:49, Paul McCulloch wrote: >

Re: How to relay different parts of message to different endpoints

2014-08-06 Thread Paul McCulloch
If your processor does: On 6 August 2014 14:45, dermoritz wrote: > How to do this? The 2 byte[] are created into a processor. I have to > create 2 > byte[] from one byte[] and i don't want to read the input byte[] twice. > > In meantime i found: > > http://camel.apache.org/how-do-i-write-a-cus

Re: How to relay different parts of message to different endpoints

2014-08-06 Thread dermoritz
How to do this? The 2 byte[] are created into a processor. I have to create 2 byte[] from one byte[] and i don't want to read the input byte[] twice. In meantime i found: http://camel.apache.org/how-do-i-write-a-custom-processor-which-sends-multiple-messages.html with this i think i can create 2

Re: How to relay different parts of message to different endpoints

2014-08-06 Thread Paul McCulloch
Use split() to turn your 2 byte[] in to two messages? On 6 August 2014 14:08, dermoritz wrote: > From unmarshal().gzip() comes a byte[] (with mixed number of fields in each > line). > > My processor scans the byte[] line by line some lines have 35 ',' some have > 65 ',' and i want to scan each

Re: How to relay different parts of message to different endpoints

2014-08-06 Thread dermoritz
>From unmarshal().gzip() comes a byte[] (with mixed number of fields in each line). My processor scans the byte[] line by line some lines have 35 ',' some have 65 ',' and i want to scan each byte[] only once. So i create 2 byte arrays one with 35er lines and one with 65er lines. My question is wha

Re: How to relay different parts of message to different endpoints

2014-08-06 Thread Walzer, Thomas
You don´t have to unmarshal the csv. As long as your processor sets the header („numberOfFields“) correctly (eg by counting the number of “,“) you can afterwards use choice to route to the appropriate endpoints. No need to create 2 byte[]. Your processor emits everything and you filter afterwards

Re: How to relay different parts of message to different endpoints

2014-08-06 Thread dermoritz
Thanks, in my case i don't want to use unmarchal().csv() because i don't need the lines to be split (complet csv lines will be sent to "to"). So my route i something like this: from("file:src/test/resources/?fileName=foo.csv&noop=true"). unmarshal().gz(). // body is byte[] at the moment my

Re: How to relay different parts of message to different endpoints

2014-08-06 Thread Paul McCulloch
How about something along the lines of: from("file:src/test/resources/?fileName=foo.csv&noop=true"). unmarshal().csv(). split(body()). setHeader("numberOfFields", bean("FieldCounter")). choice(). when(header("numberOfFields").isEqualTo(34) .to("direct:a"

Re: How to relay different parts of message to different endpoints

2014-08-06 Thread dermoritz
Thanks for this hint but how to implement the processor that splits to 2 types: if i scan through the file i'll end up with 2 messages/blocks (1 for each content type). So how to implement the splitting - create 2 exchanges (for each content type) from on exchange (1 csv file). Is there a way that

Re: How to relay different parts of message to different endpoints

2014-08-06 Thread Paul McCulloch
Perhaps, rather than filtering, your processor could just add a header which states the number of fields in the file. You could then use Filter & Content Based Router to send the messages to the appropriate place? On 6 August 2014 10:18, dermoritz wrote: > I have to handle csv (gz compressed) f