查找FilePoller的活动

时间:2018-08-02 11:49:45

标签: spring logging

我有入站通道适配器,我的通道是File。我有一个轮询器连接到我的InboundFileAdapter。我想记录轮询器的活动,即轮询器正在轮询给定目录,轮询器得到了文件Input..etc。 我曾经尝试过窃听并附加了一个记录器通道,但是我仅在输入文件时才获得状态。我想知道在轮询时如何获取轮询器状态。我在这里附上代码段。

@Bean
    public MessageChannel fileChannel() {
        DirectChannel channel = new DirectChannel();
        channel.addInterceptor(new WireTap(loggerChannel()));
        return channel;
    }
@Bean
    @InboundChannelAdapter(value = "fileChannel", autoStartup = "false",
            poller = @Poller(fixedDelay = "${abc.pollingFrequencySeconds}"))
    public MessageSource<File> fileReadingMessageSource() {
        final FileReadingMessageSource sourceReader = new FileReadingMessageSource(new FileCompareHelper());

        final CompositeFileListFilter<File> filters = new CompositeFileListFilter<>();
        filters.addFilter(new SimplePatternFileListFilter("*" + abc.getTriggerFileExtension()));
        filters.addFilter(new LastModifiedFileListFilter());
        sourceReader.setDirectory(new File(abc.getFileInputPath()));
        sourceReader.setFilter(filters);
        return sourceReader;
    }

@Bean
    @ServiceActivator(inputChannel = "fileChannel")
    public MessageHandler loggerMessageHandler() {
        return new MessageHandler() {

            @Override
            public void handleMessage(Message<?> arg0) throws MessagingException {
                final Logger LOGGER = LoggerFactory.getLogger(ZrpeIntegrationPollerConfiguration.class);
                LOGGER.info("polling the file directory");
                LOGGER.info("polling the file directory"+arg0);
            }
        };
    }


Can any one help me on this, Thanks in advance! 

0 个答案:

没有答案