Mubin
Mubin

Reputation: 4425

get total number of queued jobs laravel -- RabbitMQ

new to Laravel, I'm using RabbitMQ with it, So, what I want is to get total number of queued jobs in some specific queue.

here are my connection details

RABBITMQ_HOST=Server
RABBITMQ_PORT=5672
RABBITMQ_VHOST=/
RABBITMQ_LOGIN=user
RABBITMQ_PASSWORD=password
RABBITMQ_QUEUE=testQueue
RABBITMQ_EXCHANGE_NAME=testExchnge

any clue, or pointing to some tutorial to get total queued jobs.

Thanks

Upvotes: 0

Views: 1404

Answers (2)

Tuncay Elvanagac
Tuncay Elvanagac

Reputation: 1342

But What about the get a specific queue?

Like; /api/queues/vhost/name/get

It is accepted parameters following;

{"count":5,"ackmode":"ack_requeue_true","encoding":"auto","truncate":50000}

Upvotes: 0

Mubin
Mubin

Reputation: 4425

for any other, who is looking for the same thing, found a solution. Hope this will help.

I found the nice Rrabbit MQ HTTP API. There are a lot of endpoints there.

To get the messages from Queues, here is my code.

//laravel[lumen] based code.
public function loadQueueStats()
{
    $url = "http://" . env('RABBITMQ_HOST', '127.0.0.1') . ":" . env('RABBITMQ_PORT', 15672) . "/api/queues";
    $username = env('RABBITMQ_LOGIN', 'guest');
    $password = env('RABBITMQ_PASSWORD', 'guest');
    $response = $this->guzzle->get(
        $url,
        [
            'auth' => [
                $username,
                $password
            ],
        ]
    );
    return $response->json();
}

Upvotes: 1

Related Questions