You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by aruch <ar...@go.com> on 2009/02/03 01:17:32 UTC

Inject a new exchange based on event

Hello,

I'm using Camel 1.5.

I'm trying to find the best way to inject a new exchange based on the
existing exchange. For example, I have a processor. When the processor
receives an exchange and if the exchange matches the criteria, I would like
to send the original exchange AND a completely new exchange to the next
processor.

The closest example I can find is the Splitter processor, which gains this
functionality by extending the Multicast processor. Is extending the
Multicast processor the best/only way to do this? Isn't multicast designed
to send one exchange to multiple endpoints, not multiple exchanges to one
endpoint?

Will I be able to extend MulticastProcessor and still use Spring to create
my routes using the <bean> element?

Thanks,
Andy
-- 
View this message in context: http://www.nabble.com/Inject-a-new-exchange-based-on-event-tp21801537s22882p21801537.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Inject a new exchange based on event

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

If the next processor is able to consume such as "direct" or "seda"
endpoints then you can
just send the 2ND exchange to that.

from(x).process(mySpecialProcessor).to(direct:a).to(zzz)

And MySpecialProcessor implements Processor {

public void process(Exchange exchange) {
  // if special condition
 ProducerTemplate template =
exchange.getCamelContext().createProducerTemplate();
  template.start();
  template.send("direct:a", myNewExchange)
  template.stop();
}

Ahhh there is this FAQ
http://camel.apache.org/how-do-i-write-a-custom-processor-which-sends-multiple-messages.html

And this FAQ about you should invoke stop() on producer template when finished:
http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html


On Tue, Feb 3, 2009 at 1:17 AM, aruch <ar...@go.com> wrote:
>
> Hello,
>
> I'm using Camel 1.5.
>
> I'm trying to find the best way to inject a new exchange based on the
> existing exchange. For example, I have a processor. When the processor
> receives an exchange and if the exchange matches the criteria, I would like
> to send the original exchange AND a completely new exchange to the next
> processor.
>
> The closest example I can find is the Splitter processor, which gains this
> functionality by extending the Multicast processor. Is extending the
> Multicast processor the best/only way to do this? Isn't multicast designed
> to send one exchange to multiple endpoints, not multiple exchanges to one
> endpoint?
>
> Will I be able to extend MulticastProcessor and still use Spring to create
> my routes using the <bean> element?
>
> Thanks,
> Andy
> --
> View this message in context: http://www.nabble.com/Inject-a-new-exchange-based-on-event-tp21801537s22882p21801537.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/

Re: Inject a new exchange based on event

Posted by aruch <ar...@go.com>.
Upon further investigation, I don't think that I can write my own processor
by extending MulticastProcessor. Can I have a constructor that accepts a
destination processor as an argument? I don't think I have access to that in
Spring. Am I missing something?

Thanks,
Andy




aruch wrote:
> 
> Hello,
> 
> I'm using Camel 1.5.
> 
> I'm trying to find the best way to inject a new exchange based on the
> existing exchange. For example, I have a processor. When the processor
> receives an exchange and if the exchange matches the criteria, I would
> like to send the original exchange AND a completely new exchange to the
> next processor.
> 
> The closest example I can find is the Splitter processor, which gains this
> functionality by extending the Multicast processor. Is extending the
> Multicast processor the best/only way to do this? Isn't multicast designed
> to send one exchange to multiple endpoints, not multiple exchanges to one
> endpoint?
> 
> Will I be able to extend MulticastProcessor and still use Spring to create
> my routes using the <bean> element?
> 
> Thanks,
> Andy
> 

-- 
View this message in context: http://www.nabble.com/Inject-a-new-exchange-based-on-event-tp21801537s22882p21814422.html
Sent from the Camel - Users mailing list archive at Nabble.com.