第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用 Spring Scheduler 而不是 Camel Timer 啟動 Camel 路線

如何使用 Spring Scheduler 而不是 Camel Timer 啟動 Camel 路線

慕村225694 2023-10-13 16:28:50
如何使用 spring 調(diào)度程序而不是計時器組件啟動駱駝路線?我嘗試過使用駱駝計時器組件來觸發(fā)路線,但是除了計時器之外,還有什么方法可以使用 spring 調(diào)度程序來觸發(fā)路線。1)Spring主類:-@SpringBootApplicationpublic class SampleSchedulerApplication {    public static void main(String[] args) {        SpringApplication.run(SampleSchedulerApplication.class, args);    }}2) 路由器類別:-以下是我嘗試使用計時器組件的示例。//Directing to someServicefrom("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.
查看完整描述

2 回答

?
茅侃侃

TA貢獻(xiàn)1842條經(jīng)驗 獲得超21個贊

使用調(diào)度程序組件并將其配置為使用 spring https://camel.apache.org/components/latest/scheduler-component.html


查看完整回答
反對 回復(fù) 2023-10-13
?
德瑪西亞99

TA貢獻(xiàn)1770條經(jīng)驗 獲得超3個贊

我使用 Spring Scheduler 而不是計時器通過使用 ProducerTemplate 調(diào)用駱駝路線,參考:https://camel.apache.org/manual/latest/ Producertemplate.html 。


1)春季調(diào)度程序:-


@Configuration

@EnableScheduling

public class SchedulerConfiguration {


    @Autowired

    private IntegrationService integrationService;


     @Scheduled(fixedDelay = 90000, initialDelay = 5000)

    public void integrationConfig() throws IOException {

        integrationService.getServiceAuthentication();


    }

2)集成服務(wù);


@Component

public class IntegrationService {

    @Autowired

    private ProducerTemplate producerTemplate;


    public void getServiceAuthentication() {

 producerTemplate.sendBody("direct:someservice","username=123&password=123");

    }

}

3)路由器生成器類;


 from("direct:someservice")                

.setHeader(Exchange.HTTP_METHOD).constant(HttpMethod.GET)              

.to("undertow:http://localhost:8090/api/employee/getemployees").

.log("Response : ${body}");


查看完整回答
反對 回復(fù) 2023-10-13
  • 2 回答
  • 0 關(guān)注
  • 151 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號