public Message < ? > receive ( MessageSelector selector , long timeout ) { long timeLeft = timeout ; Message < ? > message = receive ( selector ) ; while ( message == null && timeLeft > 0 ) { timeLeft -= pollingInterval ; if ( RETRY_LOG . isDebugEnabled ( ) ) { RETRY_LOG . debug ( "No message received with message selector - retrying in " + ( timeLeft > 0 ? pollingInterval : pollingInterval + timeLeft ) + "ms" ) ; } try { Thread . sleep ( timeLeft > 0 ? pollingInterval : pollingInterval + timeLeft ) ; } catch ( InterruptedException e ) { RETRY_LOG . warn ( "Thread interrupted while waiting for retry" , e ) ; } message = receive ( selector ) ; } return message ; }
Consume messages on the channel via message selector . Timeout forces several retries with polling interval setting .