Action `queue`. Is used to Server-Sent Events.

@param string $type Type of task
@param int $retry Repeat time of events
@throws BadRequestException if request is not `SSE`
@return void
323160
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'));
	}
895547
public function listen($exchange, $routing_key, $callback, $type = self::TYPE_TOPIC)
    {
        list ($queueName) = $this->channel->queue_declare();
        if ($type == Amqp::TYPE_DIRECT) {
            $this->channel->exchange_declare($exchange, $type, false, true, false);
        }
        $this->channel->queue_bind($queueName, $exchange, $routing_key);
        $this->channel->basic_consume($queueName, '', false, true, false, false, $callback);

        while (count($this->channel->callbacks)) {
            $this->channel->wait();
        }

        $this->channel->close();
        $this->connection->close();
    }
298933
public String requeuePendingTasksByTaskType(String taskType) {
        Preconditions.checkArgument(StringUtils.isNotBlank(taskType), "Task type cannot be blank");
        return postForEntity("tasks/queue/requeue/{taskType}", null, null, String.class, taskType);
    }
893485
public function send($type, $params) {
		if (empty($params['t']) && $type !== null) {
			$params['t'] = $type;
		}
		$params = $this->_appendDefaultParameters($params);
		$this->_client->setParameterPost($params);
		
		return $this->_client->request('POST', $params);
	}
978357
public function basicReject($deliveryTag, $reQueue)
    {
        $args = $this->frameBuilder->basicReject($deliveryTag, $reQueue);
        $this->sendMethodFrame(array(60, 90), $args);
    }
58333
protected function throwException($message, $type, $delay)
    {
        $exception = new ThrottlingException($message);

        $exception->setDelay($delay);

        $exception->setType($type);

        throw $exception;
    }
941560
function( time, type ) {
		time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
		type = type || "fx";

		return this.queue( type, function() {
			var elem = this;
			setTimeout(function() {
				jQuery.dequeue( elem, type );
			}, time );
		});
	}
239117
def retry(self, queue=None, delay=None, max_retries=None):
        

        max_retries = max_retries
        if max_retries is None:
            max_retries = self.max_retries

        if self.data.get("retry_count", 0) >= max_retries:
            raise MaxRetriesInterrupt()

        exc = RetryInterrupt()

        exc.queue = queue or self.queue or self.data.get("queue") or "default"
        exc.retry_count = self.data.get("retry_count", 0) + 1
        exc.delay = delay
        if exc.delay is None:
            exc.delay = self.retry_delay

        self._attach_original_exception(exc)

        raise exc
437483
public function onRequest($req, $res)
    {
        $this->app->event->trigger('swoole.request');

        $this->resetOnRequest();

        /** @var Sandbox $sandbox */
        $sandbox = $this->app->make(Sandbox::class);
        $request = $this->prepareRequest($req);

        try {
            $sandbox->setRequest($request);

            $sandbox->init();

            $response = $sandbox->run($request);

            $this->sendResponse($sandbox, $response, $res);
        } catch (Throwable $e) {
            try {
                $exceptionResponse = $this->app
                    ->make(Handle::class)
                    ->render($request, $e);

                $this->sendResponse($sandbox, $exceptionResponse, $res);
            } catch (Throwable $e) {
                $this->logServerError($e);
            }
        } finally {
            $sandbox->clear();
        }
    }
371030
public function retry(\Exception $e = null, $output = null, $next_retry = '+15 minutes') {
		if (self::$max_attempts > 0 AND $this->retry_attempt >= self::$max_attempts) {
			echo $output;
			throw $e;
		}

		$this->retry_attempt++;
		$this->schedule($next_retry);
	}
956293
public function runRouteMiddleware($middleware, $type)
    {
        $middlewarePath = $this->baseFolder . '/' . $this->paths['middlewares'];
        $middlewareNs = $this->namespaces['middlewares'];
        if ($type == 'before') {
            if (! is_null($middleware['group'])) {
                $this->routerCommand()->beforeAfter(
                    $middleware['group'][$type], $middlewarePath, $middlewareNs
                );
            }
            $this->routerCommand()->beforeAfter(
                $middleware[$type], $middlewarePath, $middlewareNs
            );
        } else {
            $this->routerCommand()->beforeAfter(
                $middleware[$type], $middlewarePath, $middlewareNs
            );
            if (! is_null($middleware['group'])) {
                $this->routerCommand()->beforeAfter(
                    $middleware['group'][$type], $middlewarePath, $middlewareNs
                );
            }
        }
    }
413959
protected function ssePolling($data, $eventId = 'stream', $retry = 1000): Response
    {
        return ResponseFactory::getInstance()->buildPollingSse($data, $eventId, $retry);
    }
1240951
protected function retry(\Closure $retry)
    {
        if ($this->numRetries < 1) {
            return $retry();
        }

        $firstException = null;

        for ($i = 0; $i <= $this->numRetries; $i++) {
            try {
                return $retry();
            } catch (\RiakCursorException $e) {
            } catch (\RiakConnectionException $e) {
            }

            if ($firstException === null) {
                $firstException = $e;
            }
            if ($i === $this->numRetries) {
                throw $firstException;
            }
        }
    }
464250
private function request($type, $requestParams)
	{
		$this->cleanup();

		$curl = new Curl();
		$curl->setCheckCertificates($this->configParams['strongSSL']);
		$curl->post($this->configParams['gatewayUrl'], array(
			'type'  => $type,
			'input' => $requestParams,
		));

		$this->parseErrors($curl);

		if (!$this->error || $this->error['type'] == self::C_ERROR_PROCESSING) {
			$this->response = json_decode($curl->result);
		}

	}
403557
function requeue(ddqBackendInstance, recordId, callback) {
        var record;

        record = ddqBackendInstance.getRecord(recordId);
        record.isProcessing = false;
        record.requeued = true;
        callback();
    }
196162
public RemoteSendQueue createRemoteSendQueue(String strQueueName, String strQueueType) throws RemoteException
    {
        MessageManager messageManager = this.getEnvironment().getMessageManager(this.getApplication(), true);
        BaseMessageSender sender = (BaseMessageSender)messageManager.getMessageQueue(strQueueName, strQueueType).getMessageSender();
        SendQueueSession remoteQueue = new SendQueueSession(this, sender);
        return remoteQueue;
    }
199877
public function my_dispatchEvent($type, $data)
    {
        foreach ($this->client as $client) {
            $client->dispatchEvent($type, $data);
        }
    }