Coder Social home page Coder Social logo

yiiamqp's Introduction

YiiAMQP

YiiAMQP is a fully functional AMQP producer and conusumer Yii application component.

##Requirements

Tested with Yii version 1.1.13

##Quick Start

Install via composer, then configure your application to use this component by adding and updating to match your needs the following configuration

'components' => array(
        'mq' => array(
            'class' => 'YiiAMQP\Client',
            'connection' => array(
                'host' => 'localhost',
                'port' => '5672',
                'vhost' => '/',
                'user' => 'guest',
                'password' => 'guest'
            )
        ),

##Usage

Producer

$myMessage = array('greeting' => 'Hello World');
Yii::app()->mq->exchanges->greeter->send($myMessage); // will be JSON encoded

Consumer

Initialise the component

Yii::app()->mq->defaultQueue->consume(function($message){ print_r($message); });
Yii::app()->mq->queues->myQueue->consume(function($message){ print_r($message); });
Yii::app()->mq->wait(); // wait for results

##Contributing Please submit all pull requests against *-wip branches. Thanks!

##Bug tracker If you find any bugs, please create an issue at https://github.com/mteichtahl/YiiAMQP/issues

##Credits

##License

MIT.

yiiamqp's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yiiamqp's Issues

Hello Marc

I'm look inside your AppComponent and seeing usage of RabbitMQService( i can't find this file anywhere) - what is it? and why for start using YiiAMQP extension we need to define // YiiAMQP
'rabbitMQ' => array(
'class' => 'YiiAMQP\Client', \ why client and not AppComponent?
'connection' => array(
'host' => 'localhost',
'port' => '5673',
'vhost' => '/',
'user' => 'Yrabbit',
'password' => 'bloodyRabbit'
)
),

include(Client.php): failed to open stream: No such file or directory

HI mteichtahl,

I am a bit of a newbie when it comes to Yii and I am seeing this error when I run the producer.
This is my config.file
'mq' => array(
'class' => 'application.components.YiiAMQP.src.YiiAMQP.Client',
'connection' => array(
'host' => 'localhost',
'port' => '5672',
'vhost' => '/',
'user' => 'guest',
'password' => 'guest'
)),

and this is my producer in controller
Yii::app()->mq->createConnection();
Yii::app()->mq->declareQueue('mail_queue');
Yii::app()->mq->declareExchange('amq.direct', 'direct');
Yii::app()->mq->bind('mail_queue', 'amq.direct', 'mail_queue');
Yii::app()->mq->setQoS('0', '1', '0');
Yii::app()->mq->sendJSONMessage('"test":"test"','mail_queue');
Yii::app()->mq->sendTextMessage('Hello"','mail_queue');

The error is showing at line Yii::app()->mq->declareQueue('mail_queue');
Can you point me in the right direction ?

Thanks,
BALA

'Alias "application.components.RabbitMQ.RabbitMQ" is invalid.

HI mteichtahl,

Thanks so much for putting this together. It will be a huge help to me if I can get it working.

I am a bit of a newbie when it comes to Yii and I am seeing this error when I am loading your extension.

Perhaps I have done something wrong with the Autoloader. Here is the error
exception 'CException' with message 'Alias "application.components.RabbitMQ.RabbitMQ" is invalid. Make sure it points to an existing PHP file and the file is readable.' in /etc/pressjack/ENV/test/www/pressjack-site/yii/framework/YiiBase.php:318

Can you point me in the right direction ?

Thanks

Dave

Do not get settings from main.php by default.

There is a bug in YiiAMQP\Client which do not allow to get settings from config file by default. In getConnectionConfig method there is $this->_connectionConfig = array( ... . Which add default hardcoded settings to the future connection. But we have already settings in public $server var. My suggestion is using main.php settings there:

public function getConnectionConfig()
    {
        if ($this->_connectionConfig === array()) {
            if($this->server) // Check if $server is not null etc.
                $this->_connectionConfig = $this->server; // Use it
            else $this->_connectionConfig = array(
                        'host' => 'localhost',
                        'port' => 5672,
                        'user' => 'guest',
                        'password' => 'guest',
                        'vhost' => '/',
                    );
        }
        return $this->_connectionConfig;
    }

AMQP_DEBUG

defined('AMQP_DEBUG') or define('AMQP_DEBUG',false); in Client.php

Missing documentation

I'm not sure the documentation is complete...

I've configured according to the specs

and defined the component 'RabbitMQ' as application.components.RabbitMQ.RabbitMQ

However, pulling down the git repo creates a YiiAMQP folder with a YiiAMQP.php file namespaced as YiiAMQP.

This suggests some naming confusion, and secondly i'm completely unsure how the autoloading flow should work to diagnose it.

I'm missing something.

I tried adding:

Yii::app()->autoloader->getAutoloader()->addNamespace('YiiAMQP', dirname(FILE).'/.components/YiiAMQP'); as suggested by the EAutoloader class

Using extension

please write a small demo of using extension, there is no documentation

How to Configure Rabbitmq with yii

HI mteichtahl,,

I Am new to yii and php and i have to implement the mail queue system in yii framework using rabbitmq, can point me by step by step process to success it.

Thanks,
Hari

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.