I added this to the FAQ - as its something I've often wondered about...
http://cwiki.apache.org/CAMEL/how-do-i-write-a-custom-processor-which-sends-multiple-messages.html
2008/6/23 James Strachan <[EMAIL PROTECTED]>:
> BTW you could always write a custom processor which is injected with a
> ProducerTemplate instance that just generates N messages...
>
> class MyProcessor implements Processor {
> ProducerTemplate<Exchange> producer;
>
> public Exchange process(Exchange inExchange) {
> // some loop for each message
> for (String template in templates) {
> // lets send a new exchange to the default destination
> // being called back so we can customize the message
> producer.send(new Processor() {
> public Exchange process(Exchange outExchange) {
> outExchange.getIn().setBody("This is the body");
> // set some headers too?
> }
> });
> }
> }
>
> Then the ProducerTemplate can be injected - configured in spring.xml
> with its default URI
>
> <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
> <template id="myTemplate" defaultEndpoint="activemq:someQueue"/>
> </camelContext>
>
> You could also if you choose, specify the exact output URI in your
> producer.send() method call if you want.
>
> <bean id="foo" class="MyProducer">
> <property name="producer" ref="myTemplate"/>
> </bean>
>
>
> Just thought - we need an IntelliJ plugin for Gmail so its easy to
> write code snippets in an email :)
>
>
>
>
>
>
>
> 2008/6/23 greenbean <[EMAIL PROTECTED]>:
>>
>> I have a need to take the XML payload from a message in a queue, duplicate it
>> X times based on a configuration, modify the value of an element for each
>> message to a different value, and send each to the same destination.
>>
>> It seem like based on the documentation I want something like a splitter
>> (actually a duplicator) in conjunction with a content enricher. What
>> patterns would you suggest to implement this?
>>
>> Thanks.
>> --
>> View this message in context:
>> http://www.nabble.com/Message-Duplicator-tp18062628s22882p18062628.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://open.iona.com
>
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com