Mubin Mubin - 29 days ago 22
PHP Question

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

Answer

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();
}
Comments