【问题标题】:Apache Camel Webhook ComponentApache Camel Webhook 组件
【发布时间】:2021-08-30 01:48:43
【问题描述】:

我正在尝试使用 Camel 提供的 Webhook 组件。该文档未显示此元组件的任何正确使用或使用此 Webhook 组件配置的受支持组件列表。 GitHub 示例成功地仅提及了一个这样的组件,即 telegram 之一。

implementation "org.apache.camel.springboot:camel-webhook-starter:3.11.1"
implementation "org.apache.camel.springboot:camel-netty-http-starter:3.11.1"
implementation "org.apache.camel.springboot:camel-spring-boot-starter:3.11.1"

这是我尝试将组件与 REST 端点一起使用的示例代码,而不是示例中使用的 telegram 组件:

@Component
public class WebhookExample extends RouteBuilder {
    @Override
    public void configure() throws Exception {
        restConfiguration().contextPath("/camel");

        from("webhook:https://app.example.com/callback?code=<AUTHORISATION_CODE>&state=<STATE>")
                .log("Received: ${body}");
    }
}

这会引发如下错误:

Caused by: org.apache.camel.NoSuchEndpointException: No endpoint could be found for: https://app.example.com/callback?code=%3CAUTHORISATION_CODE%3E&state=%3CSTATE%3E, please check your classpath contains the needed Camel component jar.

当我更改示例代码以尝试使用 netty-http 时:

@Component
public class WebhookExample extends RouteBuilder {
    @Override
    public void configure() throws Exception {
        restConfiguration().contextPath("/camel");

        from("webhook:netty-http:https://app.example.com/callback?code=<AUTHORISATION_CODE>&state=<STATE>")
                .log("Received: ${body}");
    }
}

我得到一个不同的错误如下:

Caused by: java.lang.IllegalArgumentException: The provided endpoint is not capable of being used in webhook mode: netty-http:https://app.example.com/callback?code=%3CAUTHORISATION_CODE%3E&state=%3CSTATE%3E

对于如何在通用设置(例如与 REST 端点通信等)中实际使用该组件,确实没有合适的示例,也没有任何明确的描述需要进入 application.yml 文件的配置! 任何帮助都感激不尽。谢谢!

【问题讨论】:

  • 你找到解决办法了吗

标签: java spring-boot apache-camel webhooks spring-camel


【解决方案1】:

文档:

以下组件目前提供 webhook 端点:

【讨论】:

  • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接答案可能会失效。 - From Review
  • 谢谢!但很抱歉,这并不能回答问题。我已经提到 Telegram 作为他们在 Github 上的示例代码中提到的唯一组件。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-10
  • 2014-01-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-23
相关资源
最近更新 更多