PHP code example of cog / stupidmqbundle

1. Go to this page and download the library: Download cog/stupidmqbundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cog / stupidmqbundle example snippets


$queue = $this->getContainer()->get('my.queue');
$queue->publish('This is a message !');



namespace My\Bundle\Worker;

use CoG\StupidMQBundle\Worker\WorkerInterface;

class MyWorker implements WorkerInterface
{
    public function execute( $message ) {
        var_dump($message);
        /* you ca give a feedback using \CoG\StupidMQBundle\Feeback\Feedback */
        return Feedback::create(
            MessageInterface::STATE_DONE,
            'here is my feedback'
        );

        /* or just return a boolean */
        return true;
    }

    public function getSubscribedQueues() {
        return array(
            'my.queue'
        );
    }

    public function getName() {
        return 'my.worker';
    }
}