public function queue($type = null, $retry = 3000) {
		$this->response->disableCache();
		Configure::write('debug', 0);
		if (!$this->request->is('sse')) {
			throw new BadRequestException();
		}

		$type = (string)$type;
		$result = [
			'type' => '',
			'progress' => 0,
			'msg' => '',
			'result' => null
		];
		$event = 'progressBar';
		$retry = (int)$retry;
		if (empty($type)) {
			$data = json_encode($result);
			$this->set(compact('retry', 'data', 'event'));

			return;
		}

		$timestamp = null;
		$workermaxruntime = (int)Configure::read('Queue.workermaxruntime');
		if ($workermaxruntime > 0) {
			$timestamp = time() - $workermaxruntime;
		}
		$jobInfo = $this->ExtendQueuedTask->getPendingJob($type, true, $timestamp);
		if (empty($jobInfo)) {
			$result['type'] = $type;
			$result['result'] = false;
			$data = json_encode($result);
			$this->set(compact('retry', 'data', 'event'));

			return;
		}

		switch ($jobInfo['ExtendQueuedTask']['status']) {
			case 'COMPLETED':
				$resultFlag = true;
				break;
			case 'NOT_READY':
			case 'NOT_STARTED':
			case 'FAILED':
			case 'UNKNOWN':
				$resultFlag = false;
				break;
			case 'IN_PROGRESS':
			default:
				$resultFlag = null;
		}
		$result['type'] = $type;
		$result['progress'] = (float)$jobInfo['ExtendQueuedTask']['progress'];
		$result['msg'] = (string)$jobInfo['ExtendQueuedTask']['failure_message'];
		$result['result'] = $resultFlag;
		$data = json_encode($result);
		$this->set(compact('retry', 'data', 'event'));
	}