Please create a Magento 2 module with the namespace Assessment\SimpleQueue. Minimum requirements are Magento >= 2.4.7 and PHP >= 8.1.
This module should implement Magento's native Message Queue Framework to publish and consume messages. Either a MySQL or AMQP queue adapter is acceptable — the implementation should be adapter-agnostic.
You will create three entry points, each of which publishes a message to the same queue:
1. REST Endpoint
- Route:
POST /V1/simple-queue/publish - Should return a
200response with the bodyOK
2. CLI Command
- Command:
bin/magento simple-queue:publish
3. Product Page Observer
- Observe the appropriate controller event when a product detail page is viewed
Each entry point should publish the following payload:
$payload = json_encode(["datetime" => date(DATE_ATOM)]);Consumer
Your consumer should process messages from the queue and log the following to var/log/consumer.log:
Message published at [publish_time] and consumed at [consumed_time]
This module simulates a lightweight analytics observation layer — imagine each entry point is an event source reporting into a central pipeline. As you build this out, consider whether each of these three event sources would behave the same way in a production environment. Be prepared to discuss your thinking.
- KISS — keep it simple, stupid.
- Single Responsibility — each class should do one thing
Use your own local Magento development environment to build and test your module. When complete, create a repository containing only the Assessment\SimpleQueue module code and share the link for review.
Your testing instructions should explain how to drop the module into an existing Magento installation and verify it works.
Code will be reviewed for style, readability, and adherence to best practices. Functionally this is pass/fail, but the details matter:
- Is your code consistent and well-formatted?
- Are PSRs 3, 4, and 12 followed?
- Are your setup instructions clear enough to test blindly?
Your time is appreciated. If you cut a corner, say so in a comment — explain what you did and how you'd improve it with more time. That kind of honesty is valued as well as balancing time, effort and complexity.
Replace this section with your own step-by-step instructions for installing and verifying your module. Assume the reviewer is starting from a clean environment and your job is to instruct them to thoroughly check, review and test your work.