Message Duplicator

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Message Duplicator

Greenbean
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.
Reply | Threaded
Open this post in threaded view
|

Re: Message Duplicator

jstrachan
2008/6/23 greenbean <[hidden email]>:
> 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?

Yeah it could be a splitter. Really the splitter doesn't have to
generate a subset of the original message - its just intended to take
a message and generate N messages to be sent on.

Another approach is to just have N tranforms?

I guess it depends on how you want to implement each of these transforms.

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

Open Source Integration
http://open.iona.com
Reply | Threaded
Open this post in threaded view
|

Re: Message Duplicator

jstrachan
In reply to this post by Greenbean
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 <[hidden email]>:

>
> 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
Reply | Threaded
Open this post in threaded view
|

Re: Message Duplicator

jstrachan
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 <[hidden email]>:

> 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 <[hidden email]>:
>>
>> 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