2015-07-17 2 views
2

Как интегрировать затухающий канал в потоке интеграции. Поскольку мой поток использует NullChannel вместо Pollable Channel. Может ли кто-то любезно предоставить любой указатель на это.Интеграция задерживаемого канала в потоке весенней интеграции

This is my Integration flow. 

    @Bean 
    public IntegrationFlow sftpInboundFlow() { 
     System.out.println("enter sftpInboundFlow....." 
       + sftpSessionFactory.getSession()); 
     System.out.println("the channel is " + sftpInboundResultChannel); 
     return IntegrationFlows 
       .from(Sftp.inboundAdapter(this.sftpSessionFactory) 
         .preserveTimestamp(true).remoteDirectory(remDir) 
         .regexFilter(".*\\.txt$") 
         .localFilenameExpression("#this.toUpperCase()") 
         .localDirectory(new File(localDir)) 
         .remoteFileSeparator("/"), 
         new Consumer<SourcePollingChannelAdapterSpec>() { 
          @Override 
          public void accept(SourcePollingChannelAdapterSpec e) { 
           e.id("sftpInboundAdapter") 
             .autoStartup(true) 
             .poller(Pollers.fixedRate(1000) 
               .maxMessagesPerPoll(1)); 
          } 
         }) 
       .channel(MessageChannels.queue("sftpInboundResultChannel")) 
       .get(); 
    } 


And I want to use this.. 

    @Autowired 
    private PollableChannel sftpInboundResultChannel; 
    in the .channel() method. 

И бревна ... [2015-07-22 18:48:05.497] - 2796 INFO [main] --- com.jcraft.jsch: SSH_MSG_NEWKEYS sent [2015-07-22 18:48:05.497] - 2796 INFO [main] --- com.jcraft.jsch: SSH_MSG_NEWKEYS received [2015-07-22 18:48:05.500] - 2796 INFO [main] --- com.jcraft.jsch: SSH_MSG_SERVICE_REQUEST sent [2015-07-22 18:48:05.501] - 2796 INFO [main] --- com.jcraft.jsch: SSH_MSG_SERVICE_ACCEPT received [2015-07-22 18:48:15.517] - 2796 INFO [main] --- com.jcraft.jsch: Authentications that can continue: gssapi-with-mic,publickey,keyboard-interactive,password [2015-07-22 18:48:15.517] - 2796 INFO [main] --- com.jcraft.jsch: Next authentication method: gssapi-with-mic [2015-07-22 18:48:15.522] - 2796 INFO [main] --- com.jcraft.jsch: Authentications that can continue: publickey,keyboard-interactive,password [2015-07-22 18:48:15.522] - 2796 INFO [main] --- com.jcraft.jsch: Next authentication method: publickey [2015-07-22 18:48:15.523] - 2796 INFO [main] --- com.jcraft.jsch: Authentications that can continue: password [2015-07-22 18:48:15.523] - 2796 INFO [main] --- com.jcraft.jsch: Next authentication method: password [2015-07-22 18:48:15.537] - 2796 INFO [main] --- com.jcraft.jsch: Authentication succeeded (password). enter sftpSessionFacto[email protected]1ffcd26 enter sftpInboundFl[email protected]13a462c the channel is [email protected] [2015-07-22 18:48:15.827] - 2796 INFO [main] --- org.springframework.context.support.DefaultLifecycleProcessor: Starting beans in phase -2147483648 [2015-07-22 18:48:15.828] - 2796 INFO [main] --- org.springframework.context.support.DefaultLifecycleProcessor: Starting beans in phase 0 [2015-07-22 18:48:15.828] - 2796 INFO [main] --- org.springframework.integration.endpoint.EventDrivenConsumer: Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel [2015-07-22 18:48:15.828] - 2796 INFO [main] --- org.springframework.integration.channel.PublishSubscribeChannel: Channel 'application.errorChannel' has 1 subscriber(s). [2015-07-22 18:48:15.829] - 2796 INFO [main] --- org.springframework.integration.endpoint.EventDrivenConsumer: started _org.springframework.integration.errorLogger [2015-07-22 18:48:15.829] - 2796 INFO [main] --- org.springframework.context.support.DefaultLifecycleProcessor: Starting beans in phase 1073741823 [2015-07-22 18:48:15.832] - 2796 INFO [main] --- org.springframework.integration.endpoint.SourcePollingChannelAdapter: started sftpInboundAdapter [2015-07-22 18:48:15.834] - 2796 INFO [main] --- src.MainSftpInBoundDsl: Started MainSftpInBoundDsl in 11.019 seconds (JVM running for 11.182) enter main..... enter main..... [2015-07-22 18:48:16.040] - 2796 INFO [task-scheduler-1] --- org.springframework.integration.file.FileReadingMessageSource: Created message: [GenericMessage [payload=D:\local_copy\AMARJEET.TXT, headers={timestamp=1437571096040, id=ddc20f6d-26ee-7eef-f59e-b5207dcdc8c7}]] [2015-07-22 18:48:16.832] - 2796 INFO [task-scheduler-1] --- org.springframework.integration.file.FileReadingMessageSource: Created message: [GenericMessage [payload=D:\local_copy\INFO.TXT, headers={timestamp=1437571096832, id=361b55d5-884e-9001-d513-ddc81926bf85}]] [2015-07-22 18:48:17.832] - 2796 INFO [task-scheduler-2] --- org.springframework.integration.file.FileReadingMessageSource: Created message: [GenericMessage [payload=D:\local_copy\KKKK.TXT, headers={timestamp=1437571097832, id=49deb17c-50e3-4315-dfa2-cc443a35bd1c}]] [2015-07-22 18:48:18.832] - 2796 INFO [task-scheduler-1] --- org.springframework.integration.file.FileReadingMessageSource: Created message: [GenericMessage [payload=D:\local_copy\LA.TXT, headers={timestamp=1437571098832, id=88def298-ab86-1d63-039e-c81c70ae6819}]] [2015-07-22 18:48:19.832] - 2796 INFO [task-scheduler-3] --- org.springframework.integration.file.FileReadingMessageSource: Created message: [GenericMessage [payload=D:\local_copy\POC.TXT, headers={timestamp=1437571099832, id=d78b36eb-10f5-ce83-ba4c-cd24a806480b}]] [2015-07-22 18:48:20.832] - 2796 INFO [task-scheduler-2] --- org.springframework.integration.file.FileReadingMessageSource: Created message: [GenericMessage [payload=D:\local_copy\PPPP.TXT, headers={timestamp=1437571100832, id=4e727ebb-b4de-be19-6a92-afb3be24576f}]] [2015-07-22 18:48:21.832] - 2796 INFO [task-scheduler-4] --- org.springframework.integration.file.FileReadingMessageSource: Created message: [GenericMessage [payload=D:\local_copy\REFERENCE.TXT, headers={timestamp=1437571101832, id=3d611371-431c-6b1e-0e17-377f5607de96}]] [2015-07-22 18:48:22.831] - 2796 INFO [task-scheduler-1] --- org.springframework.integration.file.FileReadingMessageSource: Created message: [GenericMessage [payload=D:\local_copy\RRRRR.TXT, headers={timestamp=1437571102831, id=707e566c-ccfa-6c32-16d6-1f27ec73abaf}]] [2015-07-22 18:48:23.832] - 2796 INFO [task-scheduler-5] --- org.springframework.integration.file.FileReadingMessageSource: Created message: [GenericMessage [payload=D:\local_copy\SFTP.TXT, headers={timestamp=1437571103832, id=b3c979ff-fcd2-e1ff-8b37-6b8f2803637a}]] [2015-07-22 18:48:24.832] - 2796 INFO [task-scheduler-3] --- org.springframework.integration.file.FileReadingMessageSource: Created message: [GenericMessage [payload=D:\local_copy\TEST.TXT, headers={timestamp=1437571104832, id=98d43e62-8e5f-69bc-7617-4706761eaf86}]] [2015-07-22 18:48:25.832] - 2796 INFO [task-scheduler-3] --- org.springframework.integration.file.FileReadingMessageSource: Created message: [GenericMessage [payload=D:\local_copy\XSS.TXT, headers={timestamp=1437571105832, id=77b28259-0287-0ef5-825f-5345d6c21c21}]] [2015-07-22 18:48:26.832] - 2796 INFO [task-scheduler-3] --- org.springframework.integration.file.FileReadingMessageSource: Created message: [GenericMessage [payload=D:\local_copy\ZZZZ.TXT, headers={timestamp=1437571106832, id=b5644a62-8c8c-86d2-e016-75fff01c70b4}]]

ответ

2

Просто используйте autowired поле непосредственно в потоке ...

.channel(this.sftpInboundResultChannel) 

EDIT:

Похоже MessageChannels.queue("sftpInboundResultChannel") не регистрирует канал в качестве фасоли, поэтому Spring является автоповтором NullChannel в это поле (потому что это единственный PollableChannel в контексте).

Нам нужно взглянуть на это; в то же время, добавить

@Bean 
public PollableChannel sftpInboundResultChannel() { 
    return new QueueChannel(); 
} 
+0

Он полностью отвечает на вопрос. –

+0

Привет, Гэри. Да, я использовал это поле автоматически, как .channel (this.sftpInboundResultChannel), но все же я нашел в журнале канал NullChannel. Пожалуйста, см. Журнал, напечатанный ниже .... введите sftpInboundFlow ..... [email protected] канал [email protected] – David

+0

Мне нужен какой-то контекст для этого сообщения журнала, чтобы понять, откуда оно взялось, - опубликуйте больше его - не публикуйте журналы в комментариях; они не читаются - отредактируйте вопрос. –

Смежные вопросы