|
3 | 3 | namespace Enqueue\Bundle\DependencyInjection; |
4 | 4 |
|
5 | 5 | use Enqueue\AsyncEventDispatcher\DependencyInjection\AsyncEventDispatcherExtension; |
| 6 | +use Enqueue\Client\CommandSubscriberInterface; |
6 | 7 | use Enqueue\Client\Producer; |
| 8 | +use Enqueue\Client\TopicSubscriberInterface; |
7 | 9 | use Enqueue\Client\TraceableProducer; |
8 | 10 | use Enqueue\Consumption\QueueConsumer; |
9 | 11 | use Enqueue\JobQueue\Job; |
@@ -72,6 +74,8 @@ public function load(array $configs, ContainerBuilder $container) |
72 | 74 | $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
73 | 75 | $loader->load('services.yml'); |
74 | 76 |
|
| 77 | + $this->setupAutowiringForProcessors($container); |
| 78 | + |
75 | 79 | foreach ($config['transport'] as $name => $transportConfig) { |
76 | 80 | $this->factories[$name]->createConnectionFactory($container, $transportConfig); |
77 | 81 | $this->factories[$name]->createContext($container, $transportConfig); |
@@ -220,4 +224,19 @@ private function registerJobQueueDoctrineEntityMapping(ContainerBuilder $contain |
220 | 224 | } |
221 | 225 | } |
222 | 226 | } |
| 227 | + |
| 228 | + private function setupAutowiringForProcessors(ContainerBuilder $container) |
| 229 | + { |
| 230 | + if (!method_exists($container, 'registerForAutoconfiguration')) { |
| 231 | + return; |
| 232 | + } |
| 233 | + |
| 234 | + $container->registerForAutoconfiguration(TopicSubscriberInterface::class) |
| 235 | + ->setPublic(true) |
| 236 | + ->addTag('enqueue.client.processor'); |
| 237 | + |
| 238 | + $container->registerForAutoconfiguration(CommandSubscriberInterface::class) |
| 239 | + ->setPublic(true) |
| 240 | + ->addTag('enqueue.client.processor'); |
| 241 | + } |
223 | 242 | } |
0 commit comments