vyuldashev / laravel-queue-rabbitmq

RabbitMQ driver for Laravel Queue. Supports Laravel Horizon.
MIT License
1.87k stars 375 forks source link

Laravel with RabbitMQ, queue not shown information about exist jobs and has state - live instead idle or runnig #380

Closed shubaivan closed 3 years ago

shubaivan commented 3 years ago

Laravel with RabbitMQ, queue not shown information about exist jobs and has state - live instead idle or runnig. I guess maybe some in cofiguration queue or rabbit mq version. I used docker compose

This is what I have in UI rabbitmq

RabbitMQ 3.8.9Erlang 23.1.4

this is my dockerfile for rabbit

FROM rabbitmq:alpine

LABEL maintainer="Mahmoud Zalt <mahmoud@zalt.me>"

RUN rabbitmq-plugins enable --offline rabbitmq_management

EXPOSE 4369 5671 5672 15671 15672 25672

and docker compose

rabbitmq:
    build: ./docker/rabbitmq
    ports:
        - 5672:5672
        - 15672:15672
        - 15671:15671
    privileged: true
    environment:
        - RABBITMQ_DEFAULT_USER=${RABBITMQ_DEFAULT_USER}
        - RABBITMQ_DEFAULT_PASS=${RABBITMQ_DEFAULT_PASS}
    hostname: laradock-rabbitmq
    volumes:
        - "./docker/data/rabbitmq:/var/lib/rabbitmq"
    depends_on:
        - php
    networks:
        - network

php:
    build:
        context: .
        dockerfile: ./docker/php/Dockerfile
    restart: on-failure
    volumes:
        - "${API_PATH}:/var/www"
        - "./docker/php/php.ini:/usr/local/etc/php/conf.d/custom.ini"
        - "./docker/data/php:/var/zippertic"
    depends_on:
        - postgres
        - elasticsearch
    networks:
        - network

my composer in application

    "vladimir-yuldashev/laravel-queue-rabbitmq": "v10.2.2"
    "laravel/framework": "^6.2",
    "enqueue/amqp-bunny": "^0.8",

my queue conf

    'rabbitmq' => [

        'driver' => 'rabbitmq',

        /*
     * Set to "horizon" if you wish to use Laravel Horizon.
     */
        'worker' => env('RABBITMQ_WORKER', 'default'),

        'dsn' => env('RABBITMQ_DSN', null),

        /*
     * Could be one a class that implements \Interop\Amqp\AmqpConnectionFactory for example:
     *  - \EnqueueAmqpExt\AmqpConnectionFactory if you install enqueue/amqp-ext
     *  - \EnqueueAmqpLib\AmqpConnectionFactory if you install enqueue/amqp-lib
     *  - \EnqueueAmqpBunny\AmqpConnectionFactory if you install enqueue/amqp-bunny
     */

        'factory_class' => \Enqueue\AmqpBunny\AmqpConnectionFactory::class,

        'host' => env('RABBITMQ_HOST', '127.0.0.1'),
        'port' => env('RABBITMQ_PORT', 5672),

        'vhost' => env('RABBITMQ_VHOST', '/'),
        'login' => env('RABBITMQ_LOGIN', 'guest'),
        'password' => env('RABBITMQ_PASSWORD', 'guest'),

        'queue' => env('RABBITMQ_QUEUE', 'default'),

        'options' => [

            'exchange' => [

                'name' => env('RABBITMQ_EXCHANGE_NAME'),

                /*
             * Determine if exchange should be created if it does not exist.
             */

                'declare' => env('RABBITMQ_EXCHANGE_DECLARE', true),

                /*
             * Read more about possible values at https://www.rabbitmq.com/tutorials/amqp-concepts.html
             */

                'type' => env('RABBITMQ_EXCHANGE_TYPE', \Interop\Amqp\AmqpTopic::TYPE_DIRECT),
                'passive' => env('RABBITMQ_EXCHANGE_PASSIVE', false),
                'durable' => env('RABBITMQ_EXCHANGE_DURABLE', true),
                'auto_delete' => env('RABBITMQ_EXCHANGE_AUTODELETE', false),
                'arguments' => env('RABBITMQ_EXCHANGE_ARGUMENTS'),
            ],

            'queue' => [

                /*
             * Determine if queue should be created if it does not exist.
             */

                'declare' => env('RABBITMQ_QUEUE_DECLARE', true),

                /*
             * Determine if queue should be binded to the exchange created.
             */

                'bind' => env('RABBITMQ_QUEUE_DECLARE_BIND', true),

                /*
             * Read more about possible values at https://www.rabbitmq.com/tutorials/amqp-concepts.html
             */

                'passive' => env('RABBITMQ_QUEUE_PASSIVE', false),
                'durable' => env('RABBITMQ_QUEUE_DURABLE', true),
                'exclusive' => env('RABBITMQ_QUEUE_EXCLUSIVE', false),
                'auto_delete' => env('RABBITMQ_QUEUE_AUTODELETE', false),
                'arguments' => env('RABBITMQ_QUEUE_ARGUMENTS'),
            ],
        ],

        /*
     * Determine the number of seconds to sleep if there's an error communicating with rabbitmq
     * If set to false, it'll throw an exception rather than doing the sleep for X seconds.
     */

        'sleep_on_error' => env('RABBITMQ_ERROR_SLEEP', 5),

        /*
     * Optional SSL params if an SSL connection is used
     * Using an SSL connection will also require to configure your RabbitMQ to enable SSL. More details can be founds here: https://www.rabbitmq.com/ssl.html
     */

        'ssl_params' => [
            'ssl_on' => env('RABBITMQ_SSL', false),
            'cafile' => env('RABBITMQ_SSL_CAFILE', null),
            'local_cert' => env('RABBITMQ_SSL_LOCALCERT', null),
            'local_key' => env('RABBITMQ_SSL_LOCALKEY', null),
            'verify_peer' => env('RABBITMQ_SSL_VERIFY_PEER', true),
            'passphrase' => env('RABBITMQ_SSL_PASSPHRASE', null),
        ],
    ],

my .env

QUEUE_CONNECTION=sync

RABBITMQ_HOST=rabbitmq
RABBITMQ_PORT=5672
RABBITMQ_VHOST=/
RABBITMQ_LOGIN=guest
RABBITMQ_PASSWORD=guest
RABBITMQ_QUEUE=queue_handling_email

RABBITMQ_EXCHANGE_NAME=exchange_handling_email
RABBITMQ_EXCHANGE_DECLARE=
RABBITMQ_EXCHANGE_TYPE=direct
RABBITMQ_EXCHANGE_PASSIVE=
RABBITMQ_EXCHANGE_DURABLE=
RABBITMQ_EXCHANGE_AUTODELETE=
RABBITMQ_EXCHANGE_ARGUMENTS=default

RABBITMQ_QUEUE_DECLARE=
RABBITMQ_QUEUE_DECLARE_BIND=
RABBITMQ_QUEUE_PASSIVE=
RABBITMQ_QUEUE_DURABLE=
RABBITMQ_QUEUE_EXCLUSIVE=
RABBITMQ_QUEUE_AUTODELETE=
RABBITMQ_QUEUE_ARGUMENTS=default

RABBITMQ_ERROR_SLEEP=5

RABBITMQ_SSL=
RABBITMQ_SSL_CAFILE=
RABBITMQ_SSL_LOCALCERT=
RABBITMQ_SSL_LOCALKEY=
RABBITMQ_SSL_VERIFY_PEER=
RABBITMQ_SSL_PASSPHRASE=

and what I hade in rabbitmq UI, without 'Messages' info, how many jobs ready

enter image description here

but I expected 'idle' state with ready counter for jobs if I did not executed some worker and expect 'running' state when I executed some worker.

this is how I send job in my connection in chanel

        SendEmailJob::dispatch($oneBy)
            ->onConnection('rabbitmq')
            ->onQueue('queue_handling_email');

Steps To Reproduce

What steps needed, to reproduce this bug.

Current behavior

jobs are created and executed if execute artisan rabbitmq:consume rabbitmq --queue=queue_handling_email but tab rabbitmq UI tabs Messages | Message rates not presented and queue has state live

Expected behavior

`Messages | Message rates tabs should be present adn sate should be idle or running if worker was execute

adm-bome commented 3 years ago

First off... Your library config is the wrong one.

As of version 10 the library internals have changed drastically.

The library was a library that did "almost" everything from the perspective view of RabbitMQ. (how rabbitMQ handles queuing) As of version 10: the point of view has been changed/transferred to follow the Laravel idea/perspective of queuing.

The library now is more inline with Laravel's QueueAPI and is (by default) now a drop-in replacement (driver), so you can also use RabbitMQ as message-broker. It also has a couple of features that are specific to RabbitMQ. so you can benefit from most features rabbitMQ holds.

adm-bome commented 3 years ago

I'm closing the issue ;) I don't think you have a bug, rather then a configuration error.

But when your'e convinced it is a bug, please let us know.