public synchronized int add ( final Message msg ) { final int nextKey = this . getNextPosition ( ) ; this . store . put ( nextKey , msg ) ; MessageStore . LOGGER . info ( "Message #{} stored on position #{}" , msg . getUniqueId ( ) , nextKey ) ; this . nextMessagePosition . incrementAndGet ( ) ; if ( this . store . size ( ) > this . messageLimit ) { // discard first message if we're over limit this . store . remove ( this . store . firstKey ( ) ) ; } return nextKey ; }
Add message to the storage .