Skip to content

Commit b88c68d

Browse files
committed
Merge pull request #263 from Padam87/rpc_settings
RPC Server exchange options
2 parents b546af9 + b61b38c commit b88c68d

File tree

5 files changed

+41
-0
lines changed

5 files changed

+41
-0
lines changed

DependencyInjection/Configuration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ protected function addRpcServers(ArrayNodeDefinition $node)
202202
->canBeUnset()
203203
->useAttributeAsKey('key')
204204
->prototype('array')
205+
->append($this->getExchangeConfiguration())
205206
->append($this->getQueueConfiguration())
206207
->children()
207208
->scalarNode('connection')->defaultValue('default')->end()

DependencyInjection/OldSoundRabbitMqExtension.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,9 @@ protected function loadRpcServers()
346346
$server['qos_options']['global']
347347
));
348348
}
349+
if (array_key_exists('exchange_options', $server)) {
350+
$definition->addMethodCall('setExchangeOptions', array($server['exchange_options']));
351+
}
349352
if (array_key_exists('queue_options', $server)) {
350353
$definition->addMethodCall('setQueueOptions', array($server['queue_options']));
351354
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ rpc_servers:
377377
connection: default
378378
callback: random_int_server
379379
qos_options: {prefetch_size: 0, prefetch_count: 1, global: false}
380+
exchange_options: {name: exchange, type: topic}
380381
queue_options: {name: random_int_queue, durable: false, auto_delete: true}
381382
serializer: json_encode
382383
```

Tests/DependencyInjection/Fixtures/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,9 @@ old_sound_rabbit_mq:
164164
callback: server_with_queue_options.callback
165165
queue_options:
166166
name: "server_with_queue_options-queue"
167+
168+
server_with_exchange_options:
169+
callback: server_with_exchange_options.callback
170+
exchange_options:
171+
name: exchange
172+
type: topic

Tests/DependencyInjection/OldSoundRabbitMqExtensionTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,36 @@ public function testRpcServerWithQueueOptionsDefinition()
565565
$this->assertEquals('%old_sound_rabbit_mq.rpc_server.class%', $definition->getClass());
566566
}
567567

568+
public function testRpcServerWithExchangeOptionsDefinition()
569+
{
570+
$container = $this->getContainer('test.yml');
571+
572+
$this->assertTrue($container->has('old_sound_rabbit_mq.server_with_exchange_options_server'));
573+
$definition = $container->getDefinition('old_sound_rabbit_mq.server_with_exchange_options_server');
574+
$this->assertEquals((string) $definition->getArgument(0), 'old_sound_rabbit_mq.connection.default');
575+
$this->assertEquals((string) $definition->getArgument(1), 'old_sound_rabbit_mq.channel.server_with_exchange_options');
576+
$this->assertEquals(array(
577+
array('initServer', array('server_with_exchange_options')),
578+
array('setCallback', array(array(new Reference('server_with_exchange_options.callback'), 'execute'))),
579+
array('setExchangeOptions', array(array(
580+
'name' => 'exchange',
581+
'type' => 'topic',
582+
'passive' => false,
583+
'durable' => true,
584+
'auto_delete' => false,
585+
'internal' => null,
586+
'nowait' => false,
587+
'declare' => true,
588+
'arguments' => null,
589+
'ticket' => null,
590+
))),
591+
array('setSerializer', array('serialize')),
592+
),
593+
$definition->getMethodCalls()
594+
);
595+
$this->assertEquals('%old_sound_rabbit_mq.rpc_server.class%', $definition->getClass());
596+
}
597+
568598
public function testHasCollectorWhenChannelsExist()
569599
{
570600
$container = $this->getContainer('collector.yml');

0 commit comments

Comments
 (0)