mollie / magento2

Mollie Payments for Magento 2
https://www.mollie.com
Other
98 stars 49 forks source link

Error while checking if topic is synchronous #750

Closed HyperC closed 3 months ago

HyperC commented 4 months ago

We're experiencing an issue with the upgrade to the latest version of this module (2.35.0). During the setup:upgrade we get the following error:

Error while checking if topic is synchronous

We've added the exception message, which results in:

Error while checking if topic is synchronous Topic "mollie.transaction.process" is not configured.

In the latest version, a communication.xml file has been added with this topic. Is specific configuration needed for the setup:upgrade to succeed?

Used versions

To Reproduce Steps to reproduce the behavior:

  1. Upgrade to latest version
  2. Set to production mode (run di:compile and static-content:deploy)
  3. Run setup:upgrade
  4. See error:

    Updating modules: ... Module 'Magento_MysqlMq': Error while checking if topic is synchronous

Frank-Magmodules commented 4 months ago

Hi There @HyperC ,

Thank you for opening this issue. There should no extra configuration be required to run setup:upgrade. When developing and releasing this extension, setup:upgrade is run multiple times, so we are sure that it runs fine without extra configuration. I suspect that you have an extra module or configuration set that causes this problem. Could it be that you have an extra configuration in your app/etc/env.php regarding consumers?

HyperC commented 4 months ago

@Frank-Magmodules We tried different configurations in our env.php:

    'queue' => [
        'consumers_wait_for_messages' => 0
    ],

Also tried setting that to 1, and even removing the whole queue config. All result in the same error during deployment. We don't have any queue consumers like RabbitMQ, just the Magento cron.

Frank-Magmodules commented 4 months ago

Thank you, @HyperC , for providing additional information. However, based on the details provided, we are unable to allocate the issue. Could you please share further details about your environment directly with us? This will enable us to investigate the issue more effectively together. Thank you!

Hnto commented 4 months ago

@Frank-Magmodules I can confirm that we're also having this issue during deployment. I'm still trying to debug by removing our custom modules one by one, but it still gives an error.

Frank-Magmodules commented 3 months ago

Hello @Hnto , despite previously sharing some information, we are still encountering difficulties reproducing this issue. Could you please reach out to us with additional details? Your assistance would be greatly appreciated. Thank you.

qsolutions-pl commented 3 months ago

I've reproduced this issue on 3 instances

qsolutions-pl commented 3 months ago

The source of the problem is invalid XML file communication.xml It is missing the hander node I've changed it to this:

<?xml version="1.0"?>
<!--
  ~ Copyright Magmodules.eu. All rights reserved.
  ~ See COPYING.txt for license details.
  -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Communication/etc/communication.xsd">
    <topic name="mollie.transaction.processor" is_synchronous="false" request="Mollie\Payment\Api\Data\TransactionToProcessInterface" response="boolean">
        <handler name="mollie.transaction.processor.handler" type="Mollie\Payment\Queue\Handler\TransactionProcessor" method="execute" />
    </topic>
</config>

and it works now

Frank-Magmodules commented 3 months ago

Thank you for providing a possible solution here as well, @qsolutions-pl. It's really helpful since we were unable to replicate it effectively with other merchants or locally. We'll review your suggestion and incorporate it into the upcoming release if it resolves the issue and gains approval from our end. Thanks once more! Surely we will update this ticket once the release is there!

qsolutions-pl commented 3 months ago

@Frank-Magmodules it only worked once, when Rabbit MQ is enabled, we cannot process with setup:upgrade command The configuration passed to topic is not recognized by the framework

string(26) "mollie.transaction.process"
NULL
Error while checking if topic is synchronous

NULL - is the topic configuration

here is snapshot from queue config from env.php file

    'queue' => [
        'amqp' => [
            'host' => 'localhost',
            'port' => '5672',
            'user' => 'project,
            'password' => 'projectPassword',
            'virtualhost' => 'projectHost',
            'ssl' => ''
        ],
        'consumers_wait_for_messages' => 1
    ],
qsolutions-pl commented 3 months ago

On our end we will have to disable the AMQP and run all consumers via CRON

qsolutions-pl commented 3 months ago

@HyperC on our end it turned out that it was an issue with REDIS configuration. It was not cleared upon deployments or it was not even cleared on any php bin/magento c:clean or flush commands. We ruin into this issue from time to time on various projects, but never with the RabbitMQ configuration. @Frank-Magmodules we've disabled REDIS and it works with and without the patch you have provided. Imho, this issue is not code related and can be closed.

HyperC commented 3 months ago

@qsolutions-pl Thanks for looking in to this issue! Did you re-enable redis after successful deployment? And the handler you mentioned is also not necessary then?

qsolutions-pl commented 3 months ago

@HyperC to be fair, I'm not entirely sure the handler is required. As @Frank-Magmodules mentioned, they cannot replicate the issue, nor can we on instances where we've disabled the redis for config. We have not reenabled it, most projects we handle run on a single servers (each project has it's own) with fast NVMe SSD drives, so disabling REDIS for the config cache does not affect the performance. The code worked once we added the <handler> but I guess that was related to the REDIS being clear for a moment

HyperC commented 3 months ago

@qsolutions-pl Could you maybe share your env config? Did you just add something like this to your frontend cache?

'config' => [
            'backend' => 'Magento\Framework\Cache\Backend\File',
            'backend_options' => [
                'cache_dir' => ''
            ],
        ],

Wouldn't it also be enough to just flush redis cache just before performing the setup:upgrade in the deploy script?

HyperC commented 3 months ago

@qsolutions-pl And one more question on your handler change:

<topic name="mollie.transaction.processor" is_synchronous="false" request="Mollie\Payment\Api\Data\TransactionToProcessInterface" response="boolean">
        <handler name="mollie.transaction.processor.handler" type="Mollie\Payment\Queue\Handler\TransactionProcessor" method="execute" />
    </topic>

You changed the topic name from mollie.transaction.process to mollie.transaction.processor. Was this intentional?

qsolutions-pl commented 3 months ago

it was intentional, but as I've mentioned earlier, it was not needed, once we cleared the REDIS entirely, all code worked. Maybe it is needed in earlier versions of Magento, what is your project M2 version?

HyperC commented 3 months ago

We're running the latest version 2.4.6-p4

qsolutions-pl commented 3 months ago

Are you still experiencing this error ?

HyperC commented 3 months ago

Yes. Just on our production environment unfortunately. We're going to try another deploy with a redis-cli flushall just before the setup:upgrade.

HyperC commented 3 months ago

Deploy failed again initially. I ran set:up --keep-generated manually again, and it succeeded. The only thing I fear is that future deploys will run into this issue again. But we'll see. Thanks for the help!

Frank-Magmodules commented 3 months ago

Great teamwork, gentlemen! I'm happy to see that you've reached a solution together. Just to make sure, can you confirm if we can close the issue for now, @HyperC and @qsolutions-pl? Thanks!

HyperC commented 3 months ago

@Frank-Magmodules Yes, issue can be closed :)

Frank-Magmodules commented 3 months ago

Great guys, thanks again and; happy Easter!

qsolutions-pl commented 3 months ago

Deploy failed again initially. I ran set:up --keep-generated manually again, and it succeeded. The only thing I fear is that future deploys will run into this issue again. But we'll see. Thanks for the help!

It is possible that the old release code and it's configuration was loaded from Redis - this is what happend to us.