Skip to content

ElvisTheKing/sfRabbitPlugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 

Repository files navigation

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

About

symfony 1.4 rabbit mq plugin using Thumper

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages