public void shutdown ( ) throws Exception { if ( shutdown . getAndSet ( true ) ) { throw new IllegalStateException ( "Cannot shut down a publisher already shut-down." ) ; } if ( currentAlarmFuture != null && activeAlarm . getAndSet ( false ) ) { currentAlarmFuture . cancel ( false ) ; } publishAllOutstanding ( ) ; backgroundResources . shutdown ( ) ; }
Schedules immediate publishing of any outstanding messages and waits until all are processed .