code: public ReceivedMessageTask getTaskToProcess() {
          ReceivedMessageTask task = tasks.peek();
          if (task != null && task.setProcessing()) {
              return task;
          }
          return null;
      }
docs: Gets first task from queue if it can be processed. If first task is already in process it returns null.
  
  @return task that can be processed or null otherwise