Announcement Announcement Module
Collapse
No announcement yet.
Queue not queueing Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Queue not queueing

    I'm working on a program that sucks in files and eventually spits the contents into a database. Nothing fancy. I'd like to limit the inbound file messages to 5 at a time so I don't overload the system, but I'm having difficulty. Here's my config:

    Code:
        <si:channel id="inFiles">
            <si:queue capacity="5"/>
        </si:channel>
    
        <file:inbound-channel-adapter id="rawData" directory="file:${import.in_dir}">
            <si:poller >
    		<si:interval-trigger interval="5000"/>
    	</si:poller>
        </file:inbound-channel-adapter>
    
        <si:bridge input-channel="rawData" output-channel="inFiles"/>
    
        <file:file-to-string-transformer input-channel="inFiles" charset="utf-8" output-channel="rawXml"/>
    It goes on from there. However, when I run this, the inbound-channel-adapter creates messages for every single file in the directory. I expected it to block after 5. Do I need to bridge messages out of the inFiles channel or something? I'm sure I'm just missing something conceptually.

  • #2
    The channel is only holding 5 Messages at any given time, but as soon as the poller receives a Message, then another Message can be added on the File-reading side.

    So, what you are actually seeing is the default behavior of a poller. Even though you've provided an interval, that is interpreted as the delay *between* poll attempts. For each poll attempt, however, the poller will continue polling as long as non-null Messages are received. That is the default behavior. If you want to limit the number of receives per-poll, then specify a "max-messages-per-poll" attribute on the "poller" element. You may or may not want to keep the same channel capacity value if you do it that way. For example, try this:
    Code:
        <si:poller max-messages-per-poll="5">
            <si:interval-trigger interval="5000"/>
        </si:poller>
    I hope that is a clear explanation. Let me know if you still have questions, and please post back either way so that we know this is working as expected with the change.

    Comment


    • #3
      I added the max-messages-per-poll attribute as you suggested, but it still added all of the files in the directory (just 5 at a time instead of all at once).

      However, your post clarified for me how the file reading channel was working. I went back and modified the channel adapter to use my queued channel and now it works like I was hoping for. For reference, my new config is

      Code:
          <si:channel id="inFiles">
              <si:queue capacity="5"/>
          </si:channel>
      
          <file:inbound-channel-adapter id="rawData" directory="file:${import.in_dir}" channel="inFiles" >
              <si:poller max-messages-per-poll="5" >
      		<si:interval-trigger interval="5000"/>
      	</si:poller>
          </file:inbound-channel-adapter>
      
          <file:file-to-string-transformer input-channel="inFiles" charset="utf-8" output-channel="rawXml"/>
      Thanks for the help!

      Comment


      • #4
        Sorry. I did not even notice that 'bridge' element in there when I skimmed your code before. Glad to see that you were able to remove another piece!

        Regards,
        Mark

        Comment

        Working...
        X