Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion RabbitMq/Producer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,25 @@ 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;

return $this;
}

/**
* Set delivery mode
*
* @param string $deliveryMode
* @return self
*/
public function setDeliveryMode($deliveryMode)
{
$this->deliveryMode = $deliveryMode;
Expand All @@ -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);
Expand Down
21 changes: 19 additions & 2 deletions RabbitMq/ProducerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}