Adyen / adyen-magento2

Adyen Payment plugin for Magento2
MIT License
155 stars 211 forks source link

[ECP-8518] New Implement option to use queue or cron causes error Unknown connection name amqp #2031

Closed othuress closed 1 month ago

othuress commented 1 year ago

@factorin-j https://github.com/Adyen/adyen-magento2/pull/1914 PHP 7.4 Magento 2.4.3-p2 Adyen 8.16.0 No RabbitMQ installed

Adyen configuration in Stores > Configuration > Sales > Payment Methods > Adyen > Advanced settings > Magento Order Processing > Webhook Notification Processor value cron

stack trace of the warning message in var/log/adyen/warning.log

[2023-04-04 12:52:15] AdyenLoggerTest.WARNING: Unknown connection name amqp

0 /var/www/public/vendor/magento/framework-message-queue/PublisherPool.php(143): Magento\Framework\MessageQueue\ConnectionTypeResolver->getConnectionType()

1 /var/www/public/vendor/magento/framework-message-queue/PublisherPool.php(88): Magento\Framework\MessageQueue\PublisherPool->getPublisherForConnectionNameAndType()

2 /var/www/public/vendor/adyen/module-payment/Model/Queue/Notification/Publisher.php(29): Magento\Framework\MessageQueue\PublisherPool->publish()

3 /var/www/public/vendor/adyen/module-payment/Cron/WebhookProcessor.php(130): Adyen\Payment\Model\Queue\Notification\Publisher->execute()

4 /var/www/public/vendor/adyen/module-payment/Cron/WebhookProcessor.php(84): Adyen\Payment\Cron\WebhookProcessor->doProcessWebhook()

5 [internal function]: Adyen\Payment\Cron\WebhookProcessor->execute()

6 /var/www/public/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(356): call_user_func_array()

7 /var/www/public/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(858): Magento\Cron\Observer\ProcessCronQueueObserver->_runJob()

8 /var/www/public/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(825): Magento\Cron\Observer\ProcessCronQueueObserver->tryRunJob()

9 /var/www/public/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(273): Magento\Cron\Observer\ProcessCronQueueObserver->processPendingJobs()

10 /var/www/public/vendor/magento/framework/Event/Invoker/InvokerDefault.php(88): Magento\Cron\Observer\ProcessCronQueueObserver->execute()

11 /var/www/public/vendor/magento/framework/Event/Invoker/InvokerDefault.php(74): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod()

12 /var/www/public/vendor/magento/framework/Event/Manager.php(66): Magento\Framework\Event\Invoker\InvokerDefault->dispatch()

13 /var/www/public/generated/code/Magento/Framework/Event/Manager/Proxy.php(95): Magento\Framework\Event\Manager->dispatch()

14 /var/www/public/vendor/magento/framework/App/Cron.php(86): Magento\Framework\Event\Manager\Proxy->dispatch()

15 /var/www/public/vendor/magento/module-cron/Console/Command/CronCommand.php(117): Magento\Framework\App\Cron->launch()

16 /var/www/public/vendor/symfony/console/Command/Command.php(255): Magento\Cron\Console\Command\CronCommand->execute()

17 /var/www/public/vendor/magento/framework/Interception/Interceptor.php(58): Symfony\Component\Console\Command\Command->run()

18 /var/www/public/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Cron\Console\Command\CronCommand\Interceptor->___callParent()

19 /var/www/public/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Cron\Console\Command\CronCommand\Interceptor->Magento\Framework\Interception{closure}()

20 /var/www/public/generated/code/Magento/Cron/Console/Command/CronCommand/Interceptor.php(23): Magento\Cron\Console\Command\CronCommand\Interceptor->___callPlugins()

21 /var/www/public/vendor/symfony/console/Application.php(1021): Magento\Cron\Console\Command\CronCommand\Interceptor->run()

22 /var/www/public/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand()

23 /var/www/public/vendor/magento/framework/Console/Cli.php(115): Symfony\Component\Console\Application->doRun()

24 /var/www/public/vendor/symfony/console/Application.php(149): Magento\Framework\Console\Cli->doRun()

25 /var/www/public/bin/magento(23): Symfony\Component\Console\Application->run()

26 {main} [] {"uid":"f049324"}

we are using cron and the adyen setting was correct, still we get this error message unless we disable webapisync.

factorin-j commented 1 year ago

@othuress may I ask what is the value saved in core_config_data table? You may check using this query:

SELECT value
FROM core_config_data
WHERE path LIKE '%adyen%'
  AND path LIKE '%webhook_notification_processor';

As per checking from the stack trace you provided at line # 3, Cron/WebhookProcessor.php#L130 is called. Wherein the line above it (line 129), there is a checking if the config saved is equal to queue. The useQueueProcessor method is defined in Helper/Config.php#L525-L531

You may try to remove this row in config table, or set the value to cron directly in your staging environment first and test.

Mostafa-Rafea commented 1 year ago

Hello @factorin-j!

This is the value you asked for, +-------+ | value | +-------+ | cron | +-------+

So, it is strange that when the check for queue value, it returns true.

So, you suggest we remove it this record from the table and test?

factorin-j commented 1 year ago

Hi @Mostafa-Rafea, yes you may remove and test it, since the default value from the config.xml#L30 should be cron. Please flush the config cache as well.

It's a bit weird for me that it returns true even if cron is already the value from your db. I can only think of a few possible reasons.

candemiralp commented 1 year ago

Hello @othuress & @Mostafa-Rafea,

Thank you for raising this issue and thank you for your contribution @factorin-j.

We are not able to reproduce the issue if the configuration value is set to webhook_notification_processor. As @factorin-j, mentioned, this part of the code is only being executed if the webhook_notification_processor is set to queue.

@othuress could you please verify @factorin-j's solution proposed above?

Best Regards, Can

othuress commented 1 year ago

@candemiralp I will have to ask @Mostafa-Rafea to confirm this. Regards Ola

bosch-manuel commented 1 year ago

Hello, we are facing the same issue mentioned here. Doesn't matter, if we set webhook_notification_processorto cron or null. Removing it from core_config_data entirely, doesn't also change anything.

Magento: 2.4.6-p2 Adyen Modul: 8.20.1

The logs are still spammed with info message

[2023-08-29T16:21:05.469017+00:00] main.INFO: Consumer "adyen.notification" skipped as required connection "amqp" is not configured. Unknown connection name amqp [] []

Cache is updated.

To debug this issue, we ran the cron job via vendor/bin/n98-magerun2 sys:cron:run adyen_payment_process_notification. In this way, the webhook_notification_processor is considered as expected.

wilfriedwolf commented 10 months ago

Same error here (v9.0.4) but you can (semi) easily get rid of the error, problem is, that since the consumer (adyen.notification) is defined with amqp in the module and you don't have rabbit-mq installed, then the cron job consumers_runner is trying to check if it needs to be started, noticing that you do not have amqp configured (correctly), which yields the error.

So first you need to check which consumers your instance needs by running

$ /bin/magento queue:consumers:list
product_action_attribute.update
product_action_attribute.website.update
media.storage.catalog.image.resize
[...]
adyen.notification
[...]

And then add the following lines to your env.php (or config.php if you have amqp nowhere) omitting adyen.notification

    'cron_consumers_runner' => [
        'cron_run' => true,
        'max_messages' => 1000,
        'consumers' => [
            'product_action_attribute.update',
            'product_action_attribute.website.update',
            'media.storage.catalog.image.resize',
           [...]
        ]
    ],
    'queue' => [
        'consumers_wait_for_messages' => 0
    ],

The cron will then start all necessary consumers but the one leading an error, which solves the problem.