You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Claus Ibsen <cl...@gmail.com> on 2009/11/24 13:48:30 UTC

Re: Cannot intercept from another DSL-route def. in the same camel context

Hi

Its per route builder only.

There is a ticket about adding a "template" kinda routes which you can
import from other routes.
Its still work in progress. Although in Camel 2.1 Java DSL you can do
an importRoutes AFAIR in the route builder.

There is a ticket in JIRA about the "template" thingy.


On Tue, Nov 24, 2009 at 1:25 PM, shirazi <me...@farhad.eu> wrote:
>
> Hi,
> When I move my interceptor definitions from my main RouteBuilder def. to
> another RouteBuilder def., both in the same camel-context, then they cease
> to work.
> Consider the following set up, which works perfectly:
>
> // Main Route def.
> public class MyRoutes extends RouteBuilder {
>        @Override
>        public void configure() throws Exception {
>                interceptSendToEndpoint("file:///tmp/archive*").
>                to("mock:archive");
>
>                from("file:///tmp/start").
>                to("file:///tmp/archive");
>        }
> }
>
> // Another Route def.
> public class MyTestRoutes extends RouteBuilder {
>        @Override
>        public void configure() throws Exception {
>                // nothing
>        }
> }
>
> // applicationContext.xml
> .....
>        <context:component-scan base-package="com.nordija.itv.vod.workflow" />
>
>        <bean id="myRoutes" class="com.nordija.itv.vod.workflow.MyRoutes"/>
>        <bean id="myTestRoutes" class="com.nordija.itv.vod.workflow.MyTestRoutes"/>
>
>        <camel:camelContext id="test">
>                <camel:routeBuilder ref="myRoutes" />
>                <camel:routeBuilder ref="myTestRoutes"/>
>        </camel:camelContext>
> .....
>
> // Test class. works fine, as long as the interceptor def. is in MyRoutes
> class
> public class TestMyRoutes extends SpringTestSupport {
>        public void testCMoreFlow() throws Exception{
>                Thread.sleep(5000);
>                MockEndpoint archiveEndpoint = getMockEndpoint("mock:archive");
>                archiveEndpoint.expectedMessageCount(1);
>                Exchange archExc = archiveEndpoint.getExchanges().get(0);
>                assertEquals(archExc.getIn().getHeader("CamelFileNameOnly"), fileName);
>
> assertEquals(((Long)archExc.getIn().getHeader("CamelFileLength")).longValue(),
> originalFileSize);
>                archiveEndpoint.assertIsSatisfied();
>        }
> .....
> }
>
> -----------------
> Now if I move the interceptor defined in MyRoutes to the MyTestRoutes class,
> then nothing gets intercepted. Why's that?
>
> Regards,
> -Farhad Shirazi
> --
> View this message in context: http://old.nabble.com/Cannot-intercept-from-another-DSL-route-def.-in-the-same-camel-context-tp26495020p26495020.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

Re: Cannot intercept from another DSL-route def. in the same camel context

Posted by shirazi <me...@farhad.eu>.
Thanks a lot Claus. "adviceWith" is exactly what I was looking for. I guess I
need to upgrade to camel 2.1-SNAPSHOT.
I realy appreciate your help.

Bests,
-Farhad Shirazi


Claus Ibsen-2 wrote:
> 
> On Tue, Nov 24, 2009 at 2:15 PM, Claus Ibsen <cl...@gmail.com>
> wrote:
>> On Tue, Nov 24, 2009 at 2:02 PM, shirazi <me...@farhad.eu> wrote:
>>>
>>> Ok. Being able to import other routes would be very useful, specially
>>> for
>>> setting up various test scenarios.
>>>
>>
>> Yeah but we got another treat for that in 2.1 which is adviceWith
>> which I cover in the book as well in the testing chapter.
>> For now you can check out the source code for examples as there are
>> unit tests in camel-core using this.
>>
>> I plan to write about adviceWith in a blog entry when I also have a
>> bit docu at the camel site in a couple of weeks.
>>
> 
> Or check out the code in chapter 9 in the Camel in Action source code
> hosted at
> http://code.google.com/p/camelinaction/
> 
>>
>>> Thanks very much for your reply,
>>> -Farhad Shirazi
>>>
>>>
>>> Claus Ibsen-2 wrote:
>>>>
>>>> Hi
>>>>
>>>> Its per route builder only.
>>>>
>>>> There is a ticket about adding a "template" kinda routes which you can
>>>> import from other routes.
>>>> Its still work in progress. Although in Camel 2.1 Java DSL you can do
>>>> an importRoutes AFAIR in the route builder.
>>>>
>>>> There is a ticket in JIRA about the "template" thingy.
>>>>
>>>>
>>>> On Tue, Nov 24, 2009 at 1:25 PM, shirazi <me...@farhad.eu> wrote:
>>>>>
>>>>> Hi,
>>>>> When I move my interceptor definitions from my main RouteBuilder def.
>>>>> to
>>>>> another RouteBuilder def., both in the same camel-context, then they
>>>>> cease
>>>>> to work.
>>>>> Consider the following set up, which works perfectly:
>>>>>
>>>>> // Main Route def.
>>>>> public class MyRoutes extends RouteBuilder {
>>>>>        @Override
>>>>>        public void configure() throws Exception {
>>>>>                interceptSendToEndpoint("file:///tmp/archive*").
>>>>>                to("mock:archive");
>>>>>
>>>>>                from("file:///tmp/start").
>>>>>                to("file:///tmp/archive");
>>>>>        }
>>>>> }
>>>>>
>>>>> // Another Route def.
>>>>> public class MyTestRoutes extends RouteBuilder {
>>>>>        @Override
>>>>>        public void configure() throws Exception {
>>>>>                // nothing
>>>>>        }
>>>>> }
>>>>>
>>>>> // applicationContext.xml
>>>>> .....
>>>>>        <context:component-scan
>>>>> base-package="com.nordija.itv.vod.workflow" />
>>>>>
>>>>>        <bean id="myRoutes"
>>>>> class="com.nordija.itv.vod.workflow.MyRoutes"/>
>>>>>        <bean id="myTestRoutes"
>>>>> class="com.nordija.itv.vod.workflow.MyTestRoutes"/>
>>>>>
>>>>>        <camel:camelContext id="test">
>>>>>                <camel:routeBuilder ref="myRoutes" />
>>>>>                <camel:routeBuilder ref="myTestRoutes"/>
>>>>>        </camel:camelContext>
>>>>> .....
>>>>>
>>>>> // Test class. works fine, as long as the interceptor def. is in
>>>>> MyRoutes
>>>>> class
>>>>> public class TestMyRoutes extends SpringTestSupport {
>>>>>        public void testCMoreFlow() throws Exception{
>>>>>                Thread.sleep(5000);
>>>>>                MockEndpoint archiveEndpoint =
>>>>> getMockEndpoint("mock:archive");
>>>>>                archiveEndpoint.expectedMessageCount(1);
>>>>>                Exchange archExc =
>>>>> archiveEndpoint.getExchanges().get(0);
>>>>>
>>>>>  assertEquals(archExc.getIn().getHeader("CamelFileNameOnly"),
>>>>> fileName);
>>>>>
>>>>> assertEquals(((Long)archExc.getIn().getHeader("CamelFileLength")).longValue(),
>>>>> originalFileSize);
>>>>>                archiveEndpoint.assertIsSatisfied();
>>>>>        }
>>>>> .....
>>>>> }
>>>>>
>>>>> -----------------
>>>>> Now if I move the interceptor defined in MyRoutes to the MyTestRoutes
>>>>> class,
>>>>> then nothing gets intercepted. Why's that?
>>>>>
>>>>> Regards,
>>>>> -Farhad Shirazi
>>>>> --
>>>>> View this message in context:
>>>>> http://old.nabble.com/Cannot-intercept-from-another-DSL-route-def.-in-the-same-camel-context-tp26495020p26495020.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/Cannot-intercept-from-another-DSL-route-def.-in-the-same-camel-context-tp26495020p26495481.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
>>
> 
> 
> 
> -- 
> 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/Cannot-intercept-from-another-DSL-route-def.-in-the-same-camel-context-tp26495020p26499926.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Cannot intercept from another DSL-route def. in the same camel context

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Nov 24, 2009 at 2:15 PM, Claus Ibsen <cl...@gmail.com> wrote:
> On Tue, Nov 24, 2009 at 2:02 PM, shirazi <me...@farhad.eu> wrote:
>>
>> Ok. Being able to import other routes would be very useful, specially for
>> setting up various test scenarios.
>>
>
> Yeah but we got another treat for that in 2.1 which is adviceWith
> which I cover in the book as well in the testing chapter.
> For now you can check out the source code for examples as there are
> unit tests in camel-core using this.
>
> I plan to write about adviceWith in a blog entry when I also have a
> bit docu at the camel site in a couple of weeks.
>

Or check out the code in chapter 9 in the Camel in Action source code hosted at
http://code.google.com/p/camelinaction/

>
>> Thanks very much for your reply,
>> -Farhad Shirazi
>>
>>
>> Claus Ibsen-2 wrote:
>>>
>>> Hi
>>>
>>> Its per route builder only.
>>>
>>> There is a ticket about adding a "template" kinda routes which you can
>>> import from other routes.
>>> Its still work in progress. Although in Camel 2.1 Java DSL you can do
>>> an importRoutes AFAIR in the route builder.
>>>
>>> There is a ticket in JIRA about the "template" thingy.
>>>
>>>
>>> On Tue, Nov 24, 2009 at 1:25 PM, shirazi <me...@farhad.eu> wrote:
>>>>
>>>> Hi,
>>>> When I move my interceptor definitions from my main RouteBuilder def. to
>>>> another RouteBuilder def., both in the same camel-context, then they
>>>> cease
>>>> to work.
>>>> Consider the following set up, which works perfectly:
>>>>
>>>> // Main Route def.
>>>> public class MyRoutes extends RouteBuilder {
>>>>        @Override
>>>>        public void configure() throws Exception {
>>>>                interceptSendToEndpoint("file:///tmp/archive*").
>>>>                to("mock:archive");
>>>>
>>>>                from("file:///tmp/start").
>>>>                to("file:///tmp/archive");
>>>>        }
>>>> }
>>>>
>>>> // Another Route def.
>>>> public class MyTestRoutes extends RouteBuilder {
>>>>        @Override
>>>>        public void configure() throws Exception {
>>>>                // nothing
>>>>        }
>>>> }
>>>>
>>>> // applicationContext.xml
>>>> .....
>>>>        <context:component-scan
>>>> base-package="com.nordija.itv.vod.workflow" />
>>>>
>>>>        <bean id="myRoutes"
>>>> class="com.nordija.itv.vod.workflow.MyRoutes"/>
>>>>        <bean id="myTestRoutes"
>>>> class="com.nordija.itv.vod.workflow.MyTestRoutes"/>
>>>>
>>>>        <camel:camelContext id="test">
>>>>                <camel:routeBuilder ref="myRoutes" />
>>>>                <camel:routeBuilder ref="myTestRoutes"/>
>>>>        </camel:camelContext>
>>>> .....
>>>>
>>>> // Test class. works fine, as long as the interceptor def. is in MyRoutes
>>>> class
>>>> public class TestMyRoutes extends SpringTestSupport {
>>>>        public void testCMoreFlow() throws Exception{
>>>>                Thread.sleep(5000);
>>>>                MockEndpoint archiveEndpoint =
>>>> getMockEndpoint("mock:archive");
>>>>                archiveEndpoint.expectedMessageCount(1);
>>>>                Exchange archExc = archiveEndpoint.getExchanges().get(0);
>>>>
>>>>  assertEquals(archExc.getIn().getHeader("CamelFileNameOnly"), fileName);
>>>>
>>>> assertEquals(((Long)archExc.getIn().getHeader("CamelFileLength")).longValue(),
>>>> originalFileSize);
>>>>                archiveEndpoint.assertIsSatisfied();
>>>>        }
>>>> .....
>>>> }
>>>>
>>>> -----------------
>>>> Now if I move the interceptor defined in MyRoutes to the MyTestRoutes
>>>> class,
>>>> then nothing gets intercepted. Why's that?
>>>>
>>>> Regards,
>>>> -Farhad Shirazi
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/Cannot-intercept-from-another-DSL-route-def.-in-the-same-camel-context-tp26495020p26495020.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/Cannot-intercept-from-another-DSL-route-def.-in-the-same-camel-context-tp26495020p26495481.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
>



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

Re: Cannot intercept from another DSL-route def. in the same camel context

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Nov 24, 2009 at 2:02 PM, shirazi <me...@farhad.eu> wrote:
>
> Ok. Being able to import other routes would be very useful, specially for
> setting up various test scenarios.
>

Yeah but we got another treat for that in 2.1 which is adviceWith
which I cover in the book as well in the testing chapter.
For now you can check out the source code for examples as there are
unit tests in camel-core using this.

I plan to write about adviceWith in a blog entry when I also have a
bit docu at the camel site in a couple of weeks.


> Thanks very much for your reply,
> -Farhad Shirazi
>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> Its per route builder only.
>>
>> There is a ticket about adding a "template" kinda routes which you can
>> import from other routes.
>> Its still work in progress. Although in Camel 2.1 Java DSL you can do
>> an importRoutes AFAIR in the route builder.
>>
>> There is a ticket in JIRA about the "template" thingy.
>>
>>
>> On Tue, Nov 24, 2009 at 1:25 PM, shirazi <me...@farhad.eu> wrote:
>>>
>>> Hi,
>>> When I move my interceptor definitions from my main RouteBuilder def. to
>>> another RouteBuilder def., both in the same camel-context, then they
>>> cease
>>> to work.
>>> Consider the following set up, which works perfectly:
>>>
>>> // Main Route def.
>>> public class MyRoutes extends RouteBuilder {
>>>        @Override
>>>        public void configure() throws Exception {
>>>                interceptSendToEndpoint("file:///tmp/archive*").
>>>                to("mock:archive");
>>>
>>>                from("file:///tmp/start").
>>>                to("file:///tmp/archive");
>>>        }
>>> }
>>>
>>> // Another Route def.
>>> public class MyTestRoutes extends RouteBuilder {
>>>        @Override
>>>        public void configure() throws Exception {
>>>                // nothing
>>>        }
>>> }
>>>
>>> // applicationContext.xml
>>> .....
>>>        <context:component-scan
>>> base-package="com.nordija.itv.vod.workflow" />
>>>
>>>        <bean id="myRoutes"
>>> class="com.nordija.itv.vod.workflow.MyRoutes"/>
>>>        <bean id="myTestRoutes"
>>> class="com.nordija.itv.vod.workflow.MyTestRoutes"/>
>>>
>>>        <camel:camelContext id="test">
>>>                <camel:routeBuilder ref="myRoutes" />
>>>                <camel:routeBuilder ref="myTestRoutes"/>
>>>        </camel:camelContext>
>>> .....
>>>
>>> // Test class. works fine, as long as the interceptor def. is in MyRoutes
>>> class
>>> public class TestMyRoutes extends SpringTestSupport {
>>>        public void testCMoreFlow() throws Exception{
>>>                Thread.sleep(5000);
>>>                MockEndpoint archiveEndpoint =
>>> getMockEndpoint("mock:archive");
>>>                archiveEndpoint.expectedMessageCount(1);
>>>                Exchange archExc = archiveEndpoint.getExchanges().get(0);
>>>
>>>  assertEquals(archExc.getIn().getHeader("CamelFileNameOnly"), fileName);
>>>
>>> assertEquals(((Long)archExc.getIn().getHeader("CamelFileLength")).longValue(),
>>> originalFileSize);
>>>                archiveEndpoint.assertIsSatisfied();
>>>        }
>>> .....
>>> }
>>>
>>> -----------------
>>> Now if I move the interceptor defined in MyRoutes to the MyTestRoutes
>>> class,
>>> then nothing gets intercepted. Why's that?
>>>
>>> Regards,
>>> -Farhad Shirazi
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Cannot-intercept-from-another-DSL-route-def.-in-the-same-camel-context-tp26495020p26495020.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/Cannot-intercept-from-another-DSL-route-def.-in-the-same-camel-context-tp26495020p26495481.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

Re: Cannot intercept from another DSL-route def. in the same camel context

Posted by shirazi <me...@farhad.eu>.
Ok. Being able to import other routes would be very useful, specially for
setting up various test scenarios.

Thanks very much for your reply,
-Farhad Shirazi


Claus Ibsen-2 wrote:
> 
> Hi
> 
> Its per route builder only.
> 
> There is a ticket about adding a "template" kinda routes which you can
> import from other routes.
> Its still work in progress. Although in Camel 2.1 Java DSL you can do
> an importRoutes AFAIR in the route builder.
> 
> There is a ticket in JIRA about the "template" thingy.
> 
> 
> On Tue, Nov 24, 2009 at 1:25 PM, shirazi <me...@farhad.eu> wrote:
>>
>> Hi,
>> When I move my interceptor definitions from my main RouteBuilder def. to
>> another RouteBuilder def., both in the same camel-context, then they
>> cease
>> to work.
>> Consider the following set up, which works perfectly:
>>
>> // Main Route def.
>> public class MyRoutes extends RouteBuilder {
>>        @Override
>>        public void configure() throws Exception {
>>                interceptSendToEndpoint("file:///tmp/archive*").
>>                to("mock:archive");
>>
>>                from("file:///tmp/start").
>>                to("file:///tmp/archive");
>>        }
>> }
>>
>> // Another Route def.
>> public class MyTestRoutes extends RouteBuilder {
>>        @Override
>>        public void configure() throws Exception {
>>                // nothing
>>        }
>> }
>>
>> // applicationContext.xml
>> .....
>>        <context:component-scan
>> base-package="com.nordija.itv.vod.workflow" />
>>
>>        <bean id="myRoutes"
>> class="com.nordija.itv.vod.workflow.MyRoutes"/>
>>        <bean id="myTestRoutes"
>> class="com.nordija.itv.vod.workflow.MyTestRoutes"/>
>>
>>        <camel:camelContext id="test">
>>                <camel:routeBuilder ref="myRoutes" />
>>                <camel:routeBuilder ref="myTestRoutes"/>
>>        </camel:camelContext>
>> .....
>>
>> // Test class. works fine, as long as the interceptor def. is in MyRoutes
>> class
>> public class TestMyRoutes extends SpringTestSupport {
>>        public void testCMoreFlow() throws Exception{
>>                Thread.sleep(5000);
>>                MockEndpoint archiveEndpoint =
>> getMockEndpoint("mock:archive");
>>                archiveEndpoint.expectedMessageCount(1);
>>                Exchange archExc = archiveEndpoint.getExchanges().get(0);
>>              
>>  assertEquals(archExc.getIn().getHeader("CamelFileNameOnly"), fileName);
>>
>> assertEquals(((Long)archExc.getIn().getHeader("CamelFileLength")).longValue(),
>> originalFileSize);
>>                archiveEndpoint.assertIsSatisfied();
>>        }
>> .....
>> }
>>
>> -----------------
>> Now if I move the interceptor defined in MyRoutes to the MyTestRoutes
>> class,
>> then nothing gets intercepted. Why's that?
>>
>> Regards,
>> -Farhad Shirazi
>> --
>> View this message in context:
>> http://old.nabble.com/Cannot-intercept-from-another-DSL-route-def.-in-the-same-camel-context-tp26495020p26495020.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/Cannot-intercept-from-another-DSL-route-def.-in-the-same-camel-context-tp26495020p26495481.html
Sent from the Camel - Users mailing list archive at Nabble.com.