{"id":252247,"date":"2015-03-02T21:22:02","date_gmt":"2015-03-02T17:22:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=252247"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=252247","title":{"rendered":"\u0412\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 PHP \u0438 Erlang \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c RabbitMQ"},"content":{"rendered":"<p> \t\t\t\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<br \/>\n  \u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u0443\u0435\u0448\u044c \u043d\u0430 php, \u0442\u0435\u043c \u0447\u0430\u0449\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0438, \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0443\u0436\u0435\u043d \u0434\u0435\u043c\u043e\u043d \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u0414\u0430, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 phpDaemon, cron \u0438\u043b\u0438 \u043a\u043e\u0441\u0442\u044b\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c n-\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. \u041d\u043e \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0441 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043d\u0430 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435, \u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0440\u0430\u0441\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c\u0441\u044f. <\/p>\n<p>  \u0412 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u043a\u0443 php+RabbitMQ+erlang. \u041d\u0430 php \u0443\u0436\u0435 \u0431\u044b\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0431\u044b\u043b\u043e \u043b\u0438\u0448\u044c \u0440\u0430\u0437\u043d\u0435\u0441\u0442\u0438 \u0432\u044b\u0437\u043e\u0432\u044b \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 \u043c\u0430\u0448\u0438\u043d\u043a\u0438. \u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u0437\u0432\u0443\u0447\u0430\u043b\u0430 \u0442\u0430\u043a: \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0430\u0440\u0441\u0435\u0440 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0441 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438, \u0441\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<br \/>\n   \u2014 Rest-\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430 php, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0438\u0437\u0431\u0440\u0430\u043d\u043d\u043e\u0435. \u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0438 \u0431\u0443\u0434\u0443\u0442 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438, \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c, \u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u2014 \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0430.<br \/>\n   \u2014 \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 erlange, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0435\u043c \u0438 \u0442.\u0434. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0441 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0432\u0443\u043c\u044f \u043f\u0443\u0442\u044f\u043c\u0438 \u2014 \u044d\u0442\u043e \u043f\u0430\u0440\u0441\u0438\u043d\u0433 html \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0438\u043b\u0438 \u0433\u0434\u0435 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u2014 \u0437\u0430\u043f\u0440\u043e\u0441\u044b api. \u0414\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f rest-\u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u043d\u0430 php.<br \/>\n   \u2014 \u041c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432. \u0421\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0434\u043e \u043f\u0430\u0440\u0441\u0438\u0442\u044c, \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u0445, \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c\u044b\u0445 RabbitMQ.<\/p>\n<p>  \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u043e\u043c\u0435\u0440 1 \u2014 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 php \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 RabbitMQ<br \/>\n  \u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b:<\/p>\n<p>  apt-get install gcc apt-get install php5-dev<br \/>\n  \u0414\u0430\u043b\u0435\u0435 \u0441\u0430\u043c\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430, \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u0430\u0445 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430:<\/p>\n<p>  #download and install the rabbitmq c amqp lib wget https:\/\/github.com\/alanxz\/rabbitmq-c\/releases\/download\/v0.5.1\/rabbitmq-c-0.5.1.tar.gz tar -zxvf rabbitmq-c-0.5.1.tar.gz cd rabbitmq-c-0.5.1\/ .\/configure make sudo make install cd .. #download and compile the amqp wget http:\/\/pecl.php.net\/get\/amqp-1.4.0.tgz tar -zxvf amqp-1.4.0.tgz cd amqp-1.4.0\/ phpize &#038;&#038; .\/configure &#8212;with-amqp &#038;&#038; make &#038;&#038; sudo make install #Add amqp extension to php mods-availabile directory echo &quot;extension=amqp.so&quot; &gt; \/etc\/php5\/mods-available\/amqp.ini #Enabled it in cli cd \/etc\/php5\/cli\/conf.d\/ ln -s ..\/..\/mods-available\/amqp.ini 20-amqp.ini php -m | grep amqp #Enabled it in cli cd \/etc\/php5\/apache2\/conf.d\/ ln -s ..\/..\/mods-available\/amqp.ini 20-amqp.ini #restart Apache and than check phpinfo on web service apache2 restart<br \/>\n  \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043f\u043e\u0432\u0435\u0437\u043b\u043e, \u0442\u043e \u0432\u0441\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u043e\u0441\u044c \u0432\u0435\u0440\u043d\u043e.<\/p>\n<p>  \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u043e\u043c\u0435\u0440 2 \u2014 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c RabbitMQ \u0438 web-\u043f\u0430\u043d\u0435\u043b\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043c<br \/>\n  sudo apt-get install rabbitmq-server  rabbitmq-plugins enable rabbitmq_management  rabbitmqctl stop  rabbitmq-server -detached<br \/>\n  \u0414\u0430\u043b\u0435\u0435 \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u043c\u0438, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043b\u043e\u0433\u0438\u043d(guest) \u0438 \u043f\u0430\u0440\u043e\u043b\u044c(guest)<br \/>\n   ip.addres:15672\/<\/p>\n<p>  \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u043e\u043c\u0435\u0440 3 \u2014 \u0447\u0435\u0440\u0435\u0437 php \u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 RabbitMQ<br \/>\n  \/\/\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u043e\u0447\u043a\u0438 \u043e\u0431\u043c\u0435\u043d\u0430 $rabbit = new AMQPConnection(array(&#8216;host&#8217; =&gt; &#8216;127.0.0.1&#8217;, &#8216;port&#8217; =&gt; &#8216;5672&#8217;, &#8216;login&#8217; =&gt; &#8216;guest&#8217;, &#8216;password&#8217; =&gt; &#8216;guest&#8217;)); $rabbit-&gt;connect(); $testChannel = new AMQPChannel($rabbit); $exchange = new AMQPExchange($testChannel); $exchange-&gt;setName(&#8216;logoooooo&#8217;); $exchange-&gt;setType(AMQP_EX_TYPE_DIRECT); $exchange-&gt;declare();  \/\/\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u0438 $testChannel = new AMQPChannel($rabbit); $queue = new AMQPQueue($testChannel);  $queue-&gt;setName(&quot;yyyyyyy2&quot;); $queue-&gt;declare();   \/\/\u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043a \u0442\u043e\u0447\u043a\u0438 \u043e\u0431\u043c\u0435\u043d\u0430 $testChannel = new AMQPChannel($rabbit); $queue = new AMQPQueue($testChannel);  $queue-&gt;setName(&quot;yyyyyyy2&quot;); $queue-&gt;bind(&#8216;logoooooo&#8217;);  $queue-&gt;declare();  \/\/\u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e\u0447\u043a\u0443 $testChannel = new AMQPChannel($rabbit); $exchange = new AMQPExchange($testChannel); $exchange-&gt;setName(&#8216;logoooooo&#8217;); $exchange-&gt;publish(&#8216;pooooooooooooooooooooooooooooooo&#8217;); <\/p>\n<p>  \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u043e\u043c\u0435\u0440 4 \u2014 \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 erlange \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f rebar<br \/>\n  \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c rebar<br \/>\n  apt-get install rebar mkdir 1 rebar create template=simpleapp   srvid=my_server46 rebar create template=simplesrv   srvid=my_server46<br \/>\n  \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u043e\u043c\u0435\u0440 5 \u2014 \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 erlange<br \/>\n  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c CMake:<\/p>\n<p>  apt-get install make<br \/>\n  \u0412 Makefile \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  all: \trebar compile  run: \tERL_LIBS=deps erl +K true -name myapp_app@127.0.0.1 -boot start_sasl -pa ebin -s myapp_app -sasl errlog_type error<br \/>\n  \u0421\u0442\u0440\u043e\u0447\u043a\u0430 -pa ebin -s myapp_app \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c ebin\/myapp_app.erl \u0438 \u0432 \u043d\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e myapp_app:start().<br \/>\n  ERL_LIBS=deps \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0432\u0441\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u0432 \u043f\u0430\u043f\u043a\u0435 deps.<\/p>\n<p>  \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u043e\u043c\u0435\u0440 6 \u2014 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0438 RabbitMQ \u0438 Erlang<br \/>\n  \u0412 rebar.config \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  {deps, [ \t{rabbit_common, &quot;.*&quot;, {git, &quot;git:\/\/github.com\/jbrisbin\/rabbit_common.git&quot;, {tag, &quot;rabbitmq-3.0.2&quot;}}} ]}.  {erl_opts, [   debug_info,    compressed,    report,    warn_export_all,    warn_export_vars,    warn_shadow_vars,    warn_unused_function,    warn_deprecated_function,    warn_obsolete_guard,    warn_unused_import  %  warnings_as_errors ]}.<br \/>\n  \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c rebar get-deps, \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. \u0414\u0430\u043b\u0435\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u043c\u0438\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435 RabbitMQ. \u041d\u043e \u043f\u0435\u0440\u0435\u0434 \u044d\u0442\u0438 \u0434\u043e\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b:<\/p>\n<p>  apt-get install xsltproc apt-get install zip<br \/>\n  \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043e\u0447\u043a\u0443 deps, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u043b rebar \u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f git, \u0432\u0441\u0435 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c, \u0430 \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c:<\/p>\n<p>  cd deps git clone https:\/\/github.com\/rabbitmq\/rabbitmq-erlang-client.git git clone https:\/\/github.com\/rabbitmq\/rabbitmq-server.git git clone https:\/\/github.com\/rabbitmq\/rabbitmq-codegen.git cd rabbitmq-erlang-client make<br \/>\n  \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u043e\u043c\u0435\u0440 7 \u2014 \u0438\u0437 Erlang\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439 RabbitMQ<br \/>\n  \u0424\u0430\u0439\u043b myapp_app.erl \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0447\u0443\u0442\u044c \u0447\u0443\u0442\u044c \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438\u0437 makefile, \u0447\u0442\u043e \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438:<\/p>\n<p>  -module(myapp_app).  -behaviour(application).  -export([start\/0,start\/2, stop\/1]).  start() -&gt;   myapp_sup:start_link().  start(_StartType, _StartArgs) -&gt;     myapp_sup:start_link().  stop(_State) -&gt;     ok.<br \/>\n  \u0424\u0430\u0439\u043b myapp_sup.erl, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438, \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u044b\u0437\u043e\u0432 \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0438\u0437 init:<\/p>\n<p>  -module(myapp_sup).  -behaviour(supervisor).  -export([start_link\/0]).  -export([init\/1]).  -define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).  start_link() -&gt;     supervisor:start_link({local, ?MODULE}, ?MODULE, []).  init([]) -&gt;     {ok, { {one_for_one, 5, 10}, [{my_server46_0, {my_server46, start_link, []},permanent, brutal_kill, worker, [my_server46]}]} }.<br \/>\n  \u041c\u043e\u0434\u0443\u043b\u044c, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0441\u0432\u044f\u0437\u044c \u0441 RabbitMQ:<\/p>\n<p>  -module(my_server46). -behaviour(gen_server).  -include(&quot;deps\/rabbitmq-erlang-client\/include\/amqp_client.hrl&quot;).  -define(SERVER, ?MODULE).  -export([start_link\/0,main\/0,loop\/1]).  -export([init\/1, handle_call\/3, handle_cast\/2, handle_info\/2,          terminate\/2, code_change\/3]).  start_link() -&gt;     gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).  init(Args) -&gt;   main(),   {ok, Args}.  main() -&gt;   {ok, Connection} =     amqp_connection:start(#amqp_params_network{host = &quot;localhost&quot;}),   {ok, Channel} = amqp_connection:open_channel(Connection),    io:format(&quot; [*] Waiting for messages. To exit press CTRL+C~n&quot;),    amqp_channel:call(Channel, #&#8217;basic.qos'{prefetch_count = 1}),   amqp_channel:subscribe(Channel, #&#8217;basic.consume'{queue = &lt;&lt;&quot;yyyyyyy2&quot;&gt;&gt;},self()),   receive     #&#8217;basic.consume_ok'{} -&gt; io:fwrite(&quot; _rec_main_ok_ &quot;),ok   end,   loop(Channel),   io:fwrite(&quot;begin~n&quot;, []).  loop(Channel)-&gt;   receive     {#&#8217;basic.deliver'{delivery_tag = Tag}, #amqp_msg{payload = Body}} -&gt;       Dots = length([C || C &lt;- binary_to_list(Body), C == $.]),       io:format(&quot; [x] Received Body ~p~n&quot;, [Body]),       receive       after         Dots*1000 -&gt; io:format(&quot; _loop_rec_after_ ~p&quot;,[0]), ok       end,       timer:sleep(3500),       amqp_channel:cast(Channel, #&#8217;basic.ack'{delivery_tag = Tag}),       loop(Channel),       io:format(&quot; [x] Done 3~n&quot;)   end.    handle_call(_Request, _From, State) -&gt;     {reply, ok, State}.  handle_cast(_Msg, State) -&gt;     {noreply, State}.  handle_info(_Info, State) -&gt;     {noreply, State}.  terminate(_Reason, _State) -&gt;     ok.  code_change(_OldVsn, State, _Extra) -&gt;     {ok, State}.<br \/>\n  \u0422\u0443\u0442 \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043c\u044b \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u00abyyyyyyy2\u00bb:<\/p>\n<p>  amqp_channel:subscribe(Channel, #&#8217;basic.consume'{queue = &lt;&lt;&quot;yyyyyyy2&quot;&gt;&gt;},self())<br \/>\n  \u0417\u0430\u0442\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u043c RabbitMQ, \u0447\u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043e:<\/p>\n<p>  amqp_channel:cast(Channel, #&#8217;basic.ack'{delivery_tag = Tag})  \t\t\t     http:\/\/habrahabr.ru\/post\/251927\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p> \t\t\t\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<br \/>\n  \u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u0443\u0435\u0448\u044c \u043d\u0430 php, \u0442\u0435\u043c \u0447\u0430\u0449\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0438, \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0443\u0436\u0435\u043d \u0434\u0435\u043c\u043e\u043d \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u0414\u0430, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 phpDaemon, cron \u0438\u043b\u0438 \u043a\u043e\u0441\u0442\u044b\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c n-\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. \u041d\u043e \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0441 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043d\u0430 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435, \u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0440\u0430\u0441\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c\u0441\u044f. <\/p>\n<p>  \u0412 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u043a\u0443 php+RabbitMQ+erlang. \u041d\u0430 php \u0443\u0436\u0435 \u0431\u044b\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0431\u044b\u043b\u043e \u043b\u0438\u0448\u044c \u0440\u0430\u0437\u043d\u0435\u0441\u0442\u0438 \u0432\u044b\u0437\u043e\u0432\u044b \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 \u043c\u0430\u0448\u0438\u043d\u043a\u0438. \u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u0437\u0432\u0443\u0447\u0430\u043b\u0430 \u0442\u0430\u043a: \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0430\u0440\u0441\u0435\u0440 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0441 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438, \u0441\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<br \/>\n   \u2014 Rest-\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430 php, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0438\u0437\u0431\u0440\u0430\u043d\u043d\u043e\u0435. \u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0438 \u0431\u0443\u0434\u0443\u0442 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438, \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c, \u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u2014 \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0430.<br \/>\n   \u2014 \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 erlange, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0435\u043c \u0438 \u0442.\u0434. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0441 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0432\u0443\u043c\u044f \u043f\u0443\u0442\u044f\u043c\u0438 \u2014 \u044d\u0442\u043e \u043f\u0430\u0440\u0441\u0438\u043d\u0433 html \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0438\u043b\u0438 \u0433\u0434\u0435 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u2014 \u0437\u0430\u043f\u0440\u043e\u0441\u044b api. \u0414\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f rest-\u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u043d\u0430 php.<br \/>\n   \u2014 \u041c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432. \u0421\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0434\u043e \u043f\u0430\u0440\u0441\u0438\u0442\u044c, \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u0445, \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c\u044b\u0445 RabbitMQ.<\/p>\n<p>  \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u043e\u043c\u0435\u0440 1 \u2014 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 php \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 RabbitMQ<br \/>\n  \u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b:<\/p>\n<p>  apt-get install gcc apt-get install php5-dev<br \/>\n  \u0414\u0430\u043b\u0435\u0435 \u0441\u0430\u043c\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430, \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u0430\u0445 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430:<\/p>\n<p>  #download and install the rabbitmq c amqp lib wget https:\/\/github.com\/alanxz\/rabbitmq-c\/releases\/download\/v0.5.1\/rabbitmq-c-0.5.1.tar.gz tar -zxvf rabbitmq-c-0.5.1.tar.gz cd rabbitmq-c-0.5.1\/ .\/configure make sudo make install cd .. #download and compile the amqp wget http:\/\/pecl.php.net\/get\/amqp-1.4.0.tgz tar -zxvf amqp-1.4.0.tgz cd amqp-1.4.0\/ phpize &#038;&#038; .\/configure &#8212;with-amqp &#038;&#038; make &#038;&#038; sudo make install #Add amqp extension to php mods-availabile directory echo &quot;extension=amqp.so&quot; &gt; \/etc\/php5\/mods-available\/amqp.ini #Enabled it in cli cd \/etc\/php5\/cli\/conf.d\/ ln -s ..\/..\/mods-available\/amqp.ini 20-amqp.ini php -m | grep amqp #Enabled it in cli cd \/etc\/php5\/apache2\/conf.d\/ ln -s ..\/..\/mods-available\/amqp.ini 20-amqp.ini #restart Apache and than check phpinfo on web service apache2 restart<br \/>\n  \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043f\u043e\u0432\u0435\u0437\u043b\u043e, \u0442\u043e \u0432\u0441\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u043e\u0441\u044c \u0432\u0435\u0440\u043d\u043e.<\/p>\n<p>  \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u043e\u043c\u0435\u0440 2 \u2014 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c RabbitMQ \u0438 web-\u043f\u0430\u043d\u0435\u043b\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043c<br \/>\n  sudo apt-get install rabbitmq-server  rabbitmq-plugins enable rabbitmq_management  rabbitmqctl stop  rabbitmq-server -detached<br \/>\n  \u0414\u0430\u043b\u0435\u0435 \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u043c\u0438, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043b\u043e\u0433\u0438\u043d(guest) \u0438 \u043f\u0430\u0440\u043e\u043b\u044c(guest)<br \/>\n   ip.addres:15672\/<\/p>\n<p>  \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u043e\u043c\u0435\u0440 3 \u2014 \u0447\u0435\u0440\u0435\u0437 php \u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 RabbitMQ<br \/>\n  \/\/\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u043e\u0447\u043a\u0438 \u043e\u0431\u043c\u0435\u043d\u0430 $rabbit = new AMQPConnection(array(&#8216;host&#8217; =&gt; &#8216;127.0.0.1&#8217;, &#8216;port&#8217; =&gt; &#8216;5672&#8217;, &#8216;login&#8217; =&gt; &#8216;guest&#8217;, &#8216;password&#8217; =&gt; &#8216;guest&#8217;)); $rabbit-&gt;connect(); $testChannel = new AMQPChannel($rabbit); $exchange = new AMQPExchange($testChannel); $exchange-&gt;setName(&#8216;logoooooo&#8217;); $exchange-&gt;setType(AMQP_EX_TYPE_DIRECT); $exchange-&gt;declare();  \/\/\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u0438 $testChannel = new AMQPChannel($rabbit); $queue = new AMQPQueue($testChannel);  $queue-&gt;setName(&quot;yyyyyyy2&quot;); $queue-&gt;declare();   \/\/\u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043a \u0442\u043e\u0447\u043a\u0438 \u043e\u0431\u043c\u0435\u043d\u0430 $testChannel = new AMQPChannel($rabbit); $queue = new AMQPQueue($testChannel);  $queue-&gt;setName(&quot;yyyyyyy2&quot;); $queue-&gt;bind(&#8216;logoooooo&#8217;);  $queue-&gt;declare();  \/\/\u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e\u0447\u043a\u0443 $testChannel = new AMQPChannel($rabbit); $exchange = new AMQPExchange($testChannel); $exchange-&gt;setName(&#8216;logoooooo&#8217;); $exchange-&gt;publish(&#8216;pooooooooooooooooooooooooooooooo&#8217;); <\/p>\n<p>  \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u043e\u043c\u0435\u0440 4 \u2014 \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 erlange \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f rebar<br \/>\n  \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c rebar<br \/>\n  apt-get install rebar mkdir 1 rebar create template=simpleapp   srvid=my_server46 rebar create template=simplesrv   srvid=my_server46<br \/>\n  \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u043e\u043c\u0435\u0440 5 \u2014 \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 erlange<br \/>\n  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c CMake:<\/p>\n<p>  apt-get install make<br \/>\n  \u0412 Makefile \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  all: \trebar compile  run: \tERL_LIBS=deps erl +K true -name myapp_app@127.0.0.1 -boot start_sasl -pa ebin -s myapp_app -sasl errlog_type error<br \/>\n  \u0421\u0442\u0440\u043e\u0447\u043a\u0430 -pa ebin -s myapp_app \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c ebin\/myapp_app.erl \u0438 \u0432 \u043d\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e myapp_app:start().<br \/>\n  ERL_LIBS=deps \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0432\u0441\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u0432 \u043f\u0430\u043f\u043a\u0435 deps.<\/p>\n<p>  \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u043e\u043c\u0435\u0440 6 \u2014 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0438 RabbitMQ \u0438 Erlang<br \/>\n  \u0412 rebar.config \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  {deps, [ \t{rabbit_common, &quot;.*&quot;, {git, &quot;git:\/\/github.com\/jbrisbin\/rabbit_common.git&quot;, {tag, &quot;rabbitmq-3.0.2&quot;}}} ]}.  {erl_opts, [   debug_info,    compressed,    report,    warn_export_all,    warn_export_vars,    warn_shadow_vars,    warn_unused_function,    warn_deprecated_function,    warn_obsolete_guard,    warn_unused_import  %  warnings_as_errors ]}.<br \/>\n  \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c rebar get-deps, \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. \u0414\u0430\u043b\u0435\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u043c\u0438\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435 RabbitMQ. \u041d\u043e \u043f\u0435\u0440\u0435\u0434 \u044d\u0442\u0438 \u0434\u043e\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b:<\/p>\n<p>  apt-get install xsltproc apt-get install zip<br \/>\n  \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043e\u0447\u043a\u0443 deps, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u043b rebar \u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f git, \u0432\u0441\u0435 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c, \u0430 \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c:<\/p>\n<p>  cd deps git clone https:\/\/github.com\/rabbitmq\/rabbitmq-erlang-client.git git clone https:\/\/github.com\/rabbitmq\/rabbitmq-server.git git clone https:\/\/github.com\/rabbitmq\/rabbitmq-codegen.git cd rabbitmq-erlang-client make<br \/>\n  \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u043e\u043c\u0435\u0440 7 \u2014 \u0438\u0437 Erlang\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439 RabbitMQ<br \/>\n  \u0424\u0430\u0439\u043b myapp_app.erl \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0447\u0443\u0442\u044c \u0447\u0443\u0442\u044c \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438\u0437 makefile, \u0447\u0442\u043e \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438:<\/p>\n<p>  -module(myapp_app).  -behaviour(application).  -export([start\/0,start\/2, stop\/1]).  start() -&gt;   myapp_sup:start_link().  start(_StartType, _StartArgs) -&gt;     myapp_sup:start_link().  stop(_State) -&gt;     ok.<br \/>\n  \u0424\u0430\u0439\u043b myapp_sup.erl, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438, \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u044b\u0437\u043e\u0432 \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0438\u0437 init:<\/p>\n<p>  -module(myapp_sup).  -behaviour(supervisor).  -export([start_link\/0]).  -export([init\/1]).  -define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).  start_link() -&gt;     supervisor:start_link({local, ?MODULE}, ?MODULE, []).  init([]) -&gt;     {ok, { {one_for_one, 5, 10}, [{my_server46_0, {my_server46, start_link, []},permanent, brutal_kill, worker, [my_server46]}]} }.<br \/>\n  \u041c\u043e\u0434\u0443\u043b\u044c, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0441\u0432\u044f\u0437\u044c \u0441 RabbitMQ:<\/p>\n<p>  -module(my_server46). -behaviour(gen_server).  -include(&quot;deps\/rabbitmq-erlang-client\/include\/amqp_client.hrl&quot;).  -define(SERVER, ?MODULE).  -export([start_link\/0,main\/0,loop\/1]).  -export([init\/1, handle_call\/3, handle_cast\/2, handle_info\/2,          terminate\/2, code_change\/3]).  start_link() -&gt;     gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).  init(Args) -&gt;   main(),   {ok, Args}.  main() -&gt;   {ok, Connection} =     amqp_connection:start(#amqp_params_network{host = &quot;localhost&quot;}),   {ok, Channel} = amqp_connection:open_channel(Connection),    io:format(&quot; [*] Waiting for messages. To exit press CTRL+C~n&quot;),    amqp_channel:call(Channel, #&#8217;basic.qos'{prefetch_count = 1}),   amqp_channel:subscribe(Channel, #&#8217;basic.consume'{queue = &lt;&lt;&quot;yyyyyyy2&quot;&gt;&gt;},self()),   receive     #&#8217;basic.consume_ok'{} -&gt; io:fwrite(&quot; _rec_main_ok_ &quot;),ok   end,   loop(Channel),   io:fwrite(&quot;begin~n&quot;, []).  loop(Channel)-&gt;   receive     {#&#8217;basic.deliver'{delivery_tag = Tag}, #amqp_msg{payload = Body}} -&gt;       Dots = length([C || C &lt;- binary_to_list(Body), C == $.]),       io:format(&quot; [x] Received Body ~p~n&quot;, [Body]),       receive       after         Dots*1000 -&gt; io:format(&quot; _loop_rec_after_ ~p&quot;,[0]), ok       end,       timer:sleep(3500),       amqp_channel:cast(Channel, #&#8217;basic.ack'{delivery_tag = Tag}),       loop(Channel),       io:format(&quot; [x] Done 3~n&quot;)   end.    handle_call(_Request, _From, State) -&gt;     {reply, ok, State}.  handle_cast(_Msg, State) -&gt;     {noreply, State}.  handle_info(_Info, State) -&gt;     {noreply, State}.  terminate(_Reason, _State) -&gt;     ok.  code_change(_OldVsn, State, _Extra) -&gt;     {ok, State}.<br \/>\n  \u0422\u0443\u0442 \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043c\u044b \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u00abyyyyyyy2\u00bb:<\/p>\n<p>  amqp_channel:subscribe(Channel, #&#8217;basic.consume'{queue = &lt;&lt;&quot;yyyyyyy2&quot;&gt;&gt;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-252247","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/252247","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=252247"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/252247\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=252247"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=252247"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=252247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}