简体   繁体   English

Apache Camel Webhook 组件

[英]Apache Camel Webhook Component

I'm trying to make use of the Webhook component provided by Camel.我正在尝试使用 Camel 提供的 Webhook 组件。 The documentation doesn't show any proper use of this meta component or the list of supported components to be configured using this Webhook component.该文档未显示此元组件的任何正确使用或要使用此 Webhook 组件配置的受支持组件的列表。 The GitHub example succeeds in mentioning only one such component being the telegram one. 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"

This is my sample code attempting to use the component with a REST endpoint rather than the telegram component used in the example:这是我的示例代码,试图使用具有 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}");
    }
}

This throws an error as below:这会引发如下错误:

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.

When I change the sample code to try using.netty-http like so:当我更改示例代码以尝试使用 .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}");
    }
}

I get a different error as below:我收到如下不同的错误:

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

There's really no proper example on how to actually use this component in the common settings like talking to a REST endpoint etc nor is there any clear description of what configurations need to go into the application.yml file.确实没有关于如何在常见设置中实际使用此组件的适当示例,例如与 REST 端点等通信,也没有明确说明 go 需要哪些配置到 application.yml 文件中。 Any help will be much appreciated.任何帮助都感激不尽。 Thanks!谢谢!

The documentation:文档:

The following components currently provide webhook endpoints:以下组件当前提供 webhook 端点:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM