public void update ( final int numSent ) { // Reset the last HTTP error lastHttpError = 0 ; // adjust the schedule delay based on the number of messages sent in the last iteration if ( 100 <= numSent ) { // messages are coming in quickly so decrease our delay // minimum delay is 1 second scheduleDelay = Math . max ( Math . round ( scheduleDelay / 2.0 ) , ONE_SECOND ) ; } else if ( numSent < 10 ) { // messages are coming in rather slowly so increase our delay // maximum delay is 5 seconds scheduleDelay = Math . min ( Math . round ( 1.25 * scheduleDelay ) , FIVE_SECONDS ) ; } }
Sets the next scheduled delay based on the number of messages sent