cancel
Showing results for 
Search instead for 
Did you mean: 

Class "string" does not exists - put email Transport Object into RabbitMQ queue

Class "string" does not exists - put email Transport Object into RabbitMQ queue

Magento 2.4.4-p1 EE

PHP 8.1.7

 

I want to put email Transport Object into RabbitMQ queue.


communication.xml

<topic name="my_topic" request="Magento\Email\Model\Transport\Interceptor"/>

queue_publisher.xml

<publisher topic="my_topic">
<connection name="amqp" exchange="my_exchange"/>
</publisher>

queue_topology.xml

<exchange name="my_exchange" type="topic" connection="amqp">
<binding id="MyTest"
topic="my_topic"
destinationType="queue"
destination="my_destination"/>
</exchange>

queue_consumer.xml

<consumer name="my_test.consumer"
queue="my_destination"
connection="amqp"
handler="handler::process"/>   


Test with Magento CLI

 

app/code/Vendor/Module/Command/TestQueue.php

use Magento\Framework\Mail\Template\TransportBuilder;
use Magento\Framework\MessageQueue\PublisherInterface;
$this->transportBuilder->setTemplateIdentifier(
$this->scopeConfig->getValue(
self::XML_PATH_TEST_TEMPLATE,
ScopeInterface::SCOPE_STORE
)
)->setTemplateOptions(
[
'area' => FrontNameResolver::AREA_CODE,
'store' => Store::DEFAULT_STORE_ID,
]
)->setTemplateVars(
[
'number' => $number
]
)->setFromByScope(
$sender
)->addTo(
$recipient
);
$transport = $this->transportBuilder->getTransport(); 
try {
$this->publisher->publish('my_topic', $transport);
} catch (Exception $e) {
$this->logger->critical($e);
$output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
}
$transport->sendMessage();

 

After execution, an error message and Queue has no data

 

Class "string" does not exist

 

Any ideas? Cheers!