【发布时间】: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