Laravel Pull Queue

523 Views Asked by At

I have been using the Laravel framework and have just recently gotten into implementing queue's with Laravel's built in support for IronMQ.

From the Laravel documentation its easy enough to see how to push messages to a queue and then on Iron.io set subscribers and have the queue push to those subscribers. However I want to utilize IronMQ as a Pull queue. I do not see any indication of how to pull a message from a specified queue using Laravel's built in methods.

On the IronMQ site they have all the endpoints listed related to facilitate a Pull queue implementation.

Ex: /projects/{Project ID}/queues/{Queue Name}/messages

In the IronMQ package for Laravel I see the methods that seem to work with these endpoints:

/**
 * Peek Messages on a Queue
 * Peeking at a queue returns the next messages on the queue, but it does not reserve them.
 *
 * @param string $queue_name
 * @return object|null  message or null if queue is empty
 */
public function peekMessage($queue_name) {
    $messages = $this->peekMessages($queue_name, 1);
    if ($messages == null) {
        return null;
    } else {
        return $messages[0];
    }
}

However, I do not see any support for this through Laravel. I would expect to be able to do something along the lines of:

$message = Queue::peek();

Which would return the next message from a specified queue, etc.

Is there a way to do this with Laravel's built in support that is just not documented?

Thanks!

Edit:

I have seen the documentation on using Daemon Workers through Laravel, however I want to process the queue myself through a cron job.

1

There are 1 best solutions below

2
On BEST ANSWER

You could try to use IronMQ class instead of laravel Queue class:

$ironmq = new \IronMQ(array(
    'token' => Config::get('queue.connections.iron.token', 'xxx'),
    'project_id' => Config::get('queue.connections.iron.project', 'xxx')
));
$ironmq->getMessage($queue_name);

IronMQ PHP lib