Fix queue tracing for non-object messages and when using AMQP (RabbitMQ)#233
Fix queue tracing for non-object messages and when using AMQP (RabbitMQ)#233angelvilaplana wants to merge 3 commits intojustbetter:masterfrom
Conversation
…avoid unpack error
|
Thanks! What queueing engine do you use? |
|
Hi @indykoning, in the environments I've worked with, I've used RabbitMQ as the queue engine. After I fixed the "Error: Only arrays and Traversables can be unpacked" issue, a new problem appeared when running the When trying to obtain the
Given the situation, I’ll change how the trace data is added to the envelope by setting it in the properties. This approach works correctly with AMQP. However, after investigating the code further and testing the database queue engine, I discovered that once the queue reaches afterDequeue or beforeReject, the properties I previously added are no longer present. Considering this, I refactored the code to avoid breaking the queue trace. I apologize for the mistake. I wasn’t aware that Magento supports more than one queue engine option. Thank you very much for your comment, as it helped me test different scenarios and better understand why the variables are set in the body rather than in the properties. |
096d84f to
d7706f2
Compare
|
Running this using mysqlmq i'm running into the following error when running the consumers runner (
|
9291bb2 to
ece5f20
Compare
|
Hi @indykoning, thank you for your report. To be honest, I had a lot of trouble trying to reproduce the issue because I couldn't reproduce it at first. In the end, I noticed that if I publish a queue with the previous changes and then run the consumer with the new changes, I get the same problem you experienced. That allowed me to reproduce it and fix it. |

Summary
This PR fixes an exception thrown when publishing messages to custom topics with non-array payloads.
Previously, the ExchangePlugin attempted to merge Sentry tracing data into the decoded message body using the PHP spread operator. When the payload was not an array (e.g. string or integer), PHP failed to unpack it and threw:
This PR changes how Sentry trace data is propagated by injecting it into the envelope properties instead of the message body. This avoids modifying or decoding the payload entirely and works with any payload type.
This PR solves the issue reported in #232
Result
Checklist
composer run codestylecomposer run analyse