schmittjoh / JMSJobQueueBundle

Run and Schedule Symfony Console Commands as Background Jobs
http://jmsyst.com/bundles/JMSJobQueueBundle
335 stars 254 forks source link

Symfony 4 Issue: jms_job_queue.scheduler_registry ServiceNotFound #210

Closed jspizziri closed 6 years ago

jspizziri commented 6 years ago

Using the symfony4 branch I was receiving a ServiceNotFoundExecption here when attempting to get the scheduler_registry service.

Fatal error: Uncaught Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "jms_job_queue.scheduler_registry". in /var/www/app/vendor/symfony/dependency-injection/ContainerBuilder.php:978
Stack trace:
#0 /var/www/app/vendor/jms/job-queue-bundle/JMS/JobQueueBundle/DependencyInjection/CompilerPass/JobSchedulersPass.php(24): Symfony\Component\DependencyInjection\ContainerBuilder->getDefinition('jms_job_queue.s...')
#1 /var/www/app/vendor/symfony/dependency-injection/Compiler/Compiler.php(95): JMS\JobQueueBundle\DependencyInjection\CompilerPass\JobSchedulersPass->process(Object(Symfony\Component\DependencyInjection\ContainerBuilder))
#2 /var/www/app/vendor/symfony/dependency-injection/ContainerBuilder.php(713): Symfony\Component\DependencyInjection\Compiler\Compiler->compile(Object(Symfony\Component\DependencyInjection\ContainerBuilder))
#3 /var/www/app/vendor/symfony/http-kernel/Kernel.php(513): Symfony\Component\DependencyInjection\ContainerBuilder->compile()
#4 in /var/www/app/vendor/symfony/dependency-injection/ContainerBuilder.php on line 978

I'm not sure if it's a proper fix, but I changed the getDefinition to a findDefinition and I created an alias in my project to the service like so:

# services.yml
JMS\JobQueueBundle\Cron\SchedulerRegistry:
        public: true
        arguments:
            - []
        tags:
            - { name: jms_job_queue.scheduler_registry, alias: jms_job_queue.scheduler_registry }

jms_job_queue.scheduler_registry:
        alias: JMS\JobQueueBundle\Cron\SchedulerRegistry
        public: true

Here's the PR https://github.com/schmittjoh/JMSJobQueueBundle/pull/209

schmittjoh commented 6 years ago

Should be fixed in the latest version.