First of all, I am not new to Magento 2 development, I know how to create modules. However, I struggle for 3 days now to get a simple Message Queue in Magento 2 to work. Here are my XML files:
communication.xml:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Communication/etc/communication.xsd">
<topic name="erp.queue.order"
request="string">
<handler name="erp.queue.order"
type="TimoGOrderTransferModelQueueConsumer"
method="process" />
</topic>
</config>
queue_consumer.xml:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/consumer.xsd">
<consumer name="erp.queue.order"
queue="erp.queue.order"
connection="db"
handler="TimoGOrderTransferModelQueueConsumer::process"/>
</config>
queue_publisher.xml:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/publisher.xsd">
<publisher topic="erp.queue.order">
<connection name="db"
exchange="magento-db"
disabled="false"/>
</publisher>
</config>
queue_topology.xml:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/topology.xsd">
<exchange name="magento-db"
type="topic"
connection="db">
<binding id="TimoGErpOrderTransfer"
topic="erp.queue.order"
destinationType="queue"
destination="erp.queue.order"/>
</exchange>
</config>
So adding messages to the queue works (I see it in the database table “queue_message”), however when I execute php bin/magento queue:consumers:start erp.queue.order
I always get the following exception:
Type Error occurred when creating object: MagentoFrameworkMessageQueueConsumerConfigData, Argume
nt 2 passed to MagentoFrameworkReflectionTypeProcessor::resolveFullyQualifiedClassName() must be o
f the type string, null given, called in /Users/timog/Sites/magento2.local/vendor/magento/fra
mework/Reflection/TypeProcessor.php on line 545
My consumer test code:
<?php
namespace TimoGOrderTransferModelQueue;
use Exception;
use PsrLogLoggerInterface;
use MagentoFrameworkSerializeSerializerJson;
class Consumer
{
private $_logger;
private Json $_json;
public function __construct(
LoggerInterface $logger,
Json $json
)
{
$this->_json = $json;
$this->_logger = $logger;
}
public function process($request)
{
try {
$test = $this->_json->unserialize($request);
} catch (Exception $exc) {
$this->_logger->critical($exc->getMessage());
}
}
}
I have no idea what’s wrong and I really need help please… it’s frustrating…
Thank you!