@@ -41,7 +41,7 @@ public function load(array $configs, ContainerBuilder $container)
4141 $ loader = new XmlFileLoader ($ this ->container , new FileLocator (array (__DIR__ . '/../Resources/config ' )));
4242 $ loader ->load ('rabbitmq.xml ' );
4343
44- $ configuration = new Configuration ();
44+ $ configuration = new Configuration ($ this -> getAlias () );
4545 $ this ->config = $ this ->processConfiguration ($ configuration , $ configs );
4646
4747 $ this ->collectorEnabled = $ this ->config ['enable_collector ' ];
@@ -52,6 +52,7 @@ public function load(array $configs, ContainerBuilder $container)
5252 $ this ->loadConsumers ();
5353 $ this ->loadMultipleConsumers ();
5454 $ this ->loadDynamicConsumers ();
55+ $ this ->loadBatchConsumers ();
5556 $ this ->loadAnonConsumers ();
5657 $ this ->loadRpcClients ();
5758 $ this ->loadRpcServers ();
@@ -348,6 +349,47 @@ protected function loadDynamicConsumers()
348349 }
349350 }
350351
352+ protected function loadBatchConsumers ()
353+ {
354+ foreach ($ this ->config ['batch_consumers ' ] as $ key => $ consumer ) {
355+ $ definition = new Definition ('%old_sound_rabbit_mq.batch_consumer.class% ' );
356+ $ definition
357+ ->addTag ('old_sound_rabbit_mq.base_amqp ' )
358+ ->addTag ('old_sound_rabbit_mq.consumer ' )
359+ ->addTag ('old_sound_rabbit_mq.batch_consumer ' )
360+ ->addMethodCall ('setTimeoutWait ' , array ($ consumer ['timeout_wait ' ]))
361+ ->addMethodCall ('setPrefetchCount ' , array ($ consumer ['qos_options ' ]['prefetch_count ' ]))
362+ ->addMethodCall ('setExchangeOptions ' , array ($ this ->normalizeArgumentKeys ($ consumer ['exchange_options ' ])))
363+ ->addMethodCall ('setCallback ' , array (array (new Reference ($ consumer ['callback ' ]), 'execute ' )))
364+ ->addMethodCall ('setQosOptions ' , array (
365+ $ consumer ['qos_options ' ]['prefetch_size ' ],
366+ $ consumer ['qos_options ' ]['prefetch_count ' ],
367+ $ consumer ['qos_options ' ]['global ' ]
368+ ))
369+ ;
370+
371+ if (isset ($ consumer ['idle_timeout ' ])) {
372+ $ definition ->addMethodCall ('setIdleTimeout ' , array ($ consumer ['idle_timeout ' ]));
373+ }
374+
375+ if (!$ consumer ['auto_setup_fabric ' ]) {
376+ $ definition ->addMethodCall ('disableAutoSetupFabric ' );
377+ }
378+
379+ $ this ->injectConnection ($ definition , $ consumer ['connection ' ]);
380+ if ($ this ->collectorEnabled ) {
381+ $ this ->injectLoggedChannel ($ definition , $ key , $ consumer ['connection ' ]);
382+ }
383+
384+ if ($ consumer ['enable_logger ' ]) {
385+ $ this ->injectLogger ($ definition );
386+ }
387+
388+ $ name = sprintf ('old_sound_rabbit_mq.%s_batch ' , $ key );
389+ $ this ->container ->setDefinition ($ name , $ definition );
390+ }
391+ }
392+
351393 protected function loadAnonConsumers ()
352394 {
353395 foreach ($ this ->config ['anon_consumers ' ] as $ key => $ anon ) {
0 commit comments