What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hello all, I am trying to add a test message to queue via a glue endpoint, I get the following erro

U048WDEP3R7
U048WDEP3R7 Posts: 217 πŸ§‘πŸ»β€πŸš€ - Cadet
edited November 2022 in Help

Hello all,

I am trying to add a test message to queue via a glue endpoint, I get the following error:

 Glue.ERROR: Default queue connection not found. You can fix this by adding `RabbitMqEnv::RABBITMQ_DEFAULT_CONNECTION = true` in your queue connection in `config_*.php` files {"trace":"#0 /data/vendor/spryker/rabbit-mq/src/Spryker/Client/RabbitMq/Model/Connection/ConnectionManager.php(163): Spryker\\Client\\RabbitMq\\Model\\Connection\\ConnectionManager->getDefaultQueueConnectionTransfer() ...

I just have the following code in the getAction() method of resource controller which leads the the error above.

 $queueData[] = (new QueueSendMessageTransfer())->setBody("hello!");

        $queueClient = $this->getFactory()->getQueueClient();
        $queueClient->sendMessages(
            AntelopesImportRestApiConstants::ANTELOPE_API_IMPORT_QUEUE,
            $queueData
        );

        return $response;

Can someone please help?

Comments

  • Alberto Reyer
    Alberto Reyer Posts: 690 πŸͺ - Explorer

    Probably the queue you try to publish to does not exist.
    You can try to create it with docker/sdk console queue:setup

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UL6DGRULR I tried running docker/sdk console queue:setup The queue exists. I can see it in RabbitMQ url.

  • Alberto Reyer
    Alberto Reyer Posts: 690 πŸͺ - Explorer

    If you didn't modified the config_default from the demoshop in terms of RABBITMQ_CONNECTIONS there should be at least one:

    $config[RabbitMqEnv::RABBITMQ_CONNECTIONS] = array_map(static function ($storeName) {
        return [
            RabbitMqEnv::RABBITMQ_CONNECTION_NAME => $storeName . '-connection',
            RabbitMqEnv::RABBITMQ_HOST => 'localhost',
            RabbitMqEnv::RABBITMQ_PORT => '5672',
            RabbitMqEnv::RABBITMQ_PASSWORD => 'mate20mg',
            RabbitMqEnv::RABBITMQ_USERNAME => $storeName . '_development',
            RabbitMqEnv::RABBITMQ_VIRTUAL_HOST => '/' . $storeName . '_development_zed',
            RabbitMqEnv::RABBITMQ_STORE_NAMES => [$storeName],
            RabbitMqEnv::RABBITMQ_DEFAULT_CONNECTION => $storeName === APPLICATION_STORE,
        ];
    }, $stores);
    
  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UL6DGRULR I am sorry I am a beginner so I do not understand what you mean. I have all the default config files that come with B2C demo shop running on docker:

  • Alberto Reyer
    Alberto Reyer Posts: 690 πŸͺ - Explorer

    You could try to debug from \Spryker\Client\RabbitMq\Model\Connection\ConnectionManager::getDefaultConnection why it does not work.

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UL6DGRULR Thanks for the help. I think the problem is we can not use Queue depensies in Glue's scope. So Glue should talk to a module in Zed for such operations. I am going to try it in Zed and see if it works.

  • U03V0SXHU13
    U03V0SXHU13 Posts: 8 πŸ§‘πŸ»β€πŸš€ - Cadet

    As you said, Glue should talk to Zed via the Client, which in turn talks to the Queue. A good picture that shows this is here: https://spryker.s3.eu-central-1.amazonaws.com/docs/Glue+API/Glue+API+Developer+Guides/Glue+Infrastructure/communication.png

  • Alberto Reyer
    Alberto Reyer Posts: 690 πŸͺ - Explorer

    It's possible to publish events to the queue from Glue, in one project we cloned glue and have build a asynchronous API using the queue. But it was a good amount of work (several weeks) to end up with a working solution. So as long as you don't really need to publish from Glue to the Queue it might be easier to call Zed and Zed will put the event in the queue, if you need a queue at all

  • U03V0SXHU13
    U03V0SXHU13 Posts: 8 πŸ§‘πŸ»β€πŸš€ - Cadet

    yeah technically a client can talk directly to the Queue

  • U03V0SXHU13
    U03V0SXHU13 Posts: 8 πŸ§‘πŸ»β€πŸš€ - Cadet

    but in terms of best practices it is recommended to go via Zed I guess

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 πŸ§‘πŸ»β€πŸš€ - Cadet

    Thank you very much @U03V0SXHU13 and @UL6DGRULR