Incorrect logic in throttle method of DeliveryChannelImpl.java 
---------------------------------------------------------------

                 Key: SM-1937
                 URL: https://issues.apache.org/activemq/browse/SM-1937
             Project: ServiceMix
          Issue Type: Improvement
          Components: servicemix-core
            Reporter: Alexander Zobkov
            Priority: Minor
             Fix For: 3.3


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

{code}
    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++;
        }
    }
{code}

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:

{code}
    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++;
        }
    }
{code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to