【问题标题】:SpringIntegration Cron triggerSpringIntegration Cron 触发器
【发布时间】: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


    【解决方案1】:

    您可以像设置小时一样设置分钟:

    0 15-35 12-17 1/1 * ? MON-FRI
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-24
      • 1970-01-01
      • 1970-01-01
      • 2011-09-02
      相关资源
      最近更新 更多