Getting error while publish message to RabbitMQ
-
15-04-2021 - |
Question
Getting error while publish message to RabbitMQ :The connection timed out after 3 sec while awaiting incoming data.
use Magento\Framework\MessageQueue\PublisherInterface;
$this->publisher->publish('watcher_order_attribute.update', $this->serializer->serialize($publishData));
COMMUNICATION.XML
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Communication/etc/communication.xsd">
<topic name="watcher_order_attribute.update" request="string" />
</config>
queue_topology.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/topology.xsd">
<exchange name="magento" type="topic" connection="amqp">
<binding id="uniqueIdBinding" topic="watcher_order_attribute.update" destinationType="queue" destination="WatcherQueue"/>
</exchange>
</config>
queue_consumer.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/consumer.xsd">
<consumer name="vendor.WatcherQueue" queue="WatcherQueue" connection="amqp" consumerInstance="Magento\Framework\MessageQueue\Consumer" handler="Vendor\MyQueue\Model\Watcher\Attribute\Consumer::process" />
</config>
queue_publisher.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/publisher.xsd">
<publisher topic="watcher_order_attribute.update">
<connection name="amqp" exchange="magento" />
</publisher>
</config>
'amqp' => [
'host' => '127.0.0.1',
'port' => '15672',
'user' => 'guest',
'password' => 'guest',
'virtualhost' => '/'
]
Solution
Can you please update your app/etc/env.php file code, and set the below code.
'queue' => [
'amqp' => [
'host' => '127.0.0.1',
'port' => '5672',
'user' => 'guest',
'password' => 'guest',
'virtualhost' => '/'
]
]
Let me know it works. Actually, You have set the wrong port.
Note: After updating run the basic CLI command.
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f
php bin/magento indexer:reindex
php bin/magento cache:clean
php bin/magento cache:flush
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange