简体   繁体   中英

Apache Camel Webhook Component

I'm trying to make use of the Webhook component provided by Camel. 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. The GitHub example succeeds in mentioning only one such component being the telegram one.

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:

@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:

@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. Any help will be much appreciated. Thanks!

The documentation:

The following components currently provide webhook endpoints:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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