Uploaded image for project: 'ServiceMix'
  1. ServiceMix
  2. SM-1937

Incorrect logic in throttle method of DeliveryChannelImpl.java

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.3.1
    • 3.3.2
    • servicemix-core
    • None

    Description

      It seems something wrong with logic of the following method in DeliveryChannelImpl.java file:

          protected void throttle() {
              if (component.isExchangeThrottling()) {
                  if (component.getThrottlingInterval() > intervalCount) {
                      intervalCount = 0;
                      try {
                          Thread.sleep(component.getThrottlingTimeout());
                      } catch (InterruptedException e) {
                          LOG.warn("throttling failed", e);
                      }
                  }
                  intervalCount++;
              }
          }
      

      if user specifies positive values (default value is 1) of throttlingInterval then "if" statement is always true. So user need to specify negative values of throttlingInterval in order to not force thread sleep on each doSend method. Also it would be good to add a little bit logging here. So I propose the following modification:

          protected void throttle() {
              if (component.isExchangeThrottling()) {
                  if (component.getThrottlingInterval() < intervalCount) {
                      intervalCount = 0;
                      try {
                          long timeout = component.getThrottlingTimeout()
                          LOG.debug("throttling, sleep for: "+timeout);
                          Thread.sleep(timeout);
                      } catch (InterruptedException e) {
                          LOG.warn("throttling failed", e);
                      }
                  }
                  intervalCount++;
              }
          }
      

      Attachments

        Activity

          People

            ffang Freeman Yue Fang
            alexanderz Alexander Zobkov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: