You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by cmoulliard <cm...@gmail.com> on 2008/03/26 13:32:33 UTC

Use splitter strategy to send block of messages on the bus !

Hi,

I would like to know if it is possible or could be add as a new feature to
split a file containing thousands of records into several block of messages
(1 block can contain by example 100 records) using the splitter strategy ?

E.g.

From(file:///c:/temp?noop=true)
.splitter(ArrayList<Order>, 100)
.to(vm:queue:my-test-queue)

where 
ArrayList<Order> = collection of Order objects
100 = size of the records to be extracted from the file or from any other
origin

Why such request : performance and in order to avoid to send to the bus
objects or messages consuming too much memory.

Regards,

Charles
-- 
View this message in context: http://www.nabble.com/Use-splitter-strategy-to-send-block-of-messages-on-the-bus-%21-tp16300787s22882p16300787.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Use splitter strategy to send block of messages on the bus !

Posted by cmoulliard <cm...@gmail.com>.
James,

My idea was to split the content of the file during its parsing and to send
on the bus as many messages as block that we have. e.g. If my file contains
1.000 records, than the split will create 10 messages. Each message contain
100 records that next I will transform to a collection of POJO.

Regards,

Charles


James.Strachan wrote:
> 
> On 26/03/2008, cmoulliard <cm...@gmail.com> wrote:
>>
>>  Hi,
>>
>>  I would like to know if it is possible or could be add as a new feature
>> to
>>  split a file containing thousands of records into several block of
>> messages
>>  (1 block can contain by example 100 records) using the splitter strategy
>> ?
> 
> The current Splitter actually supports - provided you have some
> expression that can take the File and generate an iterator over it to
> create the individual message bodies you want to send.
> 
> So you could do something like...
> 
>   from("file:///c:/temp?noop=true)").
>     splitter().method("myBean", "split").
>     to("activemq:someQueue")
> 
> Then register "myBean" with a split method...
> 
> class SomeBean {
>   public Iterator split(File file) {
>      /// figure out how to split this file into rows...
>   }
> }
> 
> How were you planning on parsing/splitting the file?
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> Open Source Integration
> http://open.iona.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Use-splitter-strategy-to-send-block-of-messages-on-the-bus-%21-tp16300787s22882p16323599.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Use splitter strategy to send block of messages on the bus !

Posted by James Strachan <ja...@gmail.com>.
On 26/03/2008, cmoulliard <cm...@gmail.com> wrote:
>
>  Hi,
>
>  I would like to know if it is possible or could be add as a new feature to
>  split a file containing thousands of records into several block of messages
>  (1 block can contain by example 100 records) using the splitter strategy ?

The current Splitter actually supports - provided you have some
expression that can take the File and generate an iterator over it to
create the individual message bodies you want to send.

So you could do something like...

  from("file:///c:/temp?noop=true)").
    splitter().method("myBean", "split").
    to("activemq:someQueue")

Then register "myBean" with a split method...

class SomeBean {
  public Iterator split(File file) {
     /// figure out how to split this file into rows...
  }
}

How were you planning on parsing/splitting the file?

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com