Skip to content
Advertisement

Magento 2 Message Queue – Type Error with expected string, null given

I struggle for 3 days now to get a simple Message Queue in Magento 2 to work. Here are my XML files:

communication.xml:

JavaScript

queue_consumer.xml:

JavaScript

queue_publisher.xml:

JavaScript

queue_topology.xml:

JavaScript

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:

JavaScript

My consumer test code:

JavaScript

I have no idea what’s wrong and I really need help please… it’s frustrating…

Thank you!

Advertisement

Answer

Probably, after more than 3 months, you already solved your problem, but you just needed to set a type for the $request parameter, or to write the PHP Docblock (the comment with @param and @return) before the process function in your consumer’s class.

Magento 2, most of the time, uses reflections to validate the type of parameters and returns, taking advantage of the comment before each method/property to retrieve the actual data type.

So basically you should just change your method declaration to this:

JavaScript

or this:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement