You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Joël Guelluy <jg...@skynet.be.INVALID> on 2023/04/27 09:03:01 UTC

spring-main & addRoutesBuilder : don't work together ?

Hello,

I'm in migration of a program Came 2.25 to 3.18.6, and there is 
something i can't fix.
It seems like camel-spring-main & addRoutesBuilder can't work 
together... (i'm probably missing something...)

springcontext.xml
<camel:camelContext id="camel" 
xmlns="http://camel.apache.org/schema/spring">
</camel:camelContext>

MyMain.java (part)
public static void main(String[] args) throws Exception {
   Main main = new org.apache.camel.spring.Main();
          main.setApplicationContextUri("springcontext.xml");
          main.configure().addRoutesBuilder(new Route1());
          main.configure().addRoutesBuilder(new Route2());
          if (condition3)
                  main.configure().addRoutesBuilder(new Route3());
          if (condition4)
                 main.configure().addRoutesBuilder(new Route4());
          main.run();


Behavior with 2.25 : the log says "Total 0 routes, of which 0 are 
started" and just after, i see the routes in my classes Route1..Route4 
start (seen by "Route: Route1 started and consuming from:..." ) and only 
the wanted routes depending on the conditions.

Behavior with 3.18.6 : when i start my app, i see "Routes startup 
(started:0)", and nothing after that.
I also tested to add <packageScan> in the camelContext, With that, all 
the routes starts OK, but no conditions possible...

How can i have a situation like old 2.25 ?

Thanks

Re: spring-main & addRoutesBuilder : don't work together ?

Posted by Claus Ibsen <cl...@gmail.com>.
Try with latest 3.20.4 release first.

Also using spring-main standalone is not so common.
We mainly use/support/focus on spring boot or quarkus based runtimes.


On Thu, Apr 27, 2023 at 11:03 AM Joël Guelluy <jg...@skynet.be.invalid>
wrote:

> Hello,
>
> I'm in migration of a program Came 2.25 to 3.18.6, and there is
> something i can't fix.
> It seems like camel-spring-main & addRoutesBuilder can't work
> together... (i'm probably missing something...)
>
> springcontext.xml
> <camel:camelContext id="camel"
> xmlns="http://camel.apache.org/schema/spring">
> </camel:camelContext>
>
> MyMain.java (part)
> public static void main(String[] args) throws Exception {
>    Main main = new org.apache.camel.spring.Main();
>           main.setApplicationContextUri("springcontext.xml");
>           main.configure().addRoutesBuilder(new Route1());
>           main.configure().addRoutesBuilder(new Route2());
>           if (condition3)
>                   main.configure().addRoutesBuilder(new Route3());
>           if (condition4)
>                  main.configure().addRoutesBuilder(new Route4());
>           main.run();
>
>
> Behavior with 2.25 : the log says "Total 0 routes, of which 0 are
> started" and just after, i see the routes in my classes Route1..Route4
> start (seen by "Route: Route1 started and consuming from:..." ) and only
> the wanted routes depending on the conditions.
>
> Behavior with 3.18.6 : when i start my app, i see "Routes startup
> (started:0)", and nothing after that.
> I also tested to add <packageScan> in the camelContext, With that, all
> the routes starts OK, but no conditions possible...
>
> How can i have a situation like old 2.25 ?
>
> Thanks
>


-- 
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Re: spring-main & addRoutesBuilder : don't work together ?

Posted by Joël Guelluy <jg...@skynet.be.INVALID>.
It's the same with 3.20.4

Side note : when changing version, compiler screamed because of removing 
camel-test-junit5:CamelTestSupport.assertMockEndpointsSatisfied()
I don't see anything about this in 
https://camel.apache.org/manual/camel-3x-upgrade-guide-3_20.html


    ------ Message d'origine ------
    De: claus.ibsen@gmail.com
    To: users@camel.apache.org
    Envoyé: jeudi 27 avril 2023 13:38
    Objet: Re: spring-main & addRoutesBuilder : don't work together ?

          Try with latest 3.20.4 release first.

  Also using spring-main standalone is not so common.
  We mainly use/support/focus on spring boot or quarkus based runtimes.


  On Thu, Apr 27, 2023 at 11:03 AM Joël Guelluy 
<jg...@skynet.be.invalid>
  wrote:

  > Hello,
  >
  > I'm in migration of a program Came 2.25 to 3.18.6, and there is
  > something i can't fix.
  > It seems like camel-spring-main & addRoutesBuilder can't work
  > together... (i'm probably missing something...)
  >
  > springcontext.xml
  > <camel:camelContext id="camel"
  > xmlns="http://camel.apache.org/schema/spring">
  > </camel:camelContext>
  >
  > MyMain.java (part)
  > public static void main(String[] args) throws Exception {
  >    Main main = new org.apache.camel.spring.Main();
  >           main.setApplicationContextUri("springcontext.xml");
  >           main.configure().addRoutesBuilder(new Route1());
  >           main.configure().addRoutesBuilder(new Route2());
  >           if (condition3)
  >                   main.configure().addRoutesBuilder(new Route3());
  >           if (condition4)
  >                  main.configure().addRoutesBuilder(new Route4());
  >           main.run();
  >
  >
  > Behavior with 2.25 : the log says "Total 0 routes, of which 0 are
  > started" and just after, i see the routes in my classes 
Route1..Route4
  > start (seen by "Route: Route1 started and consuming from:..." ) and 
only
  > the wanted routes depending on the conditions.
  >
  > Behavior with 3.18.6 : when i start my app, i see "Routes startup
  > (started:0)", and nothing after that.
  > I also tested to add  in the camelContext, With that, all
  > the routes starts OK, but no conditions possible...
  >
  > How can i have a situation like old 2.25 ?
  >
  > Thanks
  >


  --
  Claus Ibsen
  -----------------
  @davsclaus
  Camel in Action 2: https://www.manning.com/ibsen2