【问题标题】:How to write a Camel Quarkus extension for a Camel component/endpoint?如何为 Camel 组件/端点编写 Camel Quarkus 扩展?
【发布时间】:2021-09-13 12:29:38
【问题描述】:

我有一个自己的 camel 组件/端点,我在 Spring Boot 应用程序 中的许多路由 中成功使用了它。 我正在尝试迁移到 camel quarkus 并在我的应用程序中使用相同的 routes

通过简单地添加相关依赖项,无法在我的 camel-quarkus 应用程序中使用此 组件/端点quarkus 无法像 Spring Boot 一样发现这个组件/端点

显而易见的解决方案是编写一个 quarkus 扩展,在后台使用这个 camel-componentquarkus extensions 就像 @987654322 @、filesql等使用对应的camel-components实现。

如果我们查看其运行时模块的pom-xml of sql,我们会发现它使用了等效的camel-sql component

<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-sql</artifactId>
</dependency>

我的问题是,即使按项目构建(我正在使用 eclipse),quarkus 仍然没有发现组件/端点,quarkus 显示它已经安装了我的扩展。 我在互联网上搜索了很长时间,但没有找到任何有用的资源。

【问题讨论】:

  • 您的意思是您要在 Quarkus 上使用自定义或第三方 Camel 组件?
  • James Netherton :感谢您的询问。同时,我找到了一个解决方案,我将添加为答案。

标签: routes apache-camel quarkus endpoint eai


【解决方案1】:

使用此依赖项。所有 quarkus 依赖项都以组 id 开头,即 org.apache.camel.quarkus 和 artifact camel-quarkus-xxx

<dependency>
  <groupId>org.apache.camel.quarkus</groupId>
  <artifactId>camel-quarkus-sql</artifactId>
</dependency>

对于postgresql

<dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>

【讨论】:

    【解决方案2】:

    显而易见的解决方案是不要编写额外的扩展。 Quarkus-Runtime 发现模块或第三方依赖项中的类当且仅当:

    1. 第三方依赖在宿主项目中被索引: 通过将以下条目添加到 .properties 文件:

    quarkus.index-dependency..group-id=
    quarkus.index-dependency..artifact-id=

    .yaml 文件:

    quarkus:  
       index-dependency:
         <name>:
            group-id: <group-id>
            artifact-id: <artifact-id> 
    

    其中 是第三方的。

    1. jandex-maven-plugin 存在于此模块或第三方依赖项的 pom.xml
    2. 一个空的 beans.xml 存在于 src/main/resorces/META-INF 这个模块/依赖项

    我在post 中找到了我的问题的答案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-04
      • 2021-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-21
      相关资源
      最近更新 更多