Reputation: 85388
I'm trying to set a message property using the RabbitMQ Bundle in Symfony but I don't see where/how I can do this. Here is how I do it in the RabbitMQ Admin UI
The Properties expiration: 50000 is what I would like to set.
How can I do this?
Upvotes: 2
Views: 3164
Reputation: 230
Since Jan 8, 2014, you cat set message properties using RabbitMQ Bundle, you can review the commit here
Now, when you publish a message you cat set the array $additionalProperties
public function publish($msgBody, $routingKey = '', $additionalProperties = array())
You can find the supported message properties here
For example:
$msg = ['arg1' => 'val1'];
$queue->setContentType('application/json');
$queue->publish(
json_encode($msg),
"",
['expiration' => '50000']
);
If you want to use "headers" for custom headers, it is a bit more complicated because you have to define the datatype for each value. To send, e.g. $headers['arg1'] = "val1" like a string, you have to do something like that:
$msg = ['arg1' => 'val1'];
$queue->setContentType('application/json');
$queue->publish(
json_encode($msg),
"",
["application_headers" => ["arg1" => ["S", "val1"]]]
);
Valid datatypes are:
S - String
I - Integer
D - Decimal
T - Timestamps
F - Table
A - Array
Upvotes: 6
Reputation: 2313
That's not doable at the moment. You can set message properties if you use the underlying php-amqplib library that the bundle depends on
Upvotes: 0