RabbitMQ PHP Application

Source: Internet
Author: User
Tags rabbitmq
RabbitMQ PHP Usage

RABBITMQ is an open source, highly reliable enterprise-class messaging system based on the AMQP (Advanced message Queuing Protocol) standard, with many websites currently in use, including reddit,poppen.de.

1. Installing Rabbitmqsudo apt-get Install Rabbitmq-serversudo/etc/init.d/rabbitmq-server start

?

?

?

2. Installing Librabbitmqsudo apt-get install MERCURIALHG clone HTTP://HG.RABBITMQ.COM/RABBITMQ-CCD Rabbitmq-chg clone http:// Hg.rabbitmq.com/rabbitmq-codegen codegenautoreconf-i &&./configure && make && sudo make Install3. Installing the php-rabbit extension wget http://php-rabbit.googlecode.com/files/php-rabbit.r91.tar.gztar-zxvf PHP-RABBIT.R91.TAR.GZCD Php-rabbit.r91/path/to/php/bin/phpize./configure–with-amqp–with-php-config=/path/to/php/bin/php-configmake && sudo make install edit php.ini add: extension=rabbit.so output phpinfo See if the extension has been loaded successfully, with fun:)

?

?

?

 ' localhost ', ' port ' = 5672, ' login ' = ' guest ', ' password ' = ' gues ' T ', ' vhost ' = '/'); $cnn = new Amqpconnect ($params); DECLARE exchange$exchange = new Amqpexchange ($CNN), $exchange->declare (' ex1 ', ' topic ', amqp_durable);  DECLARE queue$queue = new Amqpqueue ($CNN);  $queue->declare (' queue1 ', amqp_durable); Bind Queue$queue->bind (' Ex1 ', ' wei.# '); publishing$msg = "MSG"; for ($i =0; $i < $i + +) {$res = $exchange->publish ($i. ' msg ', ' Wei '.    $i); if ($res) {echo $i. ' Msg '.    "Yes\n"; } else {echo $i. ' Msg '.    "No\n"; }}? >consumer:? View Code PHP
 ' localhost ', ' port ' = 5672, ' login ' = ' guest ', ' password ' = ' gues ' T ', ' vhost ' = '/'); $cnn = new Amqpconnect ($params); Create the Queue$queue = new Amqpqueue ($cnn, ' queue1 '); $queueMessages = $queue->consume (100); foreach ($queueMessages as $item) {echo "$i. $item \ n";}? >

?

?

?

Reference:
Http://www.rabbitmq.com/install.html
http://blog.ftofficer.com/2010/03/translation-rabbitmq-python-rabbits-and-warrens/
http://code.google.com/p/php-rabbit/

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.