Search code examples
phpdoctrinequeuejobszend-framework3

Queue manager recommendations for Zend Framework 3


We are currently migrating our system from ZF2 to ZF3. In ZF2, in order to queue long/resource greedy jobs in background, we used SlmQueue with SlmQueueBeanstalkd Adapter. However, it turns out SlmQueueBeanstalkd is no longer maintained, which is preventing us from upgrading because of dependency conflicts.

Can you provide me good alternatives that would require a reasonable amount of changes in code?

I was considering SlmQueueDoctrine as it seems to be maintained and somewhat comparable to our current stack.


Solution

  • We ended up using SlmQueueDoctrine which required very little code changes:

    In short: Our jobs needed to implement ObjectManagerAwareInterface which has the setter and getter for the object manager that the queue manager uses internally. We needed to inject the object manager on each of our jobs via constructor.

    /** @var ObjectManager $entityManager */
    $entityManager = $container->get('doctrine.entitymanager.orm_default');
    
    return new Job($entityManager);
    

    For the above to work we enabled DoctrineModule, DoctrineORMModule and SlmQueueDoctrine in application.config

    After that we configure our queues in config.local and config.global. I will not put the configurations in here since they are kind of big. I recommend reading the README.md of SlmqueueDoctrine and the documentation of Slmqueue.