camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Johan Haleby <johan.hal...@gmail.com>
Subject Re: Intercept a processor?
Date Tue, 12 Jan 2010 18:06:59 GMT

Hi,

Thanks for your quick response. Sorry for not mentioning it in the previous
mail but I'm using Camel 2.1 just as you suspected. Unfortunately the first
solution you posted (using async send and latches) won't work "out of the
box" for me because the producer template is wrapped in an anti-corruption
layer and the test should use this anti-corruption layer to send the
message.

I'll look into your suggestion by subscribing to the ExchangeDoneEvent. Is
there anywhere I can find some documentation or example of how to do this?
Or was it this that you went through in chapter 6 in the book?

I look forward to the changes you mention in version 2.2, seems really
useful and looks to fit very well with what I'm trying to do here. Is there
an expected date when 2.2 may be available?

Regards,
/Johan

The first option won't work 

Claus Ibsen-2 wrote:
> 
> On Tue, Jan 12, 2010 at 5:56 PM, Johan Haleby <johan.haleby@gmail.com>
> wrote:
>>
>> Hi,
>>
>> I'm configuring routes using the Java DSL and it works very well. However
>> during testing I'd like to somehow hook into the end of an already
>> defined
>> route to add notification support. The reason is that in my test I'm
>> creating a message and pass it to a queue using Camel and this message is
>> handled by a processor. After this processor has finished executing I'd
>> like
>> to receive some sort of notification but only during testing. The reason
>> is
>> that I'd like my test to wait until the processor has finished executing
>> in
>> my test case so that I can verify the result of the processor. For
>> example:
>>
>> public void test() {
>>  1. send a message to queue // just as you would in production
>>  2. wait for the processor to finish // this is where I'd like to get a
>> notification that the processor has finished so that it's ok to continue
>> to
>> the next step
>>  3. verify result
>> }
>>
>> The route may look something like:
>> from("jms:queue:myqueue).process(new MyProcessor()); // A simplification
>> of
>> the production route
>>
>> Is there a preferred way of doing this in Camel without changing the code
>> making up the "production route"? Or is there a better way to achieve it?
>>
> 
> Chapter 6 in the book go over this issue and how to address that:
> http://www.manning.com/ibsen/ (will be updated in next MEAP due this
> month)
> 
> However we made it easier to do nice and easy from an unit test in 2.2
> which I assume is not the version of Camel you are using.
> In 2.2 you can advice and route by adding additional cross cutting
> concerns such as onCompletion, interceptors etc. which you would then
> be able to use to know when its done.
> 
> In Camel 2.1 you got the EventNotification which you actually can use
> for that to get notified when an Exchange is done as it emits a
> ExchangeDoneEvent.
> I am currently improving that for 2.2 to let you filter out of the box
> the notifier so you only receive interesting events. But that should
> not hold you back from using that in 2.1.
> 
> We may improve this situation even more to make it easy as it can get
> for testing production routes with test methods. So kinda inject mocks
> at end of routes etc. so you can use that to verify behavior etc.
> 
> 
>> /Johan
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Intercept-a-processor--tp27130672p27130672.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://old.nabble.com/Intercept-a-processor--tp27130672p27131142.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message