From 6af36be8a615ce4223cdf0bcaddb76801c7337a2 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Fri, 27 Oct 2017 19:52:01 +0300 Subject: [PATCH 1/6] skip gearman test --- .../Tests/Functions/DsnToConnectionFactoryFunctionTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/enqueue/Tests/Functions/DsnToConnectionFactoryFunctionTest.php b/pkg/enqueue/Tests/Functions/DsnToConnectionFactoryFunctionTest.php index 6596a79af..f123b116b 100644 --- a/pkg/enqueue/Tests/Functions/DsnToConnectionFactoryFunctionTest.php +++ b/pkg/enqueue/Tests/Functions/DsnToConnectionFactoryFunctionTest.php @@ -86,7 +86,7 @@ public static function provideDSNs() yield ['beanstalk:', PheanstalkConnectionFactory::class]; - yield ['gearman:', GearmanConnectionFactory::class]; +// yield ['gearman:', GearmanConnectionFactory::class]; yield ['kafka:', RdKafkaConnectionFactory::class]; From aa0e009bff2892f71901e6875b3eaf0d4a0c1fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dalibor=20Karlovi=C4=87?= Date: Sat, 28 Oct 2017 10:19:21 +0200 Subject: [PATCH 2/6] [bundle] streamline profiler view when no messages were sent --- pkg/enqueue-bundle/Resources/views/Profiler/panel.html.twig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/enqueue-bundle/Resources/views/Profiler/panel.html.twig b/pkg/enqueue-bundle/Resources/views/Profiler/panel.html.twig index 635a540d7..c11c21929 100644 --- a/pkg/enqueue-bundle/Resources/views/Profiler/panel.html.twig +++ b/pkg/enqueue-bundle/Resources/views/Profiler/panel.html.twig @@ -28,6 +28,7 @@ {% block panel %}

Sent messages

+ {% if collector.sentMessages|length > 0 %} @@ -59,4 +60,9 @@
+ {% else %} +
+

No messages were sent.

+
+ {% endif %} {% endblock %} From 28f55abe595691e65bf6c204fe316b37558fb8e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Parmentier?= Date: Mon, 30 Oct 2017 11:00:21 +0100 Subject: [PATCH 3/6] Renamed exposed services' name to classes' FQCN --- .../Compiler/AddTopicMetaPass.php | 3 +- .../Compiler/BuildClientRoutingPass.php | 3 +- .../Compiler/BuildQueueMetaRegistryPass.php | 3 +- .../BuildTopicMetaSubscribersPass.php | 3 +- .../DependencyInjection/Configuration.php | 3 +- .../DependencyInjection/EnqueueExtension.php | 11 +- .../Resources/config/client.yml | 105 +++++++++++++----- .../flush_spool_producer_extension.yml | 2 +- pkg/enqueue-bundle/Resources/config/job.yml | 62 ++++++++--- .../Resources/config/services.yml | 20 +++- .../Tests/Functional/App/config/config.yml | 2 +- .../Client/ConsumeMessagesCommandTest.php | 2 +- .../Client/ProduceMessageCommandTest.php | 2 +- .../Tests/Functional/Client/ProducerTest.php | 26 +++-- .../Functional/Client/SpoolProducerTest.php | 5 +- .../Functional/ConsumeMessagesCommandTest.php | 2 +- .../CalculateRootJobStatusProcessorTest.php | 2 +- .../Job/DependentJobServiceTest.php | 2 +- .../Tests/Functional/Job/JobRunnerTest.php | 2 +- .../Tests/Functional/Job/JobStorageTest.php | 2 +- .../Tests/Functional/QueueConsumerTest.php | 2 +- .../Tests/Functional/QueueRegistryTest.php | 2 +- .../Tests/Functional/QueuesCommandTest.php | 18 ++- .../Tests/Functional/RpcClientTest.php | 2 +- .../Tests/Functional/TopicRegistryTest.php | 2 +- .../Tests/Functional/TopicsCommandTest.php | 18 ++- .../Tests/Functional/UseCasesTest.php | 11 +- .../Compiler/AddTopicMetaPassTest.php | 3 +- .../Compiler/BuildClientRoutingPassTest.php | 25 +++-- .../BuildQueueMetaRegistryPassTest.php | 19 ++-- .../BuildTopicMetaSubscribersPassTest.php | 27 ++--- .../DependencyInjection/ConfigurationTest.php | 3 +- .../EnqueueExtensionTest.php | 28 +++-- .../ContainerAwareProcessorRegistry.php | 7 ++ 34 files changed, 285 insertions(+), 144 deletions(-) diff --git a/pkg/enqueue-bundle/DependencyInjection/Compiler/AddTopicMetaPass.php b/pkg/enqueue-bundle/DependencyInjection/Compiler/AddTopicMetaPass.php index ba4269b2d..45becabef 100644 --- a/pkg/enqueue-bundle/DependencyInjection/Compiler/AddTopicMetaPass.php +++ b/pkg/enqueue-bundle/DependencyInjection/Compiler/AddTopicMetaPass.php @@ -2,6 +2,7 @@ namespace Enqueue\Bundle\DependencyInjection\Compiler; +use Enqueue\Client\Meta\TopicMetaRegistry; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -44,7 +45,7 @@ public function add($topicName, $topicDescription = '', array $topicSubscribers */ public function process(ContainerBuilder $container) { - $metaRegistryId = 'enqueue.client.meta.topic_meta_registry'; + $metaRegistryId = TopicMetaRegistry::class; if (false == $container->hasDefinition($metaRegistryId)) { return; diff --git a/pkg/enqueue-bundle/DependencyInjection/Compiler/BuildClientRoutingPass.php b/pkg/enqueue-bundle/DependencyInjection/Compiler/BuildClientRoutingPass.php index 541f1f977..3511a3a96 100644 --- a/pkg/enqueue-bundle/DependencyInjection/Compiler/BuildClientRoutingPass.php +++ b/pkg/enqueue-bundle/DependencyInjection/Compiler/BuildClientRoutingPass.php @@ -3,6 +3,7 @@ namespace Enqueue\Bundle\DependencyInjection\Compiler; use Enqueue\Client\Config; +use Enqueue\Client\RouterProcessor; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -16,7 +17,7 @@ class BuildClientRoutingPass implements CompilerPassInterface public function process(ContainerBuilder $container) { $processorTagName = 'enqueue.client.processor'; - $routerId = 'enqueue.client.router_processor'; + $routerId = RouterProcessor::class; if (false == $container->hasDefinition($routerId)) { return; diff --git a/pkg/enqueue-bundle/DependencyInjection/Compiler/BuildQueueMetaRegistryPass.php b/pkg/enqueue-bundle/DependencyInjection/Compiler/BuildQueueMetaRegistryPass.php index 4cc641f2e..5e82f324d 100644 --- a/pkg/enqueue-bundle/DependencyInjection/Compiler/BuildQueueMetaRegistryPass.php +++ b/pkg/enqueue-bundle/DependencyInjection/Compiler/BuildQueueMetaRegistryPass.php @@ -2,6 +2,7 @@ namespace Enqueue\Bundle\DependencyInjection\Compiler; +use Enqueue\Client\Meta\QueueMetaRegistry; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -15,7 +16,7 @@ class BuildQueueMetaRegistryPass implements CompilerPassInterface public function process(ContainerBuilder $container) { $processorTagName = 'enqueue.client.processor'; - $queueMetaRegistryId = 'enqueue.client.meta.queue_meta_registry'; + $queueMetaRegistryId = QueueMetaRegistry::class; if (false == $container->hasDefinition($queueMetaRegistryId)) { return; } diff --git a/pkg/enqueue-bundle/DependencyInjection/Compiler/BuildTopicMetaSubscribersPass.php b/pkg/enqueue-bundle/DependencyInjection/Compiler/BuildTopicMetaSubscribersPass.php index 4eeadae04..2f5195fa6 100644 --- a/pkg/enqueue-bundle/DependencyInjection/Compiler/BuildTopicMetaSubscribersPass.php +++ b/pkg/enqueue-bundle/DependencyInjection/Compiler/BuildTopicMetaSubscribersPass.php @@ -2,6 +2,7 @@ namespace Enqueue\Bundle\DependencyInjection\Compiler; +use Enqueue\Client\Meta\TopicMetaRegistry; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -16,7 +17,7 @@ public function process(ContainerBuilder $container) { $processorTagName = 'enqueue.client.processor'; - if (false == $container->hasDefinition('enqueue.client.meta.topic_meta_registry')) { + if (false == $container->hasDefinition(TopicMetaRegistry::class)) { return; } diff --git a/pkg/enqueue-bundle/DependencyInjection/Configuration.php b/pkg/enqueue-bundle/DependencyInjection/Configuration.php index 92686d12e..e5a49a34a 100644 --- a/pkg/enqueue-bundle/DependencyInjection/Configuration.php +++ b/pkg/enqueue-bundle/DependencyInjection/Configuration.php @@ -3,6 +3,7 @@ namespace Enqueue\Bundle\DependencyInjection; use Enqueue\Client\Config; +use Enqueue\Client\RouterProcessor; use Enqueue\Symfony\TransportFactoryInterface; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; @@ -46,7 +47,7 @@ public function getConfigTreeBuilder() ->scalarNode('app_name')->defaultValue('app')->end() ->scalarNode('router_topic')->defaultValue(Config::DEFAULT_PROCESSOR_QUEUE_NAME)->cannotBeEmpty()->end() ->scalarNode('router_queue')->defaultValue(Config::DEFAULT_PROCESSOR_QUEUE_NAME)->cannotBeEmpty()->end() - ->scalarNode('router_processor')->defaultValue('enqueue.client.router_processor')->end() + ->scalarNode('router_processor')->defaultValue(RouterProcessor::class)->end() ->scalarNode('default_processor_queue')->defaultValue(Config::DEFAULT_PROCESSOR_QUEUE_NAME)->cannotBeEmpty()->end() ->integerNode('redelivered_delay_time')->min(0)->defaultValue(0)->end() ->end()->end() diff --git a/pkg/enqueue-bundle/DependencyInjection/EnqueueExtension.php b/pkg/enqueue-bundle/DependencyInjection/EnqueueExtension.php index 7d1221dcd..df6fc4cd5 100644 --- a/pkg/enqueue-bundle/DependencyInjection/EnqueueExtension.php +++ b/pkg/enqueue-bundle/DependencyInjection/EnqueueExtension.php @@ -3,7 +3,9 @@ namespace Enqueue\Bundle\DependencyInjection; use Enqueue\AsyncEventDispatcher\DependencyInjection\AsyncEventDispatcherExtension; +use Enqueue\Client\Producer; use Enqueue\Client\TraceableProducer; +use Enqueue\Consumption\QueueConsumer; use Enqueue\JobQueue\Job; use Enqueue\Null\Symfony\NullTransportFactory; use Enqueue\Symfony\DefaultTransportFactory; @@ -94,10 +96,9 @@ public function load(array $configs, ContainerBuilder $container) $container->setParameter('enqueue.client.default_queue_name', $config['client']['default_processor_queue']); if (false == empty($config['client']['traceable_producer'])) { - $producerId = 'enqueue.client.traceable_producer'; - $container->register($producerId, TraceableProducer::class) - ->setDecoratedService('enqueue.client.producer') - ->addArgument(new Reference('enqueue.client.traceable_producer.inner')) + $container->register(TraceableProducer::class, TraceableProducer::class) + ->setDecoratedService(Producer::class) + ->addArgument(new Reference(sprintf('%s.inner', TraceableProducer::class))) ; } @@ -111,7 +112,7 @@ public function load(array $configs, ContainerBuilder $container) } // configure queue consumer - $container->getDefinition('enqueue.consumption.queue_consumer') + $container->getDefinition(QueueConsumer::class) ->replaceArgument(2, $config['consumption']['idle_timeout']) ->replaceArgument(3, $config['consumption']['receive_timeout']) ; diff --git a/pkg/enqueue-bundle/Resources/config/client.yml b/pkg/enqueue-bundle/Resources/config/client.yml index 8fb6ab607..539abfcc3 100644 --- a/pkg/enqueue-bundle/Resources/config/client.yml +++ b/pkg/enqueue-bundle/Resources/config/client.yml @@ -3,40 +3,51 @@ services: class: 'Enqueue\Client\Config' public: false - enqueue.client.producer: + Enqueue\Client\Producer: class: 'Enqueue\Client\Producer' arguments: - '@enqueue.client.driver' - '@enqueue.client.rpc_factory' - '@enqueue.client.extensions' - enqueue.client.spool_producer: - class: 'Enqueue\Client\SpoolProducer' - arguments: - - '@enqueue.client.producer' - - enqueue.client.extensions: - class: 'Enqueue\Client\ChainExtension' - public: false - arguments: - - [] + # Deprecated. To be removed in 0.10. + enqueue.client.producer: + alias: 'Enqueue\Client\Producer' + # Deprecated. To be removed in 0.10. enqueue.producer: alias: 'enqueue.client.producer' + # Deprecated. To be removed in 0.10. enqueue.client.producer_v2: alias: 'enqueue.client.producer' + Enqueue\Client\SpoolProducer: + class: 'Enqueue\Client\SpoolProducer' + arguments: + - '@Enqueue\Client\Producer' + + # Deprecated. To be removed in 0.10. + enqueue.client.spool_producer: + alias: 'Enqueue\Client\SpoolProducer' + + # Deprecated. To be removed in 0.10. enqueue.spool_producer: alias: 'enqueue.client.spool_producer' + enqueue.client.extensions: + class: 'Enqueue\Client\ChainExtension' + public: false + arguments: + - [] + enqueue.client.rpc_factory: class: 'Enqueue\Rpc\RpcFactory' public: false arguments: - '@enqueue.transport.context' - enqueue.client.router_processor: + Enqueue\Client\RouterProcessor: class: 'Enqueue\Client\RouterProcessor' public: true arguments: @@ -49,22 +60,34 @@ services: topicName: '__router__' queueName: '%enqueue.client.router_queue_name%' + # Deprecated. To be removed in 0.10. + enqueue.client.router_processor: + alias: 'Enqueue\Client\RouterProcessor' + enqueue.client.processor_registry: class: 'Enqueue\Symfony\Client\ContainerAwareProcessorRegistry' public: false calls: - ['setContainer', ['@service_container']] - enqueue.client.meta.topic_meta_registry: + Enqueue\Client\Meta\TopicMetaRegistry: class: 'Enqueue\Client\Meta\TopicMetaRegistry' public: true arguments: [[]] - enqueue.client.meta.queue_meta_registry: + # Deprecated. To be removed in 0.10. + enqueue.client.meta.topic_meta_registry: + alias: 'Enqueue\Client\Meta\TopicMetaRegistry' + + Enqueue\Client\Meta\QueueMetaRegistry: class: 'Enqueue\Client\Meta\QueueMetaRegistry' public: true arguments: ['@enqueue.client.config', []] + # Deprecated. To be removed in 0.10. + enqueue.client.meta.queue_meta_registry: + alias: 'Enqueue\Client\Meta\QueueMetaRegistry' + enqueue.client.delegate_processor: class: 'Enqueue\Client\DelegateProcessor' public: false @@ -88,40 +111,56 @@ services: - ~ - ~ - enqueue.client.consume_messages_command: + Enqueue\Symfony\Client\ConsumeMessagesCommand: class: 'Enqueue\Symfony\Client\ConsumeMessagesCommand' public: true arguments: - '@enqueue.client.queue_consumer' - '@enqueue.client.delegate_processor' - - '@enqueue.client.meta.queue_meta_registry' + - '@Enqueue\Client\Meta\QueueMetaRegistry' - '@enqueue.client.driver' tags: - { name: 'console.command' } - enqueue.client.produce_message_command: + # Deprecated. To be removed in 0.10. + enqueue.client.consume_messages_command: + alias: 'Enqueue\Symfony\Client\ConsumeMessagesCommand' + + Enqueue\Symfony\Client\ProduceMessageCommand: class: 'Enqueue\Symfony\Client\ProduceMessageCommand' public: true arguments: - - '@enqueue.client.producer' + - '@Enqueue\Client\Producer' tags: - { name: 'console.command' } - enqueue.client.meta.topics_command: + # Deprecated. To be removed in 0.10. + enqueue.client.produce_message_command: + alias: 'Enqueue\Symfony\Client\ProduceMessageCommand' + + Enqueue\Symfony\Client\Meta\TopicsCommand: class: 'Enqueue\Symfony\Client\Meta\TopicsCommand' arguments: - - '@enqueue.client.meta.topic_meta_registry' + - '@Enqueue\Client\Meta\TopicMetaRegistry' tags: - { name: 'console.command' } - enqueue.client.meta.queues_command: + # Deprecated. To be removed in 0.10. + enqueue.client.meta.topics_command: + alias: 'Enqueue\Symfony\Client\Meta\TopicsCommand' + + Enqueue\Symfony\Client\Meta\QueuesCommand: class: 'Enqueue\Symfony\Client\Meta\QueuesCommand' arguments: - - '@enqueue.client.meta.queue_meta_registry' + - '@Enqueue\Client\Meta\QueueMetaRegistry' tags: - { name: 'console.command' } - enqueue.client.setup_broker_command: + # Deprecated. To be removed in 0.10. + enqueue.client.meta.queues_command: + alias: 'Enqueue\Symfony\Client\Meta\QueuesCommand' + + Enqueue\Symfony\Client\SetupBrokerCommand: class: 'Enqueue\Symfony\Client\SetupBrokerCommand' public: true arguments: @@ -129,19 +168,25 @@ services: tags: - { name: 'console.command' } + # Deprecated. To be removed in 0.10. + enqueue.client.setup_broker_command: + alias: 'Enqueue\Symfony\Client\SetupBrokerCommand' + enqueue.profiler.message_queue_collector: class: 'Enqueue\Bundle\Profiler\MessageQueueCollector' public: false - arguments: ['@enqueue.client.producer'] + arguments: + - '@Enqueue\Client\Producer' tags: - - - name: 'data_collector' - template: '@Enqueue/Profiler/panel.html.twig' - id: 'enqueue.message_queue' + - { name: 'data_collector', template: '@Enqueue/Profiler/panel.html.twig', id: 'enqueue.message_queue' } - enqueue.flush_spool_producer_listener: + Enqueue\Symfony\Client\FlushSpoolProducerListener: class: 'Enqueue\Symfony\Client\FlushSpoolProducerListener' arguments: - - '@enqueue.client.spool_producer' + - '@Enqueue\Client\SpoolProducer' tags: - { name: 'kernel.event_subscriber' } + + # Deprecated. To be removed in 0.10. + enqueue.flush_spool_producer_listener: + alias: 'Enqueue\Symfony\Client\FlushSpoolProducerListener' diff --git a/pkg/enqueue-bundle/Resources/config/extensions/flush_spool_producer_extension.yml b/pkg/enqueue-bundle/Resources/config/extensions/flush_spool_producer_extension.yml index b665cf66d..80bd3d455 100644 --- a/pkg/enqueue-bundle/Resources/config/extensions/flush_spool_producer_extension.yml +++ b/pkg/enqueue-bundle/Resources/config/extensions/flush_spool_producer_extension.yml @@ -3,6 +3,6 @@ services: class: 'Enqueue\Client\ConsumptionExtension\FlushSpoolProducerExtension' public: false arguments: - - '@enqueue.client.spool_producer' + - '@Enqueue\Client\SpoolProducer' tags: - { name: 'enqueue.consumption.extension', priority: -100 } \ No newline at end of file diff --git a/pkg/enqueue-bundle/Resources/config/job.yml b/pkg/enqueue-bundle/Resources/config/job.yml index 8a0f5f5a1..d8db70793 100644 --- a/pkg/enqueue-bundle/Resources/config/job.yml +++ b/pkg/enqueue-bundle/Resources/config/job.yml @@ -2,49 +2,77 @@ parameters: enqueue.job.unique_job_table_name: 'enqueue_job_unique' services: - enqueue.job.storage: + Enqueue\JobQueue\Doctrine\JobStorage: class: 'Enqueue\JobQueue\Doctrine\JobStorage' arguments: - '@doctrine' - 'Enqueue\JobQueue\Doctrine\Entity\Job' - '%enqueue.job.unique_job_table_name%' - enqueue.job.processor: + # Deprecated. To be removed in 0.10. + enqueue.job.storage: + alias: 'Enqueue\JobQueue\Doctrine\JobStorage' + + Enqueue\JobQueue\JobProcessor: class: 'Enqueue\JobQueue\JobProcessor' arguments: - - '@enqueue.job.storage' - - '@enqueue.client.producer' + - '@Enqueue\JobQueue\Doctrine\JobStorage' + - '@Enqueue\Client\Producer' - enqueue.job.runner: + # Deprecated. To be removed in 0.10. + enqueue.job.processor: + alias: 'Enqueue\JobQueue\JobProcessor' + + Enqueue\JobQueue\JobRunner: class: 'Enqueue\JobQueue\JobRunner' arguments: - - '@enqueue.job.processor' + - '@Enqueue\JobQueue\JobProcessor' - enqueue.job.calculate_root_job_status_service: + # Deprecated. To be removed in 0.10. + enqueue.job.runner: + alias: 'Enqueue\JobQueue\JobRunner' + + Enqueue\JobQueue\CalculateRootJobStatusService: class: 'Enqueue\JobQueue\CalculateRootJobStatusService' arguments: - - '@enqueue.job.storage' + - '@Enqueue\JobQueue\Doctrine\JobStorage' - enqueue.job.calculate_root_job_status_processor: + # Deprecated. To be removed in 0.10. + enqueue.job.calculate_root_job_status_service: + alias: 'Enqueue\JobQueue\CalculateRootJobStatusService' + + Enqueue\JobQueue\CalculateRootJobStatusProcessor: class: 'Enqueue\JobQueue\CalculateRootJobStatusProcessor' arguments: - - '@enqueue.job.storage' - - '@enqueue.job.calculate_root_job_status_service' - - '@enqueue.client.producer' + - '@Enqueue\JobQueue\Doctrine\JobStorage' + - '@Enqueue\JobQueue\CalculateRootJobStatusService' + - '@Enqueue\Client\Producer' - '@logger' tags: - { name: 'enqueue.client.processor' } - enqueue.job.dependent_job_processor: + # Deprecated. To be removed in 0.10. + enqueue.job.calculate_root_job_status_processor: + alias: 'Enqueue\JobQueue\CalculateRootJobStatusProcessor' + + Enqueue\JobQueue\DependentJobProcessor: class: 'Enqueue\JobQueue\DependentJobProcessor' arguments: - - '@enqueue.job.storage' - - '@enqueue.client.producer' + - '@Enqueue\JobQueue\Doctrine\JobStorage' + - '@Enqueue\Client\Producer' - '@logger' tags: - { name: 'enqueue.client.processor' } - enqueue.job.dependent_job_service: + # Deprecated. To be removed in 0.10. + enqueue.job.dependent_job_processor: + alias: 'Enqueue\JobQueue\DependentJobProcessor' + + Enqueue\JobQueue\DependentJobService: class: 'Enqueue\JobQueue\DependentJobService' arguments: - - '@enqueue.job.storage' + - '@Enqueue\JobQueue\Doctrine\JobStorage' + + # Deprecated. To be removed in 0.10. + enqueue.job.dependent_job_service: + alias: 'Enqueue\JobQueue\DependentJobService' diff --git a/pkg/enqueue-bundle/Resources/config/services.yml b/pkg/enqueue-bundle/Resources/config/services.yml index 1d13655d7..21a58dfdc 100644 --- a/pkg/enqueue-bundle/Resources/config/services.yml +++ b/pkg/enqueue-bundle/Resources/config/services.yml @@ -5,7 +5,7 @@ services: arguments: - [] - enqueue.consumption.queue_consumer: + Enqueue\Consumption\QueueConsumer: class: 'Enqueue\Consumption\QueueConsumer' arguments: - '@enqueue.transport.context' @@ -13,21 +13,33 @@ services: - ~ - ~ - enqueue.command.consume_messages: + # Deprecated. To be removed in 0.10. + enqueue.consumption.queue_consumer: + alias: 'Enqueue\Consumption\QueueConsumer' + + Enqueue\Symfony\Consumption\ContainerAwareConsumeMessagesCommand: class: 'Enqueue\Symfony\Consumption\ContainerAwareConsumeMessagesCommand' arguments: - - '@enqueue.consumption.queue_consumer' + - '@Enqueue\Consumption\QueueConsumer' tags: - { name: 'console.command' } + # Deprecated. To be removed in 0.10. + enqueue.command.consume_messages: + alias: 'Enqueue\Symfony\Consumption\ContainerAwareConsumeMessagesCommand' + enqueue.transport.rpc_factory: class: 'Enqueue\Rpc\RpcFactory' public: false arguments: - '@enqueue.transport.context' - enqueue.transport.rpc_client: + Enqueue\Rpc\RpcClient: class: 'Enqueue\Rpc\RpcClient' arguments: - '@enqueue.transport.context' - '@enqueue.transport.rpc_factory' + + # Deprecated. To be removed in 0.10. + enqueue.transport.rpc_client: + alias: 'Enqueue\Rpc\RpcClient' diff --git a/pkg/enqueue-bundle/Tests/Functional/App/config/config.yml b/pkg/enqueue-bundle/Tests/Functional/App/config/config.yml index d21a6ec34..d5f2dc07f 100644 --- a/pkg/enqueue-bundle/Tests/Functional/App/config/config.yml +++ b/pkg/enqueue-bundle/Tests/Functional/App/config/config.yml @@ -73,4 +73,4 @@ services: # overwrite async listener with one based on client producer. so we can use traceable producer. enqueue.events.async_listener: class: 'Enqueue\Bundle\Tests\Functional\App\AsyncListener' - arguments: ['@enqueue.client.producer', '@enqueue.events.registry'] \ No newline at end of file + arguments: ['@Enqueue\Client\Producer', '@enqueue.events.registry'] \ No newline at end of file diff --git a/pkg/enqueue-bundle/Tests/Functional/Client/ConsumeMessagesCommandTest.php b/pkg/enqueue-bundle/Tests/Functional/Client/ConsumeMessagesCommandTest.php index 8cad85ec6..7dc45a4a6 100644 --- a/pkg/enqueue-bundle/Tests/Functional/Client/ConsumeMessagesCommandTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/Client/ConsumeMessagesCommandTest.php @@ -12,7 +12,7 @@ class ConsumeMessagesCommandTest extends WebTestCase { public function testCouldBeGetFromContainerAsService() { - $command = $this->container->get('enqueue.client.consume_messages_command'); + $command = $this->container->get(ConsumeMessagesCommand::class); $this->assertInstanceOf(ConsumeMessagesCommand::class, $command); } diff --git a/pkg/enqueue-bundle/Tests/Functional/Client/ProduceMessageCommandTest.php b/pkg/enqueue-bundle/Tests/Functional/Client/ProduceMessageCommandTest.php index b003805cf..d8ae433c8 100644 --- a/pkg/enqueue-bundle/Tests/Functional/Client/ProduceMessageCommandTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/Client/ProduceMessageCommandTest.php @@ -12,7 +12,7 @@ class ProduceMessageCommandTest extends WebTestCase { public function testCouldBeGetFromContainerAsService() { - $command = $this->container->get('enqueue.client.produce_message_command'); + $command = $this->container->get(ProduceMessageCommand::class); $this->assertInstanceOf(ProduceMessageCommand::class, $command); } diff --git a/pkg/enqueue-bundle/Tests/Functional/Client/ProducerTest.php b/pkg/enqueue-bundle/Tests/Functional/Client/ProducerTest.php index 283784166..1494c6930 100644 --- a/pkg/enqueue-bundle/Tests/Functional/Client/ProducerTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/Client/ProducerTest.php @@ -5,7 +5,9 @@ use Enqueue\Bundle\Tests\Functional\WebTestCase; use Enqueue\Client\Config; use Enqueue\Client\Message; +use Enqueue\Client\Producer; use Enqueue\Client\ProducerInterface; +use Enqueue\Client\RouterProcessor; use Enqueue\Client\TraceableProducer; use Enqueue\Rpc\Promise; @@ -18,26 +20,26 @@ public function setUp() { parent::setUp(); - $this->container->get('enqueue.client.producer')->clearTraces(); + $this->container->get(Producer::class)->clearTraces(); } public function tearDown() { parent::tearDown(); - $this->container->get('enqueue.client.producer')->clearTraces(); + $this->container->get(Producer::class)->clearTraces(); } public function testCouldBeGetFromContainerAsService() { - $messageProducer = $this->container->get('enqueue.client.producer'); + $messageProducer = $this->container->get(Producer::class); $this->assertInstanceOf(ProducerInterface::class, $messageProducer); } public function testCouldBeGetFromContainerAsShortenAlias() { - $messageProducer = $this->container->get('enqueue.client.producer'); + $messageProducer = $this->container->get(Producer::class); $aliasMessageProducer = $this->container->get('enqueue.producer'); $this->assertSame($messageProducer, $aliasMessageProducer); @@ -46,7 +48,7 @@ public function testCouldBeGetFromContainerAsShortenAlias() public function testShouldSendEvent() { /** @var ProducerInterface $producer */ - $producer = $this->container->get('enqueue.client.producer'); + $producer = $this->container->get(Producer::class); $producer->sendEvent('theTopic', 'theMessage'); @@ -59,7 +61,7 @@ public function testShouldSendEvent() public function testShouldSendCommandWithoutNeedForReply() { /** @var ProducerInterface $producer */ - $producer = $this->container->get('enqueue.client.producer'); + $producer = $this->container->get(Producer::class); $result = $producer->sendCommand('theCommand', 'theMessage', false); @@ -74,7 +76,7 @@ public function testShouldSendCommandWithoutNeedForReply() public function testShouldSendMessageInstanceAsCommandWithoutNeedForReply() { /** @var ProducerInterface $producer */ - $producer = $this->container->get('enqueue.client.producer'); + $producer = $this->container->get(Producer::class); $message = new Message('theMessage'); @@ -88,7 +90,7 @@ public function testShouldSendMessageInstanceAsCommandWithoutNeedForReply() $this->assertEquals('theMessage', $traces[0]['body']); $this->assertEquals([ 'enqueue.topic_name' => Config::COMMAND_TOPIC, - 'enqueue.processor_name' => 'enqueue.client.router_processor', + 'enqueue.processor_name' => RouterProcessor::class, 'enqueue.command_name' => 'theCommand', 'enqueue.processor_queue_name' => 'default', ], $traces[0]['properties']); @@ -97,7 +99,7 @@ public function testShouldSendMessageInstanceAsCommandWithoutNeedForReply() public function testShouldSendExclusiveCommandWithNeedForReply() { /** @var ProducerInterface $producer */ - $producer = $this->container->get('enqueue.client.producer'); + $producer = $this->container->get(Producer::class); $message = new Message('theMessage'); @@ -120,7 +122,7 @@ public function testShouldSendExclusiveCommandWithNeedForReply() public function testShouldSendMessageInstanceCommandWithNeedForReply() { /** @var ProducerInterface $producer */ - $producer = $this->container->get('enqueue.client.producer'); + $producer = $this->container->get(Producer::class); $message = new Message('theMessage'); @@ -134,7 +136,7 @@ public function testShouldSendMessageInstanceCommandWithNeedForReply() $this->assertEquals('theMessage', $traces[0]['body']); $this->assertEquals([ 'enqueue.topic_name' => Config::COMMAND_TOPIC, - 'enqueue.processor_name' => 'enqueue.client.router_processor', + 'enqueue.processor_name' => RouterProcessor::class, 'enqueue.command_name' => 'theCommand', 'enqueue.processor_queue_name' => 'default', ], $traces[0]['properties']); @@ -145,6 +147,6 @@ public function testShouldSendMessageInstanceCommandWithNeedForReply() */ private function getTraceableProducer() { - return $this->container->get('enqueue.client.producer'); + return $this->container->get(Producer::class); } } diff --git a/pkg/enqueue-bundle/Tests/Functional/Client/SpoolProducerTest.php b/pkg/enqueue-bundle/Tests/Functional/Client/SpoolProducerTest.php index ee09fa75e..1ed461997 100644 --- a/pkg/enqueue-bundle/Tests/Functional/Client/SpoolProducerTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/Client/SpoolProducerTest.php @@ -12,11 +12,14 @@ class SpoolProducerTest extends WebTestCase { public function testCouldBeGetFromContainerAsService() { - $producer = $this->container->get('enqueue.client.spool_producer'); + $producer = $this->container->get(SpoolProducer::class); $this->assertInstanceOf(SpoolProducer::class, $producer); } + /** + * @group legacy + */ public function testCouldBeGetFromContainerAsShortenAlias() { $producer = $this->container->get('enqueue.client.spool_producer'); diff --git a/pkg/enqueue-bundle/Tests/Functional/ConsumeMessagesCommandTest.php b/pkg/enqueue-bundle/Tests/Functional/ConsumeMessagesCommandTest.php index 434d17199..e372d960d 100644 --- a/pkg/enqueue-bundle/Tests/Functional/ConsumeMessagesCommandTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/ConsumeMessagesCommandTest.php @@ -11,7 +11,7 @@ class ConsumeMessagesCommandTest extends WebTestCase { public function testCouldBeGetFromContainerAsService() { - $command = $this->container->get('enqueue.client.consume_messages_command'); + $command = $this->container->get(ConsumeMessagesCommand::class); $this->assertInstanceOf(ConsumeMessagesCommand::class, $command); } diff --git a/pkg/enqueue-bundle/Tests/Functional/Job/CalculateRootJobStatusProcessorTest.php b/pkg/enqueue-bundle/Tests/Functional/Job/CalculateRootJobStatusProcessorTest.php index cd8d92435..fdc3471b8 100644 --- a/pkg/enqueue-bundle/Tests/Functional/Job/CalculateRootJobStatusProcessorTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/Job/CalculateRootJobStatusProcessorTest.php @@ -12,7 +12,7 @@ class CalculateRootJobStatusProcessorTest extends WebTestCase { public function testCouldBeConstructedByContainer() { - $instance = $this->container->get('enqueue.job.calculate_root_job_status_processor'); + $instance = $this->container->get(CalculateRootJobStatusProcessor::class); $this->assertInstanceOf(CalculateRootJobStatusProcessor::class, $instance); } diff --git a/pkg/enqueue-bundle/Tests/Functional/Job/DependentJobServiceTest.php b/pkg/enqueue-bundle/Tests/Functional/Job/DependentJobServiceTest.php index ca0fdccd4..00974bb88 100644 --- a/pkg/enqueue-bundle/Tests/Functional/Job/DependentJobServiceTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/Job/DependentJobServiceTest.php @@ -12,7 +12,7 @@ class DependentJobServiceTest extends WebTestCase { public function testCouldBeConstructedByContainer() { - $instance = $this->container->get('enqueue.job.dependent_job_service'); + $instance = $this->container->get(DependentJobService::class); $this->assertInstanceOf(DependentJobService::class, $instance); } diff --git a/pkg/enqueue-bundle/Tests/Functional/Job/JobRunnerTest.php b/pkg/enqueue-bundle/Tests/Functional/Job/JobRunnerTest.php index e63fc4f20..6e1320b8c 100644 --- a/pkg/enqueue-bundle/Tests/Functional/Job/JobRunnerTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/Job/JobRunnerTest.php @@ -12,7 +12,7 @@ class JobRunnerTest extends WebTestCase { public function testCouldBeConstructedByContainer() { - $instance = $this->container->get('enqueue.job.runner'); + $instance = $this->container->get(JobRunner::class); $this->assertInstanceOf(JobRunner::class, $instance); } diff --git a/pkg/enqueue-bundle/Tests/Functional/Job/JobStorageTest.php b/pkg/enqueue-bundle/Tests/Functional/Job/JobStorageTest.php index 9bfd0ca38..e34d9dab4 100644 --- a/pkg/enqueue-bundle/Tests/Functional/Job/JobStorageTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/Job/JobStorageTest.php @@ -12,7 +12,7 @@ class JobStorageTest extends WebTestCase { public function testCouldGetJobStorageAsServiceFromContainer() { - $instance = $this->container->get('enqueue.job.storage'); + $instance = $this->container->get(JobStorage::class); $this->assertInstanceOf(JobStorage::class, $instance); } diff --git a/pkg/enqueue-bundle/Tests/Functional/QueueConsumerTest.php b/pkg/enqueue-bundle/Tests/Functional/QueueConsumerTest.php index 8ad6c46ac..415fd9842 100644 --- a/pkg/enqueue-bundle/Tests/Functional/QueueConsumerTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/QueueConsumerTest.php @@ -11,7 +11,7 @@ class QueueConsumerTest extends WebTestCase { public function testCouldBeGetFromContainerAsService() { - $queueConsumer = $this->container->get('enqueue.consumption.queue_consumer'); + $queueConsumer = $this->container->get(QueueConsumer::class); $this->assertInstanceOf(QueueConsumer::class, $queueConsumer); } diff --git a/pkg/enqueue-bundle/Tests/Functional/QueueRegistryTest.php b/pkg/enqueue-bundle/Tests/Functional/QueueRegistryTest.php index fdd35549c..5db4f3105 100644 --- a/pkg/enqueue-bundle/Tests/Functional/QueueRegistryTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/QueueRegistryTest.php @@ -11,7 +11,7 @@ class QueueRegistryTest extends WebTestCase { public function testCouldBeGetFromContainerAsService() { - $connection = $this->container->get('enqueue.client.meta.queue_meta_registry'); + $connection = $this->container->get(QueueMetaRegistry::class); $this->assertInstanceOf(QueueMetaRegistry::class, $connection); } diff --git a/pkg/enqueue-bundle/Tests/Functional/QueuesCommandTest.php b/pkg/enqueue-bundle/Tests/Functional/QueuesCommandTest.php index cff1db1aa..b4fce6140 100644 --- a/pkg/enqueue-bundle/Tests/Functional/QueuesCommandTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/QueuesCommandTest.php @@ -2,8 +2,10 @@ namespace Enqueue\Bundle\Tests\Functional; +use Enqueue\Client\RouterProcessor; use Enqueue\Symfony\Client\Meta\QueuesCommand; use Symfony\Component\Console\Tester\CommandTester; +use Symfony\Component\HttpKernel\Kernel; /** * @group functional @@ -12,14 +14,14 @@ class QueuesCommandTest extends WebTestCase { public function testCouldBeGetFromContainerAsService() { - $command = $this->container->get('enqueue.client.meta.queues_command'); + $command = $this->container->get(QueuesCommand::class); $this->assertInstanceOf(QueuesCommand::class, $command); } public function testShouldDisplayRegisteredQueues() { - $command = $this->container->get('enqueue.client.meta.queues_command'); + $command = $this->container->get(QueuesCommand::class); $tester = new CommandTester($command); $tester->execute([]); @@ -28,12 +30,20 @@ public function testShouldDisplayRegisteredQueues() $this->assertContains(' default ', $display); $this->assertContains('enqueue.app.default', $display); - $this->assertContains('enqueue.client.router_processor', $display); + + $displayId = RouterProcessor::class; + if (30300 > Kernel::VERSION_ID) { + // Symfony 3.2 and below make service identifiers lowercase, so we do the same. + // To be removed when dropping support for Symfony < 3.3. + $displayId = strtolower($displayId); + } + + $this->assertContains($displayId, $display); } public function testShouldDisplayRegisteredCommand() { - $command = $this->container->get('enqueue.client.meta.queues_command'); + $command = $this->container->get(QueuesCommand::class); $tester = new CommandTester($command); $tester->execute([]); diff --git a/pkg/enqueue-bundle/Tests/Functional/RpcClientTest.php b/pkg/enqueue-bundle/Tests/Functional/RpcClientTest.php index f9c9fcb41..ad4ea8787 100644 --- a/pkg/enqueue-bundle/Tests/Functional/RpcClientTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/RpcClientTest.php @@ -11,7 +11,7 @@ class RpcClientTest extends WebTestCase { public function testTransportRpcClientCouldBeGetFromContainerAsService() { - $connection = $this->container->get('enqueue.transport.rpc_client'); + $connection = $this->container->get(RpcClient::class); $this->assertInstanceOf(RpcClient::class, $connection); } diff --git a/pkg/enqueue-bundle/Tests/Functional/TopicRegistryTest.php b/pkg/enqueue-bundle/Tests/Functional/TopicRegistryTest.php index 0db559da0..dc7ecfea5 100644 --- a/pkg/enqueue-bundle/Tests/Functional/TopicRegistryTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/TopicRegistryTest.php @@ -11,7 +11,7 @@ class TopicRegistryTest extends WebTestCase { public function testCouldBeGetFromContainerAsService() { - $connection = $this->container->get('enqueue.client.meta.topic_meta_registry'); + $connection = $this->container->get(TopicMetaRegistry::class); $this->assertInstanceOf(TopicMetaRegistry::class, $connection); } diff --git a/pkg/enqueue-bundle/Tests/Functional/TopicsCommandTest.php b/pkg/enqueue-bundle/Tests/Functional/TopicsCommandTest.php index 84526dbe3..c1bbf6229 100644 --- a/pkg/enqueue-bundle/Tests/Functional/TopicsCommandTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/TopicsCommandTest.php @@ -3,8 +3,10 @@ namespace Enqueue\Bundle\Tests\Functional; use Enqueue\Client\Config; +use Enqueue\Client\RouterProcessor; use Enqueue\Symfony\Client\Meta\TopicsCommand; use Symfony\Component\Console\Tester\CommandTester; +use Symfony\Component\HttpKernel\Kernel; /** * @group functional @@ -13,14 +15,14 @@ class TopicsCommandTest extends WebTestCase { public function testCouldBeGetFromContainerAsService() { - $command = $this->container->get('enqueue.client.meta.topics_command'); + $command = $this->container->get(TopicsCommand::class); $this->assertInstanceOf(TopicsCommand::class, $command); } public function testShouldDisplayRegisteredTopics() { - $command = $this->container->get('enqueue.client.meta.topics_command'); + $command = $this->container->get(TopicsCommand::class); $tester = new CommandTester($command); $tester->execute([]); @@ -28,12 +30,20 @@ public function testShouldDisplayRegisteredTopics() $display = $tester->getDisplay(); $this->assertContains('__router__', $display); - $this->assertContains('enqueue.client.router_processor', $display); + + $displayId = RouterProcessor::class; + if (30300 > Kernel::VERSION_ID) { + // Symfony 3.2 and below make service identifiers lowercase, so we do the same. + // To be removed when dropping support for Symfony < 3.3. + $displayId = strtolower($displayId); + } + + $this->assertContains($displayId, $display); } public function testShouldDisplayCommands() { - $command = $this->container->get('enqueue.client.meta.topics_command'); + $command = $this->container->get(TopicsCommand::class); $tester = new CommandTester($command); $tester->execute([]); diff --git a/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php b/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php index c90b18697..9c633b3d1 100644 --- a/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php @@ -4,7 +4,10 @@ use Enqueue\Bundle\Tests\Functional\App\CustomAppKernel; use Enqueue\Client\DriverInterface; +use Enqueue\Client\Producer; use Enqueue\Client\ProducerInterface; +use Enqueue\Symfony\Client\ConsumeMessagesCommand; +use Enqueue\Symfony\Consumption\ContainerAwareConsumeMessagesCommand; use Interop\Queue\PsrContext; use Interop\Queue\PsrMessage; use Symfony\Component\Console\Tester\CommandTester; @@ -237,7 +240,7 @@ public function testClientConsumeCommandMessagesFromExplicitlySetQueue(array $en { $this->customSetUp($enqueueConfig); - $command = $this->container->get('enqueue.client.consume_messages_command'); + $command = $this->container->get(ConsumeMessagesCommand::class); $processor = $this->container->get('test.message.command_processor'); $expectedBody = __METHOD__.time(); @@ -262,7 +265,7 @@ public function testClientConsumeMessagesFromExplicitlySetQueue(array $enqueueCo { $this->customSetUp($enqueueConfig); - $command = $this->container->get('enqueue.client.consume_messages_command'); + $command = $this->container->get(ConsumeMessagesCommand::class); $processor = $this->container->get('test.message.processor'); $this->getMessageProducer()->sendEvent(TestProcessor::TOPIC, 'test message body'); @@ -285,7 +288,7 @@ public function testTransportConsumeMessagesCommandShouldConsumeMessage(array $e { $this->customSetUp($enqueueConfig); - $command = $this->container->get('enqueue.command.consume_messages'); + $command = $this->container->get(ContainerAwareConsumeMessagesCommand::class); $command->setContainer($this->container); $processor = $this->container->get('test.message.processor'); @@ -356,7 +359,7 @@ protected static function createKernel(array $options = []) */ private function getMessageProducer() { - return $this->container->get('enqueue.client.producer'); + return $this->container->get(Producer::class); } /** diff --git a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/AddTopicMetaPassTest.php b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/AddTopicMetaPassTest.php index f7730ba1a..94537fd89 100644 --- a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/AddTopicMetaPassTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/AddTopicMetaPassTest.php @@ -3,6 +3,7 @@ namespace Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler; use Enqueue\Bundle\DependencyInjection\Compiler\AddTopicMetaPass; +use Enqueue\Client\Meta\TopicMetaRegistry; use Enqueue\Test\ClassExtensionTrait; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; @@ -56,7 +57,7 @@ public function testShouldAddTopicsInRegistryKeepingPreviouslyAdded() $registry = new Definition(null, [[ 'bazTopic' => [], ]]); - $container->setDefinition('enqueue.client.meta.topic_meta_registry', $registry); + $container->setDefinition(TopicMetaRegistry::class, $registry); $pass = AddTopicMetaPass::create() ->add('fooTopic') diff --git a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildClientRoutingPassTest.php b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildClientRoutingPassTest.php index d553d53f0..2b493f5df 100644 --- a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildClientRoutingPassTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildClientRoutingPassTest.php @@ -10,6 +10,7 @@ use Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock\ProcessorNameTopicSubscriber; use Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock\QueueNameTopicSubscriber; use Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock\WithoutProcessorNameTopicSubscriber; +use Enqueue\Client\RouterProcessor; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; @@ -35,7 +36,7 @@ public function testShouldBuildRouteRegistry() $router = new Definition(); $router->setArguments([null, null, null]); - $container->setDefinition('enqueue.client.router_processor', $router); + $container->setDefinition(RouterProcessor::class, $router); $pass = new BuildClientRoutingPass(); $pass->process($container); @@ -61,7 +62,7 @@ public function testThrowIfProcessorClassNameCouldNotBeFound() $router = new Definition(); $router->setArguments([null, []]); - $container->setDefinition('enqueue.client.router_processor', $router); + $container->setDefinition(RouterProcessor::class, $router); $pass = new BuildClientRoutingPass(); @@ -80,7 +81,7 @@ public function testShouldThrowExceptionIfTopicNameIsNotSet() $router = new Definition(); $router->setArguments([null, null, null]); - $container->setDefinition('enqueue.client.router_processor', $router); + $container->setDefinition(RouterProcessor::class, $router); $pass = new BuildClientRoutingPass(); @@ -102,7 +103,7 @@ public function testShouldSetServiceIdAdProcessorIdIfIsNotSetInTag() $router = new Definition(); $router->setArguments([null, null, null]); - $container->setDefinition('enqueue.client.router_processor', $router); + $container->setDefinition(RouterProcessor::class, $router); $pass = new BuildClientRoutingPass(); $pass->process($container); @@ -128,7 +129,7 @@ public function testShouldSetDefaultQueueIfNotSetInTag() $router = new Definition(); $router->setArguments([null, null, null]); - $container->setDefinition('enqueue.client.router_processor', $router); + $container->setDefinition(RouterProcessor::class, $router); $pass = new BuildClientRoutingPass(); $pass->process($container); @@ -152,7 +153,7 @@ public function testShouldBuildRouteFromSubscriberIfOnlyTopicNameSpecified() $router = new Definition(); $router->setArguments([null, null, null]); - $container->setDefinition('enqueue.client.router_processor', $router); + $container->setDefinition(RouterProcessor::class, $router); $pass = new BuildClientRoutingPass(); $pass->process($container); @@ -176,7 +177,7 @@ public function testShouldBuildRouteFromSubscriberIfProcessorNameSpecified() $router = new Definition(); $router->setArguments([null, null, null]); - $container->setDefinition('enqueue.client.router_processor', $router); + $container->setDefinition(RouterProcessor::class, $router); $pass = new BuildClientRoutingPass(); $pass->process($container); @@ -200,7 +201,7 @@ public function testShouldBuildRouteFromSubscriberIfQueueNameSpecified() $router = new Definition(); $router->setArguments([null, null, null]); - $container->setDefinition('enqueue.client.router_processor', $router); + $container->setDefinition(RouterProcessor::class, $router); $pass = new BuildClientRoutingPass(); $pass->process($container); @@ -224,7 +225,7 @@ public function testShouldBuildRouteFromWithoutProcessorNameTopicSubscriber() $router = new Definition(); $router->setArguments([null, null, null]); - $container->setDefinition('enqueue.client.router_processor', $router); + $container->setDefinition(RouterProcessor::class, $router); $pass = new BuildClientRoutingPass(); $pass->process($container); @@ -248,7 +249,7 @@ public function testShouldThrowExceptionWhenTopicSubscriberConfigurationIsInvali $router = new Definition(); $router->setArguments(['', '']); - $container->setDefinition('enqueue.client.router_processor', $router); + $container->setDefinition(RouterProcessor::class, $router); $pass = new BuildClientRoutingPass(); @@ -268,7 +269,7 @@ public function testShouldBuildRouteFromCommandSubscriberIfOnlyCommandNameSpecif $router = new Definition(); $router->setArguments([null, null, null]); - $container->setDefinition('enqueue.client.router_processor', $router); + $container->setDefinition(RouterProcessor::class, $router); $pass = new BuildClientRoutingPass(); $pass->process($container); @@ -291,7 +292,7 @@ public function testShouldBuildRouteFromCommandSubscriberIfProcessorNameSpecifie $router = new Definition(); $router->setArguments([null, null, null]); - $container->setDefinition('enqueue.client.router_processor', $router); + $container->setDefinition(RouterProcessor::class, $router); $pass = new BuildClientRoutingPass(); $pass->process($container); diff --git a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildQueueMetaRegistryPassTest.php b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildQueueMetaRegistryPassTest.php index cd98f8b18..46c315a78 100644 --- a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildQueueMetaRegistryPassTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildQueueMetaRegistryPassTest.php @@ -8,6 +8,7 @@ use Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock\ProcessorNameCommandSubscriber; use Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock\ProcessorNameTopicSubscriber; use Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock\QueueNameTopicSubscriber; +use Enqueue\Client\Meta\QueueMetaRegistry; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; @@ -45,7 +46,7 @@ public function testThrowIfProcessorClassNameCouldNotBeFound() $registry = new Definition(); $registry->setArguments([null, []]); - $container->setDefinition('enqueue.client.meta.queue_meta_registry', $registry); + $container->setDefinition(QueueMetaRegistry::class, $registry); $pass = new BuildQueueMetaRegistryPass(); @@ -67,7 +68,7 @@ public function testShouldBuildQueueMetaRegistry() $registry = new Definition(); $registry->setArguments([null, []]); - $container->setDefinition('enqueue.client.meta.queue_meta_registry', $registry); + $container->setDefinition(QueueMetaRegistry::class, $registry); $pass = new BuildQueueMetaRegistryPass(); $pass->process($container); @@ -91,7 +92,7 @@ public function testShouldSetServiceIdAdProcessorIdIfIsNotSetInTag() $registry = new Definition(); $registry->setArguments([null, []]); - $container->setDefinition('enqueue.client.meta.queue_meta_registry', $registry); + $container->setDefinition(QueueMetaRegistry::class, $registry); $pass = new BuildQueueMetaRegistryPass(); $pass->process($container); @@ -116,7 +117,7 @@ public function testShouldSetQueueIfSetInTag() $registry = new Definition(); $registry->setArguments([null, []]); - $container->setDefinition('enqueue.client.meta.queue_meta_registry', $registry); + $container->setDefinition(QueueMetaRegistry::class, $registry); $pass = new BuildQueueMetaRegistryPass(); $pass->process($container); @@ -138,7 +139,7 @@ public function testShouldBuildQueueFromSubscriberIfOnlyTopicNameSpecified() $registry = new Definition(); $registry->setArguments([null, []]); - $container->setDefinition('enqueue.client.meta.queue_meta_registry', $registry); + $container->setDefinition(QueueMetaRegistry::class, $registry); $pass = new BuildQueueMetaRegistryPass(); $pass->process($container); @@ -160,7 +161,7 @@ public function testShouldBuildQueueFromSubscriberIfProcessorNameSpecified() $registry = new Definition(); $registry->setArguments([null, []]); - $container->setDefinition('enqueue.client.meta.queue_meta_registry', $registry); + $container->setDefinition(QueueMetaRegistry::class, $registry); $pass = new BuildQueueMetaRegistryPass(); $pass->process($container); @@ -182,7 +183,7 @@ public function testShouldBuildQueueFromSubscriberIfQueueNameSpecified() $registry = new Definition(); $registry->setArguments([null, []]); - $container->setDefinition('enqueue.client.meta.queue_meta_registry', $registry); + $container->setDefinition(QueueMetaRegistry::class, $registry); $pass = new BuildQueueMetaRegistryPass(); $pass->process($container); @@ -204,7 +205,7 @@ public function testShouldBuildQueueFromCommandSubscriber() $registry = new Definition(); $registry->setArguments([null, []]); - $container->setDefinition('enqueue.client.meta.queue_meta_registry', $registry); + $container->setDefinition(QueueMetaRegistry::class, $registry); $pass = new BuildQueueMetaRegistryPass(); $pass->process($container); @@ -226,7 +227,7 @@ public function testShouldBuildQueueFromOnlyCommandNameSubscriber() $registry = new Definition(); $registry->setArguments([null, []]); - $container->setDefinition('enqueue.client.meta.queue_meta_registry', $registry); + $container->setDefinition(QueueMetaRegistry::class, $registry); $pass = new BuildQueueMetaRegistryPass(); $pass->process($container); diff --git a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildTopicMetaSubscribersPassTest.php b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildTopicMetaSubscribersPassTest.php index cb8425abf..d5128add1 100644 --- a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildTopicMetaSubscribersPassTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildTopicMetaSubscribersPassTest.php @@ -9,6 +9,7 @@ use Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock\ProcessorNameCommandSubscriber; use Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock\ProcessorNameTopicSubscriber; use Enqueue\Client\Config; +use Enqueue\Client\Meta\TopicMetaRegistry; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; @@ -33,7 +34,7 @@ public function testShouldBuildTopicMetaSubscribersForOneTagAndEmptyRegistry() $topicMetaRegistry = new Definition(); $topicMetaRegistry->setArguments([[]]); - $container->setDefinition('enqueue.client.meta.topic_meta_registry', $topicMetaRegistry); + $container->setDefinition(TopicMetaRegistry::class, $topicMetaRegistry); $pass = new BuildTopicMetaSubscribersPass(); $pass->process($container); @@ -57,7 +58,7 @@ public function testThrowIfProcessorClassNameCouldNotBeFound() $topicMetaRegistry = new Definition(); $topicMetaRegistry->setArguments([[]]); - $container->setDefinition('enqueue.client.meta.topic_meta_registry', $topicMetaRegistry); + $container->setDefinition(TopicMetaRegistry::class, $topicMetaRegistry); $pass = new BuildTopicMetaSubscribersPass(); @@ -81,7 +82,7 @@ public function testShouldBuildTopicMetaSubscribersForOneTagAndSameMetaInRegistr $topicMetaRegistry->setArguments([[ 'topic' => ['description' => 'aDescription', 'processors' => ['fooProcessorName']], ]]); - $container->setDefinition('enqueue.client.meta.topic_meta_registry', $topicMetaRegistry); + $container->setDefinition(TopicMetaRegistry::class, $topicMetaRegistry); $pass = new BuildTopicMetaSubscribersPass(); $pass->process($container); @@ -112,7 +113,7 @@ public function testShouldBuildTopicMetaSubscribersForOneTagAndSameMetaInPlusAno 'fooTopic' => ['description' => 'aDescription', 'processors' => ['fooProcessorName']], 'barTopic' => ['description' => 'aBarDescription'], ]]); - $container->setDefinition('enqueue.client.meta.topic_meta_registry', $topicMetaRegistry); + $container->setDefinition(TopicMetaRegistry::class, $topicMetaRegistry); $pass = new BuildTopicMetaSubscribersPass(); $pass->process($container); @@ -148,7 +149,7 @@ public function testShouldBuildTopicMetaSubscribersForTwoTagAndEmptyRegistry() $topicMetaRegistry = new Definition(); $topicMetaRegistry->setArguments([[]]); - $container->setDefinition('enqueue.client.meta.topic_meta_registry', $topicMetaRegistry); + $container->setDefinition(TopicMetaRegistry::class, $topicMetaRegistry); $pass = new BuildTopicMetaSubscribersPass(); $pass->process($container); @@ -184,7 +185,7 @@ public function testShouldBuildTopicMetaSubscribersForTwoTagSameMetaRegistry() $topicMetaRegistry->setArguments([[ 'fooTopic' => ['description' => 'aDescription', 'processors' => ['bazProcessorName']], ]]); - $container->setDefinition('enqueue.client.meta.topic_meta_registry', $topicMetaRegistry); + $container->setDefinition(TopicMetaRegistry::class, $topicMetaRegistry); $pass = new BuildTopicMetaSubscribersPass(); $pass->process($container); @@ -209,7 +210,7 @@ public function testThrowIfTopicNameNotSetOnTagAsAttribute() $topicMetaRegistry = new Definition(); $topicMetaRegistry->setArguments([[]]); - $container->setDefinition('enqueue.client.meta.topic_meta_registry', $topicMetaRegistry); + $container->setDefinition(TopicMetaRegistry::class, $topicMetaRegistry); $pass = new BuildTopicMetaSubscribersPass(); @@ -230,7 +231,7 @@ public function testShouldSetServiceIdAdProcessorIdIfIsNotSetInTag() $topicMetaRegistry = new Definition(); $topicMetaRegistry->setArguments([[]]); - $container->setDefinition('enqueue.client.meta.topic_meta_registry', $topicMetaRegistry); + $container->setDefinition(TopicMetaRegistry::class, $topicMetaRegistry); $pass = new BuildTopicMetaSubscribersPass(); $pass->process($container); @@ -252,7 +253,7 @@ public function testShouldBuildMetaFromSubscriberIfOnlyTopicNameSpecified() $topicMetaRegistry = new Definition(); $topicMetaRegistry->setArguments([[]]); - $container->setDefinition('enqueue.client.meta.topic_meta_registry', $topicMetaRegistry); + $container->setDefinition(TopicMetaRegistry::class, $topicMetaRegistry); $pass = new BuildTopicMetaSubscribersPass(); $pass->process($container); @@ -274,7 +275,7 @@ public function testShouldBuildMetaFromSubscriberIfProcessorNameSpecified() $topicMetaRegistry = new Definition(); $topicMetaRegistry->setArguments([[]]); - $container->setDefinition('enqueue.client.meta.topic_meta_registry', $topicMetaRegistry); + $container->setDefinition(TopicMetaRegistry::class, $topicMetaRegistry); $pass = new BuildTopicMetaSubscribersPass(); $pass->process($container); @@ -296,7 +297,7 @@ public function testShouldThrowExceptionWhenTopicSubscriberConfigurationIsInvali $topicMetaRegistry = new Definition(); $topicMetaRegistry->setArguments([[]]); - $container->setDefinition('enqueue.client.meta.topic_meta_registry', $topicMetaRegistry); + $container->setDefinition(TopicMetaRegistry::class, $topicMetaRegistry); $pass = new BuildTopicMetaSubscribersPass(); @@ -316,7 +317,7 @@ public function testShouldBuildMetaFromCommandSubscriberIfOnlyCommandNameSpecifi $topicMetaRegistry = new Definition(); $topicMetaRegistry->setArguments([[]]); - $container->setDefinition('enqueue.client.meta.topic_meta_registry', $topicMetaRegistry); + $container->setDefinition(TopicMetaRegistry::class, $topicMetaRegistry); $pass = new BuildTopicMetaSubscribersPass(); $pass->process($container); @@ -338,7 +339,7 @@ public function testShouldBuildMetaFromCommandSubscriberIfProcessorNameSpecified $topicMetaRegistry = new Definition(); $topicMetaRegistry->setArguments([[]]); - $container->setDefinition('enqueue.client.meta.topic_meta_registry', $topicMetaRegistry); + $container->setDefinition(TopicMetaRegistry::class, $topicMetaRegistry); $pass = new BuildTopicMetaSubscribersPass(); $pass->process($container); diff --git a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php index 81be3a44c..fbff2d989 100644 --- a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php @@ -4,6 +4,7 @@ use Enqueue\Bundle\DependencyInjection\Configuration; use Enqueue\Bundle\Tests\Unit\Mocks\FooTransportFactory; +use Enqueue\Client\RouterProcessor; use Enqueue\Null\Symfony\NullTransportFactory; use Enqueue\Symfony\DefaultTransportFactory; use Enqueue\Test\ClassExtensionTrait; @@ -144,7 +145,7 @@ public function testShouldSetDefaultConfigurationForClient() 'client' => [ 'prefix' => 'enqueue', 'app_name' => 'app', - 'router_processor' => 'enqueue.client.router_processor', + 'router_processor' => RouterProcessor::class, 'router_topic' => 'default', 'router_queue' => 'default', 'default_processor_queue' => 'default', diff --git a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/EnqueueExtensionTest.php b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/EnqueueExtensionTest.php index 014e7c3b5..806fe9754 100644 --- a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/EnqueueExtensionTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/EnqueueExtensionTest.php @@ -8,6 +8,8 @@ use Enqueue\Bundle\Tests\Unit\Mocks\TransportFactoryWithoutDriverFactory; use Enqueue\Client\Producer; use Enqueue\Client\TraceableProducer; +use Enqueue\Consumption\QueueConsumer; +use Enqueue\JobQueue\JobRunner; use Enqueue\Null\NullContext; use Enqueue\Null\Symfony\NullTransportFactory; use Enqueue\Symfony\DefaultTransportFactory; @@ -17,6 +19,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\DependencyInjection\Extension; +use Symfony\Component\HttpKernel\Kernel; class EnqueueExtensionTest extends TestCase { @@ -182,7 +185,7 @@ public function testShouldLoadClientServicesWhenEnabled() self::assertTrue($container->hasDefinition('foo.driver')); self::assertTrue($container->hasDefinition('enqueue.client.config')); - self::assertTrue($container->hasDefinition('enqueue.client.producer')); + self::assertTrue($container->hasDefinition(Producer::class)); } public function testShouldNotCreateDriverIfFactoryDoesNotImplementDriverFactoryInterface() @@ -223,7 +226,7 @@ public function testShouldUseProducerByDefault() ], ]], $container); - $producer = $container->getDefinition('enqueue.client.producer'); + $producer = $container->getDefinition(Producer::class); self::assertEquals(Producer::class, $producer->getClass()); } @@ -247,7 +250,7 @@ public function testShouldUseMessageProducerIfTraceableProducerOptionSetToFalseE ], ]], $container); - $producer = $container->getDefinition('enqueue.client.producer'); + $producer = $container->getDefinition(Producer::class); self::assertEquals(Producer::class, $producer->getClass()); } @@ -271,16 +274,23 @@ public function testShouldUseTraceableMessageProducerIfTraceableProducerOptionSe ], ]], $container); - $producer = $container->getDefinition('enqueue.client.traceable_producer'); + $producer = $container->getDefinition(TraceableProducer::class); self::assertEquals(TraceableProducer::class, $producer->getClass()); self::assertEquals( - ['enqueue.client.producer', null, 0], + [Producer::class, null, 0], $producer->getDecoratedService() ); self::assertInstanceOf(Reference::class, $producer->getArgument(0)); + + $innerServiceName = sprintf('%s.inner', TraceableProducer::class); + if (30300 > Kernel::VERSION_ID) { + // Symfony 3.2 and below make service identifiers lowercase, so we do the same. + $innerServiceName = strtolower($innerServiceName); + } + self::assertEquals( - 'enqueue.client.traceable_producer.inner', + $innerServiceName, (string) $producer->getArgument(0) ); } @@ -345,7 +355,7 @@ public function testShouldLoadJobServicesIfEnabled() 'job' => true, ]], $container); - self::assertTrue($container->hasDefinition('enqueue.job.runner')); + self::assertTrue($container->hasDefinition(JobRunner::class)); } public function testShouldNotLoadJobServicesIfDisabled() @@ -360,7 +370,7 @@ public function testShouldNotLoadJobServicesIfDisabled() 'job' => false, ]], $container); - self::assertFalse($container->hasDefinition('enqueue.job.runner')); + self::assertFalse($container->hasDefinition(JobRunner::class)); } public function testShouldAllowGetConfiguration() @@ -551,7 +561,7 @@ public function testShouldConfigureQueueConsumer() ], ]], $container); - $def = $container->getDefinition('enqueue.consumption.queue_consumer'); + $def = $container->getDefinition(QueueConsumer::class); $this->assertSame(123, $def->getArgument(2)); $this->assertSame(456, $def->getArgument(3)); diff --git a/pkg/enqueue/Symfony/Client/ContainerAwareProcessorRegistry.php b/pkg/enqueue/Symfony/Client/ContainerAwareProcessorRegistry.php index 2b42cec18..b378eb45d 100644 --- a/pkg/enqueue/Symfony/Client/ContainerAwareProcessorRegistry.php +++ b/pkg/enqueue/Symfony/Client/ContainerAwareProcessorRegistry.php @@ -6,6 +6,7 @@ use Interop\Queue\PsrProcessor; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; +use Symfony\Component\HttpKernel\Kernel; class ContainerAwareProcessorRegistry implements ProcessorRegistryInterface, ContainerAwareInterface { @@ -38,6 +39,12 @@ public function set($processorName, $serviceId) */ public function get($processorName) { + if (30300 > Kernel::VERSION_ID) { + // Symfony 3.2 and below make service identifiers lowercase, so we do the same. + // To be removed when dropping support for Symfony < 3.3. + $processorName = strtolower($processorName); + } + if (false == isset($this->processors[$processorName])) { throw new \LogicException(sprintf('Processor was not found. processorName: "%s"', $processorName)); } From 031380e5f8b9069dcf9d996da42c58ead38e7ac3 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Mon, 30 Oct 2017 14:20:21 +0200 Subject: [PATCH 4/6] amqp transport fixes. --- bin/build-rabbitmq-ssl-image.sh | 5 +- bin/dev | 4 +- bin/test | 2 +- docker-compose.yml | 16 +++-- pkg/enqueue/Symfony/AmqpTransportFactory.php | 65 +++++++++++++------- var/rabbitmq_certificates/cacert.pem | 17 +++++ var/rabbitmq_certificates/cert.pem | 18 ++++++ var/rabbitmq_certificates/key.pem | 27 ++++++++ var/rabbitmq_certificates/req.pem | 16 +++++ 9 files changed, 132 insertions(+), 38 deletions(-) create mode 100644 var/rabbitmq_certificates/cacert.pem create mode 100644 var/rabbitmq_certificates/cert.pem create mode 100644 var/rabbitmq_certificates/key.pem create mode 100644 var/rabbitmq_certificates/req.pem diff --git a/bin/build-rabbitmq-ssl-image.sh b/bin/build-rabbitmq-ssl-image.sh index 635bde953..5bb52043a 100755 --- a/bin/build-rabbitmq-ssl-image.sh +++ b/bin/build-rabbitmq-ssl-image.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash - set -e set -x @@ -15,6 +14,4 @@ rm -rf /tmp/roboconf/* (cd /tmp/roboconf/rabbitmq-with-ssl-in-docker && docker push "enqueue/rabbitmq-ssl:latest") docker run --rm -v "`pwd`/var/rabbitmq_certificates:/enqueue" "enqueue/rabbitmq-ssl:latest" cp /home/testca/cacert.pem /enqueue/cacert.pem - - - +docker run --rm -v "`pwd`/var/rabbitmq_certificates:/enqueue" "enqueue/rabbitmq-ssl:latest" /bin/bash -c "/bin/bash /home/generate-client-keys.sh && cp /home/client/key.pem /enqueue/key.pem && cp /home/client/cert.pem /enqueue/cert.pem" diff --git a/bin/dev b/bin/dev index d0d87b0bf..46bf47995 100755 --- a/bin/dev +++ b/bin/dev @@ -3,10 +3,10 @@ set -x set -e -while getopts "bustefcd" OPTION; do +while getopts "bustefcdp" OPTION; do case $OPTION in b) - COMPOSE_PROJECT_NAME=mqdev docker-compose build + COMPOSE_PROJECT_NAME=mqdev docker-compose pull && COMPOSE_PROJECT_NAME=mqdev docker-compose build ;; u) COMPOSE_PROJECT_NAME=mqdev docker-compose up diff --git a/bin/test b/bin/test index e53034ebb..10d072386 100755 --- a/bin/test +++ b/bin/test @@ -30,7 +30,7 @@ function waitForService() trap "FORCE_EXIT=true" SIGTERM SIGINT waitForService rabbitmq 5672 50 -waitForService rabbitmq_ssl 5671 50 +waitForService rabbitmqssl 5671 50 waitForService mysql 3306 50 waitForService redis 6379 50 waitForService beanstalkd 11300 50 diff --git a/docker-compose.yml b/docker-compose.yml index 7d247510c..a25178854 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,6 @@ services: # build: { context: docker, dockerfile: Dockerfile } depends_on: - rabbitmq - - rabbitmq_ssl - mysql - redis - beanstalkd @@ -14,11 +13,12 @@ services: - kafka - zookeeper - google-pubsub + - rabbitmqssl volumes: - './:/mqdev' environment: - AMQP_DSN=amqp://guest:guest@rabbitmq:5672/mqdev - - AMQPS_DSN=amqps://guest:guest@rabbitmq_ssl:5671 + - AMQPS_DSN=amqps://guest:guest@rabbitmqssl:5671 - DOCTINE_DSN=mysql://root:rootpass@mysql/mqdev - SYMFONY__RABBITMQ__HOST=rabbitmq - SYMFONY__RABBITMQ__USER=guest @@ -47,7 +47,7 @@ services: - GCLOUD_PROJECT=mqdev rabbitmq: - image: enqueue/rabbitmq:latest + image: 'enqueue/rabbitmq:latest' # build: { context: docker, dockerfile: Dockerfile.rabbitmq } environment: - RABBITMQ_DEFAULT_USER=guest @@ -56,13 +56,11 @@ services: ports: - "15677:15672" - rabbitmq_ssl: - image: enqueue/rabbitmq-ssl:latest + rabbitmqssl: + image: 'enqueue/rabbitmq-ssl:latest' environment: - - RABBITMQ_DEFAULT_USER=guest - - RABBITMQ_DEFAULT_PASS=guest - volumes: - - './var/rabbitmq_certificates:/home/client' + - 'RABBITMQ_DEFAULT_USER=guest' + - 'RABBITMQ_DEFAULT_PASS=guest' beanstalkd: image: 'jonbaldie/beanstalkd' diff --git a/pkg/enqueue/Symfony/AmqpTransportFactory.php b/pkg/enqueue/Symfony/AmqpTransportFactory.php index d098762ab..8a2a20ee9 100644 --- a/pkg/enqueue/Symfony/AmqpTransportFactory.php +++ b/pkg/enqueue/Symfony/AmqpTransportFactory.php @@ -34,16 +34,7 @@ public function __construct($name = 'amqp') */ public function addConfiguration(ArrayNodeDefinition $builder) { - $drivers = []; - if (class_exists(AmqpExtConnectionFactory::class)) { - $drivers[] = 'ext'; - } - if (class_exists(AmqpLibConnectionFactory::class)) { - $drivers[] = 'lib'; - } - if (class_exists(AmqpBunnyConnectionFactory::class)) { - $drivers[] = 'bunny'; - } + $transportsMap = static::getAvailableTransportsMap(); $builder ->beforeNormalization() @@ -59,8 +50,19 @@ public function addConfiguration(ArrayNodeDefinition $builder) }) ->end() ->children() - ->enumNode('driver') - ->values($drivers) + ->scalarNode('driver') + ->validate() + ->always(function ($v) use ($transportsMap) { + $drivers = array_keys($transportsMap); + if (empty($transportsMap)) { + throw new \InvalidArgumentException('There is no amqp driver available. Please consider installing one of the packages: enqueue/amqp-ext, enqueue/amqp-lib, enqueue/amqp-bunny.'); + } + + if (isset($v['driver']) && false == in_array($v['driver'], $drivers, true)) { + throw new \InvalidArgumentException(sprintf('Unexpected driver given "invalidDriver". Available are "%s"', implode('", "', $drivers))); + } + }) + ->end() ->end() ->scalarNode('dsn') ->info('The connection to AMQP broker set as a string. Other parameters could be used as defaults') @@ -200,18 +202,18 @@ public function getName() public static function createConnectionFactoryFactory(array $config) { - if (array_key_exists('driver', $config)) { - if ('ext' == $config['driver']) { - return new AmqpExtConnectionFactory($config); - } - if ('lib' == $config['driver']) { - return new AmqpLibConnectionFactory($config); - } - if ('bunny' == $config['driver']) { - return new AmqpBunnyConnectionFactory($config); + if (false == empty($config['driver'])) { + $transportsMap = static::getAvailableTransportsMap(); + + if (false == array_key_exists($config['driver'], $transportsMap)) { + throw new \InvalidArgumentException(sprintf('Unexpected driver given "invalidDriver". Available are "%s"', implode('", "', array_keys($transportsMap)))); } - throw new \LogicException(sprintf('Unexpected driver given "%s"', $config['driver'])); + $connectionFactoryClass = $transportsMap[$config['driver']]; + + unset($config['driver']); + + return new $connectionFactoryClass($config); } $dsn = array_key_exists('dsn', $config) ? $config['dsn'] : 'amqp:'; @@ -225,4 +227,23 @@ public static function createConnectionFactoryFactory(array $config) return new $factoryClass($config); } + + /** + * @return string[] + */ + private static function getAvailableTransportsMap() + { + $map = []; + if (class_exists(AmqpExtConnectionFactory::class)) { + $map['ext'] = AmqpExtConnectionFactory::class; + } + if (class_exists(AmqpLibConnectionFactory::class)) { + $map['lib'] = AmqpLibConnectionFactory::class; + } + if (class_exists(AmqpBunnyConnectionFactory::class)) { + $map['bunny'] = AmqpBunnyConnectionFactory::class; + } + + return $map; + } } diff --git a/var/rabbitmq_certificates/cacert.pem b/var/rabbitmq_certificates/cacert.pem new file mode 100644 index 000000000..d0ace80a6 --- /dev/null +++ b/var/rabbitmq_certificates/cacert.pem @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICxjCCAa6gAwIBAgIJAJQiwgTxMOEsMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNV +BAMMCE15VGVzdENBMB4XDTE3MTAzMDExNDYyMFoXDTE4MTAzMDExNDYyMFowEzER +MA8GA1UEAwwITXlUZXN0Q0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB +AQCjmnPzpeM0iBVv2JNe0p+KueGQEeCQPG7WSuIEojXa7WMjiZuCzfBEAFSytwCI +Q90rolPuOZoy6lxOX+K4Sr20I94xPfIlV5naHBjMj5yTPGSbFtpGjhnOIOHkqzh7 +Ffz3HnBDeXbMABnCQifVnUrRv/tYLE/F8pC33uLgKrouoalLW9eWEtzXyFxpo7Jd +LXdV60D/as5Z3Vp9R3swax4LMgV17GsQEfIT/FzgjmSiPEjqZCWbMGrQlRUrn4lF +IB3M62ACIWfS7SRx0y5Yy7IJ4L/3OEvL+2VvOHs/9TatXhrldE/Lmp5OEsw+z5Y0 +L2e97t+Xl4OlUCP8zT9AkeIhAgMBAAGjHTAbMAwGA1UdEwQFMAMBAf8wCwYDVR0P +BAQDAgEGMA0GCSqGSIb3DQEBCwUAA4IBAQBkyVzkXo74tW1ZpE9hLOov/ZwME7Xo +bdgvLPlpQMURuKsosU9hMtYJ5y5dO+U6GwOvH7SYoS7oNzu+sLnMK0877UipuTi2 +puLVpCoqMpp3gonj8QL6+uNOmtLMTUcv2eZA02zsm956wr72gOwZHpdgVjLq31rX +4E29YU8yDfRZQsP6STbEYG32Om6ko7JgWzSaUqtim4xpKTAAxC5MN8MpXoM4oMoN +2obJDCql74nQw4UgtDLEJODJ3hOSdoel4Z272GvBb09pb9J+70xSpNWYj2PvcICK +XGgHCweEiZQ4eUCvhRwlgA/LMe4kx81+kCaGAd879yRi61zTG2r/agLE +-----END CERTIFICATE----- diff --git a/var/rabbitmq_certificates/cert.pem b/var/rabbitmq_certificates/cert.pem new file mode 100644 index 000000000..b54db4682 --- /dev/null +++ b/var/rabbitmq_certificates/cert.pem @@ -0,0 +1,18 @@ +-----BEGIN CERTIFICATE----- +MIIC5TCCAc2gAwIBAgIBAjANBgkqhkiG9w0BAQsFADATMREwDwYDVQQDDAhNeVRl +c3RDQTAeFw0xNzEwMzAxMTQ2NDhaFw0xODEwMzAxMTQ2NDhaMCgxFTATBgNVBAMM +DDIxZWViZWZmMTkwMDEPMA0GA1UECgwGY2xpZW50MIIBIjANBgkqhkiG9w0BAQEF +AAOCAQ8AMIIBCgKCAQEArhfeHBC++s1rHiaLfqTSZKFkFMjOwqKElf01hMDQQf50 +nvg5kNifkl0ov9qC8yIPyyUPfrHNalz3uCfjnuRtad88EK/N4SD+xgFJqp8AykO+ +hRDkjCyE+ujt4hXNwrQawRxdntsXrvMacSrkFJ5Yx+l9a9tJ6f4qrEeeWc6UeosY +EVdN+id18Zf/MPOMyIVAB201clcsOqBCVZ5tscYngELCu6DqZegUWGqMgv6CBAlY ++enZpM8FWt2AYCajn2Lsyi/p+ob71YY3GwSox8AS0O/7sLYvAiWwsg34xPwZq79N +dgJrwak8wJiRXZHSbPyPO8xeBP6NOBr3Nsgnj5qqkQIDAQABoy8wLTAJBgNVHRME +AjAAMAsGA1UdDwQEAwIHgDATBgNVHSUEDDAKBggrBgEFBQcDAjANBgkqhkiG9w0B +AQsFAAOCAQEABGCF+pODR7HL5jUWzkgeKJ5ytG3ZraCWb3kF3Xv5b3SKR2N5jJSK +A/6wfLMyvHGCdAmJXVg/AEmq2fIvBG3Wn1Mlc4xyZjQEWBbHHz2EyreacVZAhrru +gWhwtu/Z3efm9OcITCebwBHGXAYg/6XzMDrPQcaUL+62Xsq4fbh5UzN0vwDkFV55 +xZWAlQe/Mb+7aKDpzyF7Nka/if3I8ukQBbTmFw16JHV9wPGnJ3KzXv2Z6uf5hVQg +MjYEBqJZnA/E6KpCfIv8jjubzk380SVfX2gONtvEfyKLpm8vT4ZmzV6jrrrwUwSq +EI1T9q/tokHywEWB+aM83KXcUNkaosg3WA== +-----END CERTIFICATE----- diff --git a/var/rabbitmq_certificates/key.pem b/var/rabbitmq_certificates/key.pem new file mode 100644 index 000000000..2b5a95db2 --- /dev/null +++ b/var/rabbitmq_certificates/key.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEArhfeHBC++s1rHiaLfqTSZKFkFMjOwqKElf01hMDQQf50nvg5 +kNifkl0ov9qC8yIPyyUPfrHNalz3uCfjnuRtad88EK/N4SD+xgFJqp8AykO+hRDk +jCyE+ujt4hXNwrQawRxdntsXrvMacSrkFJ5Yx+l9a9tJ6f4qrEeeWc6UeosYEVdN ++id18Zf/MPOMyIVAB201clcsOqBCVZ5tscYngELCu6DqZegUWGqMgv6CBAlY+enZ +pM8FWt2AYCajn2Lsyi/p+ob71YY3GwSox8AS0O/7sLYvAiWwsg34xPwZq79NdgJr +wak8wJiRXZHSbPyPO8xeBP6NOBr3Nsgnj5qqkQIDAQABAoIBAFivLeUsHq2SgRO9 +3OepvMeoc1wnIzSBJ3tknqO+uRg1MGFe36xKvZcIv95jyLtkSZlZirgmiRa6vzJf +l5N0l8wL/QQfGoipjz98nnM9RmDC+8W7YkGJ2EAc8jluk/+wUcS313U59KmZi4nE +qKVcOKu15L9R2ShK4qAaZ68mDfsSEv0XRTqCdQ3ru2PAqlpFhReB1eg6IqZPx2Jx +R/REba4aAMPk/lmuXNlJCVeQUWWbV1aELRzOxZqXF/g+ea/Z9cbag7IQUbcnhvcl +pwfcQuh5HXitRdGNwZr4yBv/ElFU4QMnA7mct6J0alXk+HsBRiJlKZYn0or+gmP1 +gYnDj8UCgYEA2nx/oGbABYPtz3ige/c0bbrjbDZBzTA8z3dASoAFskEaG2g831/0 +8OYWSbwaoYSjYJXsx8493ucGqvLJYu7oravpPfwjpdATbkQX09XsPX9VR8Q3W8IS +jBjR4KtT7+mgih04OtthRf4jmx9wfm7iG0yMB++7LobZv2tSPpWQiL8CgYEAy/wV +gOsbUEAEpQ+7np/jVVbUUxte+IOz0g8UAbvxkKQM9Ri3WvFc8lunyOkfivfT/DHv +UOC6ZskC4foxhZ+KlxSkhn4ALHTbRuncUi0lUQHqxhFzNEa57k926mZj7BKoKF++ +nPQsHnydhSiccciNFRsExT7KYITRUG++OWfO0K8CgYEAtKhpJ4qOkIDsLLdDi/12 +Pp1f22RpuG6AedPTN0bwbtph6fOhEdrYQDEgkMuXAaMZLI4LgZNJmXxSCRxD5ShD +AQe7DuPj3gFVb8GiKiki9B7Lt1HJrHemumzzbeB8wU3ezxUmH5SytBtV+bhfXkv1 +bjk3OIDDt88NUbg+Az3MiyUCgYAiTykSwPicG9hsJuRIvt3Oycb2n4DuzcAeEbks +vX7Y9C7Vvq2AV15pyS7EZSmQBzUZkxCMiu/vP9oDRkC0F+yIkslFccX3tEP5fnY3 +QC6pnGfvnpnA7jBxu93leQlPeKfd+pSl84/EJPOdpQIDRVcteJjp0DDb4RsPq2vU +Xfh0MwKBgQDMAfq0YVp0dmp6Od3+LoVAyRqiqZuAW7ZCZb7ld+6eiEiGzuCEQtex +qUSakDdS7Ys6pRCt8dwfkykYybggx8qZouixX3Rd4Q/fmPM493CgdlqsvH3FN9vP +uE/AxDmbkqfajjC6uk3bu/mo4q8k1qp69OArG5rIymeeD0PG11Y0wA== +-----END RSA PRIVATE KEY----- diff --git a/var/rabbitmq_certificates/req.pem b/var/rabbitmq_certificates/req.pem new file mode 100644 index 000000000..f809d16d8 --- /dev/null +++ b/var/rabbitmq_certificates/req.pem @@ -0,0 +1,16 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIICbTCCAVUCAQAwKDEVMBMGA1UEAwwMMjZlZDE0OGIwZjE2MQ8wDQYDVQQKDAZj +bGllbnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDI7GiCTS8V2GLd +tZPmVmVVocVVGmaES5gc17/qft7z+/zv/2hCR0Dd3V2hpyH6fa4Y8nabC1nuMgO1 +XwGiGaPPTXX/djgSzPNneTZNSxMoxCXtIsxe5TNOdLPTzE9RSXQofplhcAt/jJx/ +wNHFFJy9oGOiiwEWNsccIcxS08kr8r3IYF7l22wTiWpxn7OahTQrH25/z/RTLDk+ +WsxfWYNApF8p3mM2V6ueBGS07TPLej4HDZzjG+ST/nCAIQLTW86DdnDTPc0Dcp7M +ymoQwyKDRDPX0eSZ1mM5FPBR+sLm/fl2IWtek2VVu79PXaQsvAt+/y29VPTpP171 +m9LRnEhXAgMBAAGgADANBgkqhkiG9w0BAQsFAAOCAQEAsrf3RYCxNQj7SgHJ8uC5 +H6ZWftjigtxysVX85Il9ox7I+zQtdSKZ834T9wyG+L9l870I7bM5DmjZn7uocoio +xFo/zALdGJ/IU5br/FgtoQjRkKi+PdGB8023Ab3R2Azsf/0BccduFR5TfD18oIKo +XGtwdLIpsfmeTWfHBN81HOXWkiRCT0IQXApIjl6H0mSKae9qOkEaL9b9iL6YaPyg +PUroYPqJqfnJDnoSRkWhHAe/uuTRD1xUWbVZc1QQ9FzdQa83uMGRRF2Yl2TX4qS5 +UpLbwLMsjFg0uBdCMwLeHVXSVC6ozJR5IpDfhEgLvSdGx39ZCiZldRfWNz12yllI +1g== +-----END CERTIFICATE REQUEST----- From 56e231afe38f54889f8f89e633dbd508b5ac3fc0 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Mon, 30 Oct 2017 14:46:26 +0200 Subject: [PATCH 5/6] add retries to sqs test --- pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromTopicTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromTopicTest.php b/pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromTopicTest.php index 831b23775..56ca7dc08 100644 --- a/pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromTopicTest.php +++ b/pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromTopicTest.php @@ -4,16 +4,19 @@ use Enqueue\Sqs\SqsContext; use Enqueue\Sqs\SqsDestination; +use Enqueue\Test\RetryTrait; use Enqueue\Test\SqsExtension; use Interop\Queue\PsrContext; use Interop\Queue\Spec\SendToAndReceiveFromTopicSpec; /** * @group functional + * @retry 5 */ class SqsSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec { use SqsExtension; + use RetryTrait; /** * @var SqsContext From 75c91fa449bc1c4dc3518e030956577aac2c987c Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Wed, 1 Nov 2017 09:40:25 +0200 Subject: [PATCH 6/6] Release 0.8.3 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5711b7279..e64af62d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## [0.8.3](https://github.com/php-enqueue/enqueue-dev/tree/0.8.3) (2017-11-01) +[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.8.2...0.8.3) + +- \[Symfony\]\[Minor\] profiler view when no messages collected during the request [\#243](https://github.com/php-enqueue/enqueue-dev/issues/243) +- \[bundle\] streamline profiler view when no messages were sent [\#247](https://github.com/php-enqueue/enqueue-dev/pull/247) ([dkarlovi](https://github.com/dkarlovi)) +- \[bundle\] Renamed exposed services' name to classes' FQCN [\#242](https://github.com/php-enqueue/enqueue-dev/pull/242) ([Lctrs](https://github.com/Lctrs)) + ## [0.8.2](https://github.com/php-enqueue/enqueue-dev/tree/0.8.2) (2017-10-27) [Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.8.1...0.8.2)