public int flush ( final LogSender sender ) throws IOException , HttpException { int numSent = 0 ; int maxToSend = queue . size ( ) ; if ( 0 < maxToSend ) { AppIdentity appIdentity = appIdentityService . getAppIdentity ( ) ; while ( numSent < maxToSend ) { // get the next batch of messages int batchSize = Math . min ( maxToSend - numSent , MAX_BATCH ) ; List < LogMsg > batch = new ArrayList < LogMsg > ( batchSize ) ; for ( int i = 0 ; i < batchSize ; ++ i ) { batch . add ( queue . remove ( ) ) ; } // build the log message group LogMsgGroup group = createLogMessageGroup ( batch , platform , logger , envDetail , appIdentity ) ; // send the batch to Stackify int httpStatus = sender . send ( group ) ; // if the batch failed to transmit, return the appropriate transmission status if ( httpStatus != HttpURLConnection . HTTP_OK ) { throw new HttpException ( httpStatus ) ; } // next iteration numSent += batchSize ; } } return numSent ; }
Flushes the queue by sending all messages to Stackify