【问题标题】:Explicitly define Camel Routes in Quarkus在 Quarkus 中显式定义骆驼路线
【发布时间】:2022-08-08 03:46:04
【问题描述】:

当前行为:当我使用 Camel 运行 Quarkus 应用程序时,它会自动将所有 RouteBuilder 扩展作为路由启动。

我想要达到的目标:启动时,仅启动我配置的路由。

我试过的

  1. 使用以下 sn-p 可以显式启动 CamelMainApplication 但我不知道如何控制例如CamelContext 在这一点上我可以配置我的路线。
    @QuarkusMain
    public class Main {
        public static void main(String[] args) throws Exception {
            Quarkus.run(CamelMainApplication.class, args);
        }
    }
    
    1. 在我可以使用的路线上.noAutoStartup()在启动时禁用路由。但这意味着它不是默认禁用所有路由的第一个和第二个我不知道在哪里激活它们,因为我不知道在 Quarkus 应用程序中的哪个位置我可以使用骆驼上下文激活路线。

    2. 在我的以下应用程序.yml我可以禁用自动路由发现,但剩下的问题是如何手动启动路由,例如在我的夸库斯主班级。

    quarkus:
     camel:
       routes-discovery:
         enabled: false
    

    标签: apache-camel quarkus


    【解决方案1】:

    我遇到了同样的问题,我最终做了以下事情:

    @QuarkusMain
    public class Main implements QuarkusApplication {
    
       @Inject
       OrderService orderService;
    
        @Override
        public int run(String... args) throws Exception {
            CamelRuntime runtime = Arc.container().instance(CamelRuntime.class).get();
            runtime.start(new String[]{});
    
            orderService.handleOrders(args[0]); //this would inject the camelContext and start the route. 
    
    
            return 0;
        }
    
    

    【讨论】:

      猜你喜欢
      • 2014-02-09
      • 2018-09-05
      • 2011-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-05
      相关资源
      最近更新 更多