From 8651d1e5ba8396660f291a78f7672b2f7c65b690 Mon Sep 17 00:00:00 2001 From: Jonas Gielen Date: Tue, 3 Jan 2017 12:08:38 +0100 Subject: [PATCH] Bring ProducerInterface uptodate with the Producer --- RabbitMq/Producer.php | 14 +++++++++++++- RabbitMq/ProducerInterface.php | 21 +++++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/RabbitMq/Producer.php b/RabbitMq/Producer.php index 446bb611..34bd66af 100644 --- a/RabbitMq/Producer.php +++ b/RabbitMq/Producer.php @@ -13,6 +13,12 @@ class Producer extends BaseAmqp implements ProducerInterface protected $contentType = 'text/plain'; protected $deliveryMode = 2; + /** + * Set content type + * + * @param string $contentType + * @return self + */ public function setContentType($contentType) { $this->contentType = $contentType; @@ -20,6 +26,12 @@ public function setContentType($contentType) return $this; } + /** + * Set delivery mode + * + * @param string $deliveryMode + * @return self + */ public function setDeliveryMode($deliveryMode) { $this->deliveryMode = $deliveryMode; @@ -46,7 +58,7 @@ public function publish($msgBody, $routingKey = '', $additionalProperties = arra $this->setupFabric(); } - $msg = new AMQPMessage((string) $msgBody, array_merge($this->getBasicProperties(), $additionalProperties)); + $msg = new AMQPMessage((string)$msgBody, array_merge($this->getBasicProperties(), $additionalProperties)); if (!empty($headers)) { $headersTable = new AMQPTable($headers); diff --git a/RabbitMq/ProducerInterface.php b/RabbitMq/ProducerInterface.php index b4e166c1..5e38a8c5 100644 --- a/RabbitMq/ProducerInterface.php +++ b/RabbitMq/ProducerInterface.php @@ -5,11 +5,28 @@ interface ProducerInterface { /** - * Publish a message + * Set content type + * + * @param string $contentType + * @return self + */ + public function setContentType($contentType); + + /** + * Set delivery mode + * + * @param string $deliveryMode + * @return self + */ + public function setDeliveryMode($deliveryMode); + + /** + * Publishes the message and merges additional properties with basic properties * * @param string $msgBody * @param string $routingKey * @param array $additionalProperties + * @param array $headers */ - public function publish($msgBody, $routingKey = '', $additionalProperties = array()); + public function publish($msgBody, $routingKey = '', $additionalProperties = array(), array $headers = null); }