Skip to content

Commit 0a2bd15

Browse files
committed
Allow setting headers on publishing message
1 parent 09be4be commit 0a2bd15

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

RabbitMq/Producer.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use OldSound\RabbitMqBundle\RabbitMq\BaseAmqp;
66
use PhpAmqpLib\Message\AMQPMessage;
7+
use PhpAmqpLib\Wire\AMQPTable;
78

89
/**
910
* Producer, that publishes AMQP Messages
@@ -38,14 +39,19 @@ protected function getBasicProperties()
3839
* @param string $msgBody
3940
* @param string $routingKey
4041
* @param array $additionalProperties
42+
* @param array $headers
4143
*/
42-
public function publish($msgBody, $routingKey = '', $additionalProperties = array())
44+
public function publish($msgBody, $routingKey = '', $additionalProperties = array(), array $headers = null)
4345
{
4446
if ($this->autoSetupFabric) {
4547
$this->setupFabric();
4648
}
4749

4850
$msg = new AMQPMessage((string) $msgBody, array_merge($this->getBasicProperties(), $additionalProperties));
51+
52+
$headersTable = new AMQPTable($headers);
53+
$msg->set('application_headers', $headersTable);
54+
4955
$this->getChannel()->basic_publish($msg, $this->exchangeOptions['name'], (string) $routingKey);
5056
}
5157
}

0 commit comments

Comments
 (0)