gpt4 book ai didi

java - 如何使用 Spring Scheduler 而不是 Camel Timer 启动 Camel 路线

转载 作者:行者123 更新时间:2023-12-01 23:18:26 25 4
gpt4 key购买 nike

如何使用 Spring Scheduler 而不是计时器组件来启动 Camel 路由?

我尝试过使用camel计时器组件来触发路线,但是除了计时器之外,还有什么方法可以使用spring调度程序来触发路线。

1) Spring 主类:-

@SpringBootApplication
public class SampleSchedulerApplication {
public static void main(String[] args) {
SpringApplication.run(SampleSchedulerApplication.class, args);
}
}

2) 路由器类:-

以下示例是我尝试使用计时器组件的示例。

//Directing to someService
from("timer://scheduler?period=10s")//What component should i use by default.
.to("direct:someservice");

//Fetching datas from the rest api.
from("direct:someservice")
.setHeader(Exchange.HTTP_METHOD).constant(HttpMethod.GET)
.to("undertow:http://localhost:8090/api/employee/getemployees").
.log("Response : ${body}");

without timer, i can't able to trigger the route.

最佳答案

使用调度程序组件并将其配置为使用spring https://camel.apache.org/components/latest/scheduler-component.html

关于java - 如何使用 Spring Scheduler 而不是 Camel Timer 启动 Camel 路线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58339581/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com