delete

@param QueueMessage|string $message

@return static
@internal param null $queue
9713
public function delete(QueueMessage $message)
    {
        $this->client->deleteMessage(
            [
                'QueueUrl' => $this->getQueueUrl($message->getQueueName()),
                'ReceiptHandle' => $this->getReceiptHandle($message),
            ]
        );

        return $this;
    }
1097730
public function push(QueueMessage $message)
    {
        $time = new \DateTimeImmutable('now');

        $data = [
            'queue' => $message->getQueueName() ?: $this->queue,
            'body' => json_encode($message),
            'attempts' => 0,
            'created' => $time->format('Y-m-d H:i:s'),
            'visibility' => $time->modify(sprintf('+%dseconds', $message->getDelay()))->format('Y-m-d H:i:s'),
            'reserved' => null,
        ];

        $this->db->getWriter()->insertOne($this->table, $data, 'id');

        return $data['id'];
    }
216350
protected function setQueue(Queue $queue)
    {
        $this->queue = $queue;
        $this->queue->setProducer($this);

        return $this;
    }
320161
public function pop($queue = null)
    {
        $this->migrate($prefixed = $this->getQueue($queue));

        if (empty($nextJob = $this->retrieveNextJob($prefixed))) {
            return;
        }

        [$job, $reserved] = $nextJob;

        if ($reserved) {
            return new RedisJob(
                $this->container, $this, $job,
                $reserved, $this->connectionName, $queue ?: $this->default
            );
        }
    }
726116
public function pop($queue = null)
    {
        $original = $queue ?: $this->default;

        $queue = $this->getQueue($queue);

        if (!is_null($this->expire)) {
            $this->migrateAllExpiredJobs($queue);
        }
        $job = $this->getConnection()->lPop($queue);

        if ($job) {
            $this->getConnection()->zAdd($queue . ':reserved', $this->getTime() + $this->expire, $job);

            return new PHPRedisJob($this->container, $this, $job, $original);
        }
    }
1025472
public function release(QueueMessage $message)
    {
        $this->client->changeMessageVisibility(
            [
                'QueueUrl' => $this->getQueueUrl($message->getQueueName()),
                'ReceiptHandle' => $this->getReceiptHandle($message),
                'VisibilityTimeout' => $message->getDelay(),
            ]
        );

        return $this;
    }
1229778
public function push(QueueMessage $message)
    {
        $job = $message->getJob();
        /** @var JobInterface $job */
        $job = unserialize($job);

        $job->execute();

        return 0;
    }
1239456
protected function getNextMessage($queue)
    {
        $queue = (array) $queue;

        foreach ($queue as $queueName) {
            if ($message = $this->manager->pop($queueName)) {
                return $message;
            }
        }

        return null;
    }
1162738
public function pop($queue = null)
    {
        $queue = $this->getQueue($queue);

        $job = $this->pheanstalk->watchOnly($queue)->reserve(0);

        if ($job instanceof Pheanstalk_Job) {
            return new BeanstalkdJob($this->container, $this->pheanstalk, $job, $queue);
        }
    }
1046658
public function encodeMessage($message, $queue)
    {
        $messageFactory = $this->getMessageFactory();

        if (!$this->messageFactory->accepts($message)) {
            throw new Exception\RuntimeException(
                sprintf(
                    '%s does not accept message of type "%s"',
                    get_class($messageFactory),
                    (is_object($message) ? get_class($message) : gettype($message))
                )
            );
        }

        return new BernardDefaultMessage(
            $queue,
            array(
                self::MESSAGE_CLASS_KEY => get_class($message),
                self::MESSAGE_KEY => $this->getMessageFactory()->toArray($message),
            )
        );
    }
556825
public function indexQueuedItem(QueueMessage $message)
    {
        $log = $this->getLogger();
        $context = array(
            'engine' => get_class($this->_searchEngine),
            'item' => $message->getBody(),
        );

        // Load the source data form the message. The message usually contains a
        // unique identifier in the body. Skip processing if false is returned
        // as the source data.
        $collection = $message->getCollection();
        $data = $collection->loadSourceData($message);

        if ($data) {
            $context['collection'] = $collection->getId();
            $log->debug('Data fetched from source', $context);

            // Build an index document from the source data.
            $document = $this->_searchEngine->newDocument($this);
            $collection->buildDocument($document, $data);
            $log->debug('Document prepared for indexing', $context);

            // Index the document, sandwich indexing with events.
            $event = new IndexDocumentEvent($this, $document, $data);
            $this->dispatchEvent(SearchEvents::DOCUMENT_PRE_INDEX, $event);
            $this->_searchEngine->indexDocument($collection, $document);
            $this->dispatchEvent(SearchEvents::DOCUMENT_POST_INDEX, $event);

            $log->debug('Document processed for indexing', $context);

        } else {
            $log->critical('Data could not be loaded from source', $context);
        }
    }
641476
public function release(QueueMessage $message)
    {
        $queue = $message->getQueueName() ?: $this->queue;

        $time = new \DateTimeImmutable('now');
        $time = $time->modify('+' . $message->getDelay() . 'seconds');

        $values = [
            'reserved' => null,
            'visibility' => $time->format('Y-m-d H:i:s'),
        ];

        $this->db->getWriter()->updateBatch(
            $this->table,
            $values,
            [
                'id' => $message->getId(),
                'queue' => $queue,
            ]
        );

        return $this;
    }
1033142
public function push(QueueMessage $message)
    {
        $queue = $message->getQueueName() ?: $this->queue;

        $this->queueDeclare($queue);

        $options = [
            'delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT,
        ];

        if ($message->getDelay() > 0) {
            $options['application_headers'] = new AMQPTable(
                [
                    'x-delay' => $message->getDelay(),
                ]
            );
        }

        $msg = new AMQPMessage(json_encode($message), $options);

        $this->channel->basic_publish($msg, '', $queue);

        return 1;
    }
1299990
public function pop($queue)
    {
        //migrate the retry jobs
        $this->migrateRetryJobs($queue);

        $data = $this->client->lpop($this->getQueueNameWithPrefix($queue));

        if (!empty($data)) {
            $job = @unserialize($data);
            if ($job instanceof AbstractJob) {
                return $job;
            }
        }

        return null;
    }
100124
public function delete(QueueMessage $message)
    {
        $queue = $message->getQueueName() ?: $this->queue;

        $query = $this->db->getQuery(true);

        $query->delete($query->quoteName($this->table))
            ->where('id = :id')
            ->where('queue = :queue')
            ->bind('id', $message->getId())
            ->bind('queue', $queue);

        $this->db->setQuery($query)->execute();

        return $this;
    }
366962
public function pop($queue = null)
    {
        return tap(parent::pop($queue), function ($result) use ($queue) {
            if ($result) {
                $this->event($this->getQueue($queue), new JobReserved($result->getReservedJob()));
            }
        });
    }
1158684
public function pop($queue = null)
    {
        $queue = $queue ?: $this->queue;

        $this->queueDeclare($queue);

        $this->channel->basic_qos(null, 1, null);
        $result = $this->channel->basic_get($queue, false);

        if (!$result) {
            return null;
        }

        $message = new QueueMessage();

        $message->setId(0);
        $message->setBody(json_decode($result->body, true));
        $message->setRawBody($result->body);
        $message->setQueueName($queue ?: $this->queue);

        // Delivery tag
        $message->set('delivery_tag', $result->delivery_info['delivery_tag']);

        // Attempts
        $attempts = $message->get('attempts', 0) + 1;

        $message->setAttempts($attempts);
        $message->set('attempts', $attempts);

        return $message;
    }