code: public Command receiveCommand(String queueName, long timeout) {
  
          try {
              Message message = receiveMessage(queueName, timeout);
              if(message == null){
                  return null;
              }else{
                  Command command;
                  if(binaryMode){
                      command = Command.fromBytes(getBytes((BytesMessage) message));
                  }else {
                      command = Command.fromXml(((TextMessage)message).getText());
                  }
                  command.setJMSMessageID(message.getJMSMessageID());
                  return command;
              }
          } catch (Exception e) {
              throw new AsyncException("Could not get command", e);
          }
      }
docs: Receives a command from a queue synchronously. If this queue also has listeners, then commands will be distributed across
  all consumers.
  
  @param queueName name of queue
  @param timeout timeout in milliseconds. If a command is not received during a timeout, this methods returns null.
  
  @return command if found. If command not found, this method will block till a command is present in queue or a timeout expires.