Page 1 of 3 123 LastLast
Results 1 to 10 of 26

Thread: Inbound channel adapter issue

  1. #1
    Join Date
    Sep 2006
    Posts
    100

    Default Inbound channel adapter issue

    Here is my inbound channel adapter config:

    Code:
    <int-file:inbound-channel-adapter directory="DecryptedFiles" channel="decryptedFilesChannel" prevent-duplicates="true">
    		<int:poller cron="* * 6-23 * * SUN-SAT" />
    	</int-file:inbound-channel-adapter>
    However, when my application runs, I see that multiple threads are processing the same file. How do I ensure that the file is picked up only once?

    Any help is greatly appreciated.

  2. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Bobby

    From your configuration i can't see how is it possible.
    Could you please provide more detail
    All I see is that new file will be picked up by the poller's thread in intervals governed by the cron expression. And your poller is single-threaded

  3. #3
    Join Date
    Sep 2006
    Posts
    100

    Default

    I totally understand and that was my expectation too as I did not assign any task executor. According to my application log, two task scheduler threads (10 and 8) were spanned to access the same file at the same time.

    Please see below:

    Code:
    2011-05-03 15:33:02,006  DEBUG FileReadingMessageSource [task-scheduler-10] (FileReadingMessageSource.java:272) - Added to queue: [DecryptedFiles\DECRYPTED_YwHsP9Evt5BY$gAA]
    2011-05-03 15:33:02,006  INFO  FileReadingMessageSource [task-scheduler-10] (FileReadingMessageSource.java:260) - Created message: [[Payload=DecryptedFiles\DECRYPTED_YwHsP9Evt5BY$gAA][Headers={timestamp=1304454782006, id=7ac20ada-c13f-460e-b05d-1291eb49a144}]]
    2011-05-03 15:33:02,006  DEBUG FileReadingMessageSource [task-scheduler-8] (FileReadingMessageSource.java:272) - Added to queue: [DecryptedFiles\DECRYPTED_YwHsP9Evt5BY$gAA]
    2011-05-03 15:33:02,006  INFO  FileReadingMessageSource [task-scheduler-8] (FileReadingMessageSource.java:260) - Created message: [[Payload=DecryptedFiles\DECRYPTED_YwHsP9Evt5BY$gAA][Headers={timestamp=1304454782006, id=4c422df2-dfb9-453e-91ac-1cda56a6683d}]]

  4. #4
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Bobby

    I was just trying to reproduce and I don't see any duplication. The only way I was able to reproduce it is by starting the ApplicationContext (AC) twice or by configuring two adapter instances in the same AC.
    Can you look at your config and make sure you don't have a second instance of the adapter?

  5. #5
    Join Date
    Sep 2006
    Posts
    100

    Default

    I do not have multiple inbound channel adapters polling the same folder; however, I do have inbound channel adapters polling different folders (within the same applicationContext). Could this be an issue?

    This is what is happening in my application:
    1. I poll an FTP site, pick an encrypted file when present.
    2. There is a command line utility used to decrypt the file and is stored in DecryptedFiles folder.
    3. I use inbound channel adapter to process the decrypted file.

    There is other inbound-channel-adapter polling to FTP an encrypted file (outbound processing). The same behavior is seen there as well and is consistent even between Tomcat recycles.

  6. #6
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Not sure I understand that. Could you clarify?
    I do not have multiple inbound channel adapters polling the same folder; however, I do have inbound channel adapters polling different folders

  7. #7
    Join Date
    Sep 2006
    Posts
    100

    Default

    I meant to say there are multiple inbound channel adapters polling different folders say folder1, folder2, folder3 at various stages of processing (a file being processed in phase1 would be in folder1, and then moved to folder2 for phase2 processing etc).

  8. #8
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Ok, i think i know what's going on.

    Correct me if I am wrong.
    FTP downloads a file in the directory dir1. Then your inbound-channel-adapter polls dir-1. Right?
    If so then here is what's happening.
    FTP after downloading the file uses FileReadingMessageSource to generate a Message from the the newly downloaded file and send it to a channel. So the second inbound-channel-adapter is really not necessary if all you need is process files as soon as they arrive, otherwise that is what's causing the illusion of duplication. Makes sense?

  9. #9
    Join Date
    Sep 2006
    Posts
    100

    Default

    Kind of.

    FTP Process downloads the file to folder1 is put on channel. It is then passed to a service activator which decrypts the file and puts it in folder2. Then I have an inbound channel adapter polling folder2 to process the decrypted file. This is where I am seeing what I am seeing (two task scheduler threads generating two messages).

  10. #10
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Could you post your ful config, since I can't see how that's possible.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •