Announcement Announcement Module
Collapse
No announcement yet.
How to slow down message consumer? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to slow down message consumer?

    Hi all,


    There's a pollable consumer on a database backed channel. That consumer uses service activator to pull messages from channel and uploads some data using web services.
    Due to slow nature of remote server I set polling interval to 500ms. Unfortunately, remote server is down quite often (or the network link is down).
    I'd like to throttle polling when any network errors are detected.
    What I did first, was to post failed message to a channel with delayer set to 1 minute, and then back to original channel. I don't think it's a good option, because delayer keeps processing thread busy - am I right? I think that I should rather throttle consumer.

    Any hints?
    Thanks

  • #2
    Hello

    What you are dooing is correct: it is similar to "Retry Pattern" with some Circuit Breaker abilities.
    About "delayer": no, it doesn't block "processing thread". It schedule future task with calculated "delay" and returns "null" immediately.
    However "delayer" can't help you here: it delays messages, but when the delay expires messages will be sended into output-channel.
    So, in the end (here you're right) your consumer will be throttled.

    What I propose:
    1. Make poller for persistent channel like this:
    HTML Code:
    <poller max-messages-per-poll="1" fixed-delay="60" time-unit="SECONDS">
    	<transactional/>
    </poller>
    What does it mean?
    1. You poll only one message at minute
    2. Send polled message to remote server in this thread (don't transfer it to another non-direct channel)
    3. If your remote server downs, you catch Exception which rollback current transaction and message will be returned to the persistent channel

    I understand that poll messages so slowly is bad, but let it be the start point to implement good solution.

    Cheers,
    Arte Bilan

    P.S.: Circuit Breaker is the best solution for such task...

    Comment


    • #3
      Hi Cleric,

      Thanks for the Circuit Breaker - very good idea! It deserves dedicated FactoryBean :-)
      Anyway, for my initial problem. Is there any way to modify polling interval at runtime? I think that ideally, my circuit breaker implementation should modify poller's interval to slow down message consuming.

      Comment


      • #4
        Let me answer my question: http://static.springsource.org/sprin...e-polling-rate

        Comment

        Working...
        X