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
3 changes: 2 additions & 1 deletion src/Kdyby/RabbitMq/DI/RabbitMqExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class RabbitMqExtension extends Nette\DI\CompilerExtension
public $rpcClientDefaults = [
'connection' => 'default',
'expectSerializedResponse' => TRUE,
'contentType' => 'text/plain',
];

/**
Expand Down Expand Up @@ -428,7 +429,7 @@ protected function loadRpcClients($clients)

$builder->addDefinition($serviceName = $this->prefix('rpcClient.' . $name))
->setClass('Kdyby\RabbitMq\RpcClient', ['@' . $this->connectionsMeta[$config['connection']]['serviceId']])
->addSetup('initClient', [$config['expectSerializedResponse']])
->addSetup('initClient', [$config['expectSerializedResponse'], $config['contentType']])
->addTag(self::TAG_RPC_CLIENT)
->setAutowired(FALSE);

Expand Down
10 changes: 8 additions & 2 deletions src/Kdyby/RabbitMq/RpcClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,19 @@ class RpcClient extends AmqpMember
*/
protected $expectSerializedResponse;

/**
* @var string
*/
protected $contentType;

/**
* @var int
*/
protected $timeout = 0;



public function initClient($expectSerializedResponse = true)
public function initClient($expectSerializedResponse = true, $contentType = 'text/plain')
{
list($this->queueName,,) = $this->getChannel()->queue_declare(
"",
Expand All @@ -51,6 +56,7 @@ public function initClient($expectSerializedResponse = true)
);

$this->expectSerializedResponse = $expectSerializedResponse;
$this->contentType = $contentType;
}


Expand All @@ -62,7 +68,7 @@ public function addRequest($msgBody, $server, $requestId = null, $routingKey = '
}

$msg = new AMQPMessage($msgBody, [
'content_type' => 'text/plain',
'content_type' => $this->contentType,
'reply_to' => $this->queueName,
'delivery_mode' => 1, // non durable
'expiration' => $expiration * 1000,
Expand Down