magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.49k stars 9.29k forks source link

Add Amqp as a dependency for ProductAlert #35790

Open Bartiema opened 2 years ago

Bartiema commented 2 years ago

Summary (*)

If the amqp module is not installed in your magento 2.4.4 instance and you want to use the ProductAlert module functionality you will never be able to send alert emails because when the cronjob catalog_product_alert is run there will be a critical error with the message: "Publisher 'product_alert' is not declared"

Steps to reproduce

Examples (*)

.CRITICAL: Publisher 'product_alert' is not declared. [] [] is the error you can find in debug.log after running bin/magento cron:run when the cronjob catalog_product_alert is trying to send an alert.

Proposed solution

Add the amqp module as a dependency for the ProductAlert module, both in composer and in the module.xml


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

m2-assistant[bot] commented 2 years ago

Hi @Bartiema. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

engcom-Echo commented 2 years ago

@Bartiema

Thanks for reporting the issue.

As you mentioned that "amqp module is not installed " so, could you please confirm if you uninstalled or disabled the module "module-amqp" in config.php file then run the cron manually from terminal so you got that exception.

Please provide the exact steps to reproduce the same and share the screenshots so we can try to reproduce the same at our end.

Thanks,

m2-assistant[bot] commented 2 years ago

Hi @engcom-Echo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:


engcom-Echo commented 2 years ago

Hello @Bartiema,

We have noticed that this issue has not been updated for a period of 14 Days. Hence we assume that this issue is fixed now, so we are closing it.Please raise a fresh ticket or reopen this ticket if you need more assistance on this.

Thanks

norgeindian commented 1 year ago

@engcom-Echo , I can verify the issue still persists on Magento 2.4.5-p1. You can reproduce it, like @Bartiema said, by disabling Magento_Amqp and then doing the following steps:

PromInc commented 1 year ago

I can confirm the same situation.

Never needed the amqp module in the past. But it appears with v2.4.5-p1 (or maybe one of the versions prior) it is required??? Can't find any documenation to support that, but appears to be the case if you want to send product alerts...

APanteleychuk commented 1 year ago

I can confirm the same situation too.

HenKun commented 1 year ago

@engcom-Echo This issue is closed, but reproducible on 2.4.6-p2

Other modules do not need to have Magento_Amqp enabled, like Magento_Catalog with the topic product_action_attribute.update or Magento_SalesRule with topic sales_rule.codegenerator. Both modules have files etc/queue_publisher.xml and etc/queue_topology.xml, whereas Magento_ProductAlert does not provide these files. Might there be a problem?

m2-assistant[bot] commented 1 year ago

Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Hotel commented 1 year ago

Hello @norgeindian,

Thanks for the steps to reproduce the issue. We have followed the same but the issue is not reproducible for us.

The command ran successfully, it might be possible the issue is resolved in the latest 2.4-develop branch. I request you to please try to reproduce the issue in the latest development branch.

Thanks

HenKun commented 1 year ago

Note that the cron for catalog_product_alert is only scheduled once a day (depending on the settings). So not every cron:run will trigger the issue.

Furthermore, the Exception is thrown in Magento\Framework\MessageQueue\Publisher\Config::getPublisher($topic). The class comment states: "Publisher config provides access data declared in etc/queue_publisher.xml". And indeed, all modules having a communication.xml file, also have a queue_publisher.xml file, only ProductAlert module does not have this file. According to https://developer.adobe.com/commerce/php/development/components/message-queues/configuration/ and https://developer.adobe.com/commerce/php/development/components/message-queues/migration/:

If you only want to consume from an existing queue, you will only need the queue_consumer.xml config file.

Since product_alert.queue is not an existing queue, a etc/queue_topology.xml must be created. Since we want to publish to this queue, a etc/queue_publisher.xml must be created.

I can't tell why it works with activated Magento_Amqp. I have not tested it with activated Magento_Amqp. But the Reader responsible for getting the publisher config is Magento\Framework\MessageQueue\Publisher\Config\CompositeReader, which, besides reading from etc/queue_publisher.xml, also tries to get config data from Magento\WebapiAsync\Code\Generator\Config\RemoteServiceReader\Publisher and Magento\Framework\MessageQueue\Publisher\Config\RemoteService\Reader. It might be that those additional readers return an auto generated config, when Magento_Amqp is enabled, and do not when it is disabled.

engcom-Hotel commented 1 year ago

Hello @HenKun,

Thanks for the detailed explanation!

Can you please suggest to us the steps to reproduce of this issue?

Thanks

HenKun commented 1 year ago

I just can restate the steps described before: https://github.com/magento/magento2/issues/35790#issuecomment-1359054097

However when executing cron:run you have to go sure the job is actually scheduled, since this is done only once a day.

engcom-Hotel commented 1 year ago

Hello @HenKun,

Thanks for the reply!

We have tried to reproduce this issue with the mentioned steps here https://github.com/magento/magento2/issues/35790#issuecomment-1359054097 in the 2.4-develop branch, but the issue is still not reproducible for us.

We have made changes in the setting of product alert cron from the admin panel as well. Please refer to the below screenshot for reference:

image

We request you to please try to reproduce the issue in the 2.4-develop branch.

Thanks

HenKun commented 1 year ago

@engcom-Hotel Was the product alert mail actually sent? So did you receive the alert email? We have to go sure the cron job is actually executed when verifying the issue. Otherwise the issue cannot occur.

Is it possible to run a specific cronjob via CLI without it being scheduled and without using cron:run? This way we could explicitly trigger the process without depending on any cron schedule.

I cannot imagine how this can work, since the publisher is indeed just not declared, so the issue must occur.

PromInc commented 1 year ago

@HenKun to manually run this cron job from the CLI you could do this:

mysql -e "INSERT INTO cron_schedule ( job_code, scheduled_at ) VALUES ( 'catalog_product_alert', CURENT_TIMESTAMP );" && php bin/magento cron:run

This will enter a new entry into the cron_schedule table scheduled for now and then run the cron jobs. NOTE: you need to have CLI access to MySQL setup for mysql to function. You could also run the query via a GUI or any other MySQL connection you have then run the php bin/magento cron:run portion.

engcom-Hotel commented 12 months ago

Hello @PromInc,

Thanks for the missing step to reproduce the issue. Now we are able to reproduce the issue. But we are getting the mentioned error in system.log file:

image

Hence confirming the issue.

Thanks

github-jira-sync-bot commented 12 months ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-9637 is successfully created for this GitHub issue.

m2-assistant[bot] commented 12 months ago

:white_check_mark: Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

yegxr commented 11 months ago

@magento I am working on this

rostilos commented 11 months ago

@magento I am working on this