【发布时间】:2018-11-01 12:23:16
【问题描述】:
您好,我正在使用带有触发器的 SpringIntegration 来轮询目录。到目前为止,一切都很好。
但我在轮询开始和结束时间遇到问题,例如下午 12:05 和 18:15
0 0/1 12-18 ? * MON-FRI
12 点到 18 点之间每分钟都可以正常工作,但我也找不到设置时间的方法
支持吗
@Bean
public IntegrationFlow inboundFileIntegration(
) {
CronTrigger cronTrigger = new CronTrigger("0 0/1 12-18 ? * MON-FRI");
return IntegrationFlows.from(fileReadingMessageSource(),
c -> c.poller(Pollers.trigger(cronTrigger)
.maxMessagesPerPoll(10).advice(new AbstractMessageSourceAdvice() {
@Override
public Message<?> afterReceive(Message<?> message, MessageSource<?> messageSource) {
System.out.println("after");
return message;
}
@Override
public boolean beforeReceive(MessageSource<?> source) {
System.out.println("before");
return true;
}
})))
// .transactionSynchronizationFactory(transactionSynchronizationFactory())
// .transactional(transactionManager())))
.log()
.transform(Files.toStringTransformer())
.transform(o -> {
// jmsTemplate.convertAndSend("testing_queue", o);
System.out.println(o);
return o;
})
.channel(ApplicationConfiguration.INBOUND_CHANNEL)
.get();
}
【问题讨论】:
标签: java spring-boot cron spring-integration spring-integration-dsl