'Add a header when sending a message with php-enqueue and RabbitMQ
I am trying to send a header using php-enqueue bundle I'm trying this:
public function __construct(
ProducerInterface $producer
)
{
parent::__construct();
$this->producer = $producer;
}
//... Inside function...
$m = new Message(
'message to send',
[],
[
'm' => 1
]
);
$this->producer->sendCommand('newMessageFromApi', $m);
But the header does not reach the consumer. These are the only headers that arrive.
[
"content_type" => "text/plain",
"delivery_mode" => 2,
"message_id" => "38f96af0-64de-4a31-9315-6b51dd5f8baf",
"timestamp" => 1652027271
]
Solution 1:[1]
Try this
$m = new Message('message to send',['m' => 1]);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | JayJay |