2 回答

TA貢獻(xiàn)1842條經(jīng)驗 獲得超21個贊
使用調(diào)度程序組件并將其配置為使用 spring https://camel.apache.org/components/latest/scheduler-component.html

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}");
添加回答
舉報