Skip to content

Commit

Permalink
Add bundle configuration for login_method for RabbitMQ connections (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
spras authored Mar 19, 2024
1 parent a80937c commit 9117576
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- 2024-03-18
* Add bundle configuration for `login_method` for RabbitMQ connections, this allow to configure other values than default AMQPLAIN (PLAIN or EXTERNAL), see https://www.rabbitmq.com/docs/access-control#mechanisms

- 2023-11-07
* Add consumer option `no_ack`

Expand Down
9 changes: 9 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace OldSound\RabbitMqBundle\DependencyInjection;

use OldSound\RabbitMqBundle\RabbitMq\Producer;
use PhpAmqpLib\Connection\AMQPConnectionConfig;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
Expand Down Expand Up @@ -73,6 +74,14 @@ protected function addConnections(ArrayNodeDefinition $node)
->scalarNode('user')->defaultValue('guest')->end()
->scalarNode('password')->defaultValue('guest')->end()
->scalarNode('vhost')->defaultValue('/')->end()
->enumNode('login_method')
->values([
AMQPConnectionConfig::AUTH_AMQPPLAIN,
AMQPConnectionConfig::AUTH_PLAIN,
AMQPConnectionConfig::AUTH_EXTERNAL
])
->defaultValue(AMQPConnectionConfig::AUTH_AMQPPLAIN)
->end()
->arrayNode('hosts')
->info('connection_timeout, read_write_timeout, use_socket, ssl_context, keepalive,
heartbeat and connection_parameters_provider should be specified globally when
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ old_sound_rabbit_mq:

#requires php_sockets.dll
use_socket: true # default false

login_method: 'AMQPLAIN' # default 'AMQPLAIN', can be 'EXTERNAL' or 'PLAIN', see https://www.rabbitmq.com/docs/access-control#mechanisms

another:
# A different (unused) connection defined by an URL. One can omit all parts,
# except the scheme (amqp:). If both segment in the URL and a key value (see above)
Expand Down
5 changes: 5 additions & 0 deletions Tests/DependencyInjection/OldSoundRabbitMqExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function testFooConnectionDefinition()
'url' => '',
'hosts' => [],
'channel_rpc_timeout' => 0.0,
'login_method' => 'AMQPLAIN',

], $factory->getArgument(1));
$this->assertEquals('%old_sound_rabbit_mq.connection.class%', $definition->getClass());
Expand Down Expand Up @@ -72,6 +73,7 @@ public function testSslConnectionDefinition()
'url' => '',
'hosts' => [],
'channel_rpc_timeout' => 0.0,
'login_method' => 'AMQPLAIN',
], $factory->getArgument(1));
$this->assertEquals('%old_sound_rabbit_mq.connection.class%', $definition->getClass());
}
Expand Down Expand Up @@ -101,6 +103,7 @@ public function testLazyConnectionDefinition()
'url' => '',
'hosts' => [],
'channel_rpc_timeout' => 0.0,
'login_method' => 'AMQPLAIN',
], $factory->getArgument(1));
$this->assertEquals('%old_sound_rabbit_mq.lazy.connection.class%', $definition->getClass());
}
Expand Down Expand Up @@ -130,6 +133,7 @@ public function testDefaultConnectionDefinition()
'url' => '',
'hosts' => [],
'channel_rpc_timeout' => 0.0,
'login_method' => 'AMQPLAIN',
], $factory->getArgument(1));
$this->assertEquals('%old_sound_rabbit_mq.connection.class%', $definition->getClass());
}
Expand Down Expand Up @@ -194,6 +198,7 @@ public function testClusterConnectionDefinition()
'use_socket' => false,
'url' => '',
'channel_rpc_timeout' => 0.0,
'login_method' => 'AMQPLAIN',
], $factory->getArgument(1));
$this->assertEquals('%old_sound_rabbit_mq.connection.class%', $definition->getClass());
}
Expand Down

0 comments on commit 9117576

Please sign in to comment.