- Member | 2
I need to write a series of PHP daemons for one of my projects written in Nette. I can't use Cron because the daemons need to be able to react to a message immediately. I want to use PHP and Nette because I want to be able to reuse existing code from the models. Also let's ignore the problem with possible memory leaks, and/or GC issues.
So far I had two ideas, the first one is to copy the micro blog example and somehow hack it to do what I want, or use the CLI router somehow.
Frankly, I don't like either of those ideas, the first one sounds quite nasty. for the second one, I'd have to put the daemon logic into a presenter, and I don't like that idea.
How would you go about it? Is there a smart way to achieve this?
Thanks in advance.
- Member | 620
why would you want to commit such atrocities?
i use the following approach
<?php $container = require_once __DIR__ . '/../bootstrap.php'; $daemon = $container->ironMQConsumer; $queue = 'queueName'; $callback = callback($container->messageProcessor, 'process'); $daemon->bindQueue($queue)->addCallback($callback)->consume(); ?>
where consume() function contains some while or whatever that reads messages from queue