camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Intercept a processor?
Date Tue, 12 Jan 2010 17:08:57 GMT
Hi

Ah forgot about the producer template which got methods for callback
when an Exchange is done.

For example this one where onDone is invoked when the Exchange is
done, which allows you to know when its complete and continue your
test.


        final CountDownLatch latch = new CountDownLatch(1);

        template.asyncCallbackSendBody("direct:start", "Hello", new
SynchronizationAdapter() {
            @Override
            public void onDone(Exchange exchange) {
                order += "B";
                assertEquals("Hello World", exchange.getIn().getBody());
                latch.countDown();
            }
        });

        order += "A";
        latch.await(10, TimeUnit.SECONDS);
        order += "C";



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?
>
> /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

Mime
View raw message