code: public Map<Long, Data> drain(int maxSize) {
          int maxSizeParam = maxSize;
          if (maxSizeParam < 0 || maxSizeParam > getItemQueue().size()) {
              maxSizeParam = getItemQueue().size();
          }
          Map<Long, Data> map = createLinkedHashMap(maxSizeParam);
          mapDrainIterator(maxSizeParam, map);
          if (store.isEnabled() && maxSizeParam != 0) {
              try {
                  store.deleteAll(map.keySet());
              } catch (Exception e) {
                  throw new HazelcastException(e);
              }
          }
          long current = Clock.currentTimeMillis();
          for (int i = 0; i < maxSizeParam; i++) {
              QueueItem item = getItemQueue().poll();
              // for stats
              age(item, current);
          }
          if (maxSizeParam != 0) {
              scheduleEvictionIfEmpty();
          }
          return map;
      }
docs: Removes items from the queue and the queue store (if configured), up to {@code maxSize} or the size of the queue,
  whichever is smaller. Also schedules the queue for destruction if it is empty or destroys it immediately if it is
  empty and {@link QueueConfig#getEmptyQueueTtl()} is 0.
  
  @param maxSize the maximum number of items to be removed
  @return the map of IDs and removed (drained) items