2

How to integrate a Pollable channel in the Integration flow. As my flow is using a NullChannel instead of Pollable Channel. Can some one kindly provide any pointer on this.

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.

And the logs are... [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 sftpSessionFactory.....org.springframework.integration.sftp.session.SftpSession@1ffcd26 enter sftpInboundFlow.....org.springframework.integration.sftp.session.SftpSession@13a462c the channel is org.springframework.integration.channel.NullChannel@d532ee [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}]]

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
David
  • 109
  • 1
  • 16

1 Answers1

2

Just use the autowired field directly in the flow...

.channel(this.sftpInboundResultChannel)

EDIT:

It looks like MessageChannels.queue("sftpInboundResultChannel") is not registering the channel as a bean so Spring is autowiring NullChannel into that field (because it's the only PollableChannel in the context).

We need to take a look at that; in the meantime, add

@Bean
public PollableChannel sftpInboundResultChannel() {
    return new QueueChannel();
}
Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • It completely answers the question. – Gary Russell Jul 19 '15 at 14:22
  • Hi Gary, Yes , I used this autowired field directly like .channel(this.sftpInboundResultChannel) but still I found in log the channel is NullChannel. Please see the log printed below....enter sftpInboundFlow.....org.springframework.integration.sftp.session.SftpSession@e4e7df the channel is org.springframework.integration.channel.NullChannel@331017 – David Jul 22 '15 at 05:04
  • I need some context for that log message to understand where it's coming from - post more of it - don't post logs in comments; they are unreadable - edit the question. – Gary Russell Jul 22 '15 at 12:52
  • Hi Gary, As suggested by you, I have posted the log in my original message. The message is coming from this..."System.out.println("the channel is " + sftpInboundResultChannel);" – David Jul 22 '15 at 13:22
  • I edited the answer. Can you confirm the version of the DSL you are using? – Gary Russell Jul 22 '15 at 13:56
  • Hi Gary, Thanks for your answer, I am using the DSL version 1.0.1 Release. – David Jul 24 '15 at 06:17