symfony 1.4 rabbit mq plugin using Thumper
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
lib
README.md

README.md

sfRabbitPlugin is symfony 1.4 plugin that provides access to rabbitmq messaging system.

Now it's just backport of videlalvaro's symfony2 RabbitMqBundle and it uses unchanged videlalvaro's Thumper and tnc's php-amqplib backend.

It uses Consumer and Producer classes from thumper ( https://github.com/videlalvaro/Thumper ), but configures them via symfony yml configuration, so checkout thumper examples too!

Enable the plugin

	$this->enablePlugins('sfRabbitPlugin');

Some examples:

Publish message $msg with $routing_key

define producer in config

producers:
  test:
    connection:       default
    exchange_options: {name: test_direct, type: direct}

and then publish message somewhere

try {
    $producer = sfRabbit::getProducer('test');
    $producer->publish(serialize($msg), $routing_key);
} catch (Exception $e){
    sfContext::getInstance()->getLogger()->err($e);
}

Consume messages

create message handler

class MsgHandler
{
    public static function execute($msg)
    {        
        $msg = unserialize($msg);
        do_something_with_message($msg)
    }
}

define consumer in config

consumers:
  test:
    connection:       default
    exchange_options: {name: test_direct, type: direct}
    queue_options: {name: test}
    callback:         MsgHandler 

run consumer task or check its code and use it somewhere else

symfony rabbitmq:consumer test 

you can find all optional arguments in source code