;}
@豆@InboundChannelAdapter(value =“ssnInboundFileChannel”,poller = @Poller(cron =“$ { MEC </跨度> / SSN_POLLER}“))public MessageSource&lt; File&gt; fileMessageSourceSSN(){ System.out.println(“SSNPOLLING 以下dir …..”+ mecProperty.getProperty(MecConstants.SSN_SFTP_WORKING_DIR)); 返回来源;}
@豆@InboundChannelAdapter(value =“mdwInboundFileChannel”,poller = @Poller(cron =“$ { MEC </跨度>
入站通道适配器由(至少两个)bean组成;在这种情况下,一个 MessageSource 和a SourcePollingChannelAdapter 。
MessageSource
SourcePollingChannelAdapter
在您的示例中,消息源获取指定的bean名称( filePoller )。将生成通道适配器的名称
filePoller
filePoller.fileMessageSource.inboundChannelAdapter
( @Configuration class bean name + method name + type)
@Configuration
我们有一个 打开JIRA问题 记录这些生成的bean名称。
由于名称是虚线的,因此在使用控制总线时需要引用它:
@'filePoller.fileMessageSource.inboundChannelAdapter'.stop()
的 编辑 强>
我刚测试了这个,它工作得很好......
@Configuration @EnableIntegration public class Foo { @Bean QueueChannel inboundFileChannel() { return new QueueChannel(); } @Bean @InboundChannelAdapter(value = "inboundFileChannel", poller = @Poller(fixedDelay="1000")) public MessageSource<?> fileMessageSource() { MessageSource<?> source = mock(MessageSource.class); return source; } @Bean MessageChannel control() { return new DirectChannel(); } @Bean @ServiceActivator(inputChannel="control") public ExpressionControlBusFactoryBean controlBus() { return new ExpressionControlBusFactoryBean(); } public static void main(String[] args) throws Exception { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Foo.class); Thread.sleep(2000); ctx.getBean("control", MessageChannel.class).send( new GenericMessage<String>("@'foo.fileMessageSource.inboundChannelAdapter'.stop()")); assertFalse(ctx.getBean(SourcePollingChannelAdapter.class).isRunning()); Thread.sleep(2000); ctx.close(); } }
的 EDIT2 强> :
我在上面的例子中放了一些睡眠,看到这个......
2015-08-03 12:23:34,528 [task-scheduler-1] DEBUG: org.springframework.integration.endpoint.SourcePollingChannelAdapter - Received no Message during the poll, returning 'false' 2015-08-03 12:23:35,530 [task-scheduler-2] DEBUG: org.springframework.integration.endpoint.SourcePollingChannelAdapter - Received no Message during the poll, returning 'false' 2015-08-03 12:23:35,615 [main] DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'control' 2015-08-03 12:23:35,616 [main] DEBUG: org.springframework.integration.channel.DirectChannel - preSend on channel 'control', message: GenericMessage [payload=@'foo.fileMessageSource.inboundChannelAdapter'.stop(), headers={id=d0049777-025c-5439-6ee7-d66bce34868a, timestamp=1438619015616}] 2015-08-03 12:23:35,616 [main] DEBUG: org.springframework.integration.handler.ServiceActivatingHandler - ServiceActivator for [org.springframework.integration.handler.ExpressionCommandMessageProcessor@1e0b4072] received message: GenericMessage [payload=@'foo.fileMessageSource.inboundChannelAdapter'.stop(), headers={id=d0049777-025c-5439-6ee7-d66bce34868a, timestamp=1438619015616}] 2015-08-03 12:23:35,617 [main] DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'foo.fileMessageSource.inboundChannelAdapter' 2015-08-03 12:23:35,618 [main] INFO : org.springframework.integration.endpoint.SourcePollingChannelAdapter - stopped foo.fileMessageSource.inboundChannelAdapter 2015-08-03 12:23:35,618 [main] DEBUG: org.springframework.integration.handler.ServiceActivatingHandler - handler 'ServiceActivator for [org.springframework.integration.handler.ExpressionCommandMessageProcessor@1e0b4072]' produced no reply for request Message: GenericMessage [payload=@'foo.fileMessageSource.inboundChannelAdapter'.stop(), headers={id=d0049777-025c-5439-6ee7-d66bce34868a, timestamp=1438619015616}] 2015-08-03 12:23:35,618 [main] DEBUG: org.springframework.integration.channel.DirectChannel - postSend (sent=true) on channel 'control', message: GenericMessage [payload=@'foo.fileMessageSource.inboundChannelAdapter'.stop(), headers={id=d0049777-025c-5439-6ee7-d66bce34868a, timestamp=1438619015616}] 2015-08-03 12:23:35,618 [main] DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'foo.fileMessageSource.inboundChannelAdapter'
(停止后没有民意调查)