code: public void removeFromQueue(T t) {
          synchronized (messages) {
              for (Map.Entry<Long, Message> messageEntry : messages.entrySet()) {
                  if (messageEntry.getValue().equals(t)) {
                      Message message = messages.remove(messageEntry.getKey());
                      recycle(message);
                      notifyQueueChanged();
                      return;
                  }
              }
          }
      }
docs: Removing message from queue
  
  @param t message