Camel
  1. Camel
  2. CAMEL-2206

Addition of 'Sample' Throttling strategy

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.1.0
    • Component/s: camel-core, camel-spring
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      I've been using a different kind of sampling based throttling pattern recently and figured others might find it useful. The basic premise is the same as the current throttler, there is a consumer downstream that has specific requirements as to how fast it can process incoming exchanges and a mechanism is required to 'throttle' the exchanges inbound to it. The difference between the current throttler implementation and the sampling throttler is that where the current throttler queues up all the exchanges it receives, the sampling throttler will allow only a single exchange through for a period and 'drop' all others; dropped exchanges being passed to a stop processor to complete them.

      Its been useful for situations where a route receives many semantically equivalent exchanges in a time period, any single one of which could be used to represent them all. For example, say an upstream component generates a stream of warning alarms and sends these to an email processor to inform the operator. An email for each alarm would be overkill instead one every x minutes or so would be preferred. Also it would be undesirable for the throttler to queue up these warning alarms as when the upstream component ceases sending them the emails should cease. Sampling the warnings would pick one for each x minute period, and stop the rest.

      This would be defined via the java dsl as follows

      from("direct:alarm-notifier").sample(60, TimeUnit.SECONDS).to("direct:alarm-emailer")

      or

      from("direct:alarm-notifier").sample().samplePeriod(1).timeUnits(TimeUnit.SECONDS).to("direct:alarm-emailer")

      or with a default of one per second

      from("direct:alarm-notifier").sample().to("direct:alarm-emailer")

      In spring xml it looks like

      <route>
        <from uri="direct:sample" />
        <sample>
          <to uri="mock:result" />
        </sample>
      </route>
      

      or

      <route>
        <from uri="direct:sample" />
        <sample samplePeriod="1" units="seconds">
          <to uri="mock:result" />
        </sample>
      </route>
      

      If this patch is accepted, I'd be happy to update the wiki with the required documentation. As per ususal I've split the patches, one for core and one for spring

      1. sampling-patch-spring.txt
        4 kB
        Stephen Gargan
      2. sampling-patch-core-with-stats.txt
        19 kB
        Stephen Gargan
      3. sampling-patch-core-with-javadoc.txt
        18 kB
        Stephen Gargan
      4. sampling-patch-core.txt
        16 kB
        Stephen Gargan
      5. sampling-patch-core.txt
        18 kB
        Stephen Gargan

        Activity

        Jeff Turner made changes -
        Project Import Sat Nov 27 00:14:50 EST 2010 [ 1290834890113 ]
        Claus Ibsen made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Claus Ibsen made changes -
        Fix Version/s 2.1.0 [ 12002 ]
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.2.0 [ 12170 ]
        Claus Ibsen made changes -
        Assignee Claus Ibsen [ davsclaus ]
        Stephen Gargan made changes -
        Attachment sampling-patch-core-with-stats.txt [ 18670 ]
        Claus Ibsen made changes -
        Fix Version/s 2.1.0 [ 12002 ]
        Affects Version/s 2.1.0 [ 12002 ]
        Priority Minor [ 4 ] Major [ 3 ]
        Stephen Gargan made changes -
        Stephen Gargan made changes -
        Attachment sampling-patch-core.txt [ 18663 ]
        Claus Ibsen made changes -
        Issue Type Improvement [ 4 ] New Feature [ 2 ]
        Fix Version/s 2.2.0 [ 12170 ]
        Fix Version/s 2.1.0 [ 12002 ]
        Stephen Gargan made changes -
        Field Original Value New Value
        Attachment sampling-patch-core.txt [ 18660 ]
        Attachment sampling-patch-spring.txt [ 18661 ]
        Stephen Gargan created issue -

          People

          • Assignee:
            Claus Ibsen
            Reporter:
            Stephen Gargan
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development