Search code examples
phpsymfonyserviceyamlrabbitmq

Fix error: Class %old_sound_rabbit_mq.producer.class% does not exist from OldSoundRabbitMqExtension.php


I'm trying to execute symfony project with a rabbitmq plugin. The problem it's when i execute the command: php bin/console rabbitmq:consumer -m 50 activity-logs. The response is:

OldSoundRabbitMqExtension.php line 677: Class %old_sound_rabbit_mq.producer.class% does not exist

I add the conexion info to services.yaml

old_sound_rabbit_mq:
connections:
    default:
        host:     'localhost'
        port:     5672
        user:     'user'
        password: 'pass'
        vhost:    '/'
        lazy:     false
        connection_timeout: 3
        read_write_timeout: 3

        # requires php-amqplib v2.4.1+ and PHP5.4+
        keepalive: false

        # requires php-amqplib v2.4.1+
        heartbeat: 0

        #requires php_sockets.dll
        use_socket: true # default false
    another:
        # A different (unused) connection defined by an URL. One can omit all parts,
        # except the scheme (amqp:). If both segment in the URL and a key value (see above)
        # are given the value from the URL takes precedence.
        # See https://www.rabbitmq.com/uri-spec.html on how to encode values.
        url: 'amqp://guest:password@localhost:5672/vhost?lazy=1&connection_timeout=6'
producers:
    upload_picture: #this are ignored by the moment, only want the consumers
        connection:            default
        exchange_options:      {name: 'upload-picture', type: direct}
        service_alias:         TestService # no alias by default
        default_routing_key:   'optional.routing.key' # defaults to '' if not set
        default_content_type:  'content/type' # defaults to 'text/plain'
        default_delivery_mode: 2 # optional. 1 means non-persistent, 2 means persistent. Defaults to "2".
consumers: #here my consumers, that i really need
    activty_log:
        connection:       default
        exchange_options: {name: 'la.1.activity.activity_to_save', type: direct}
        queue_options:    {name: 'la.1.activity.activity_to_save'}
        callback:         TestService #activity_log_service

And i had a dummy service to recipe the callback:

    <?php
// src/Service/MessageGenerator.php
namespace App\Service;


class TestService
{
    public function __construct(
        $entityManager,
        $producer
    ) {
        dd("hi constructor", $entityManager, $producer);
    }
    // ...

    public function testFunct(){
        dump("hello dummy!");
    }

    /*public function getConnectionParameters() {
        return array('vhost' => $this->getVhost());
    }*/

}

I know that when the command execute the read of rabbitMq and services recipe the info from the queue messages. But look like that the message is wrong.

I test to insert the messages into the queue manually to read it, but the bug it's the same.

Any ideas? What could be?


Solution

  • The problem was into the configuration:

    enter image description here

    how i don't use the producers, if you give wrong configuration broke the execution.