code: 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;
      }
docs: Add message to the storage.
  
  Every call will change values returned by {@link #getNextPosition()} and
  {@link #getLatestPosition()}. Any call may change value returned by
  {@link #getFirstPosition()}, which will happen if a message is discarded
  due to hitting the message store capacity.
  
  @param msg
  Message in question.
  @return Position of the message.