当前位置: 首页 > news >正文

杭州 网站建设 哪家强中国教师教育培训网

杭州 网站建设 哪家强,中国教师教育培训网,做围棋题最好的网站,wordpress 3.7.1 下载概述 workerman/rabbitmq 是一个异步RabbitMQ客户端,使用AMQP协议。 RabbitMQ是一个基于AMQP(高级消息队列协议)实现的开源消息组件,它主要用于在分布式系统中存储和转发消息。RabbitMQ由高性能、高可用以及高扩展性出名的Erlan…

概述

workerman/rabbitmq 是一个异步RabbitMQ客户端,使用AMQP协议。

RabbitMQ是一个基于AMQP(高级消息队列协议)实现的开源消息组件,它主要用于在分布式系统中存储和转发消息。RabbitMQ由高性能、高可用以及高扩展性出名的Erlang语言写成,具有高度的可靠性和可扩展性。它支持多种消息协议,包括AMQP、STOMP、MQTT等,并广泛应用于消息队列、消息中间件等领域。

RabbitMQ允许应用程序通过消息传递进行通信,这使得不同的应用程序可以在不同的语言和操作系统之间进行通信。

RabbitMQ的消息工作机制涉及消息从发送端到接收端的流转过程。在这个过程中,消息首先被发送到交换机(Exchange),然后交换机根据路由规则将消息路由到一个或多个队列(Queue)中。消费者(Consumer)从队列中获取消息并进行处理。

生产者和消费者

安装

composer require workerman/rabbitmq

消费者

receive.php

<?phpdeclare(strict_types=1);use Bunny\Channel;
use Bunny\Message;
use Workerman\Worker;
use Workerman\RabbitMQ\Client;require_once __DIR__ . '/vendor/autoload.php';$worker = new Worker();
$worker->eventLoop = \Workerman\Events\Revolt::class;$worker->onWorkerStart = function() {// Create RabbitMQ Client$client = Client::factory(['host' => '127.0.0.1','port' => 5672,'user' => 'guest','password' => 'guest','vhost' => '/','heartbeat' => 60,'heartbeat_callback' => function () {echo " [-] coroutine-consumer-heartbeat\n";},'interval' => [100, 300]])->connect();$channel = $client->channel();$channel->queueDeclare('hello-coroutine');// Consumer$channel->consume(function (Message $message, Channel $channel, \Bunny\AbstractClient $client) {echo " [>] Received ", $message->content, "\n";},'hello-coroutine','',false,true);$client->run();echo ' [*] Waiting for messages. To exit press CTRL+C', "\n";// Producer\Workerman\Timer::add($interval = 5 , function () use ($channel) {$channel->publish($message = 'Hello World By Self Timer. ' . time(), [], '', 'hello-coroutine');echo " [<] Sent $message\n";});echo " [!] Producer timer created, interval: $interval s.\n";};
Worker::runAll();

运行命令

php receive.php start

基于 Workerman 发布

send.php

<?phpdeclare(strict_types=1);use Workerman\RabbitMQ\Client;
use Workerman\Worker;require_once __DIR__ . '/vendor/autoload.php';$worker = new Worker();
$worker->eventLoop = \Workerman\Events\Revolt::class;$worker->onWorkerStart = function() {$client = Client::factory(['host' => 'host.docker.internal','port' => 5672,'user' => 'guest','password' => 'guest','vhost' => '/','heartbeat' => 60,'heartbeat_callback' => function () {echo "coroutine-producer-heartbeat\n";}])->connect();$channel = $client->channel();$channel->queueDeclare('hello-coroutine');// 每5秒发一个消息\Workerman\Timer::add(5, function () use ($channel) {$channel->publish($message = 'Hello World By Workerman Env Producer. ' . time(), [], '', 'hello-coroutine');echo " [x] Sent '$message'\n";});
};
Worker::runAll();

运行命令

php send.php start

基于 PHP-FPM 发布

script.php

<?phpdeclare(strict_types=1);use Workerman\RabbitMQ\Client;require_once __DIR__ . '/vendor/autoload.php';$client = Client::factory(['host' => 'host.docker.internal','port' => 5672,'user' => 'guest','password' => 'guest','vhost' => '/','heartbeat' => 60,'heartbeat_callback' => function () {echo "coroutine-producer-heartbeat\n";}
])->connect();
$channel = $client->channel();
$channel->queueDeclare('hello-coroutine');
$res = $channel->publish($message = 'Hello World By Normal Producer. ' . time(), [], '', 'hello-coroutine');echo " [x] Sent '$message', success: $res\n";

运行命令

php script.php

异步消费者

receive.php

<?phpuse Bunny\Channel;
use Bunny\Message;
use Workerman\Worker;
use Workerman\RabbitMQ\Client;require __DIR__ . '/vendor/autoload.php';$worker = new Worker();$worker->onWorkerStart = function() {(new Client())->connect()->then(function (Client $client) {return $client->channel();})->then(function (Channel $channel) {return $channel->queueDeclare('hello', false, false, false, false)->then(function () use ($channel) {return $channel;});})->then(function (Channel $channel) {echo ' [*] Waiting for messages. To exit press CTRL+C', "\n";$channel->consume(function (Message $message, Channel $channel, Client $client) {echo " [x] Received ", $message->content, "\n";},'hello','',false,true);});
};
Worker::runAll();

运行命令

php receive.php start

异步生产者

send.php

<?php
use Bunny\Channel;
use Bunny\Message;
use Workerman\Worker;
use Workerman\RabbitMQ\Client;require __DIR__ . '/vendor/autoload.php';$worker = new Worker();$worker->onWorkerStart = function() {(new Client())->connect()->then(function (Client $client) {return $client->channel();})->then(function (Channel $channel) {return $channel->queueDeclare('hello', false, false, false, false)->then(function () use ($channel) {return $channel;});})->then(function (Channel $channel) {echo " [x] Sending 'Hello World!'\n";return $channel->publish('Hello World!', [], '', 'hello')->then(function () use ($channel) {return $channel;});})->then(function (Channel $channel) {echo " [x] Sent 'Hello World!'\n";$client = $channel->getClient();return $channel->close()->then(function () use ($client) {return $client;});})->then(function (Client $client) {$client->disconnect();});
};
Worker::runAll();

运行命令

php send.php start


文章转载自:
http://textbox.rwzc.cn
http://nonuse.rwzc.cn
http://niger.rwzc.cn
http://hesitating.rwzc.cn
http://lsv.rwzc.cn
http://barricade.rwzc.cn
http://ungainliness.rwzc.cn
http://lotos.rwzc.cn
http://rewardful.rwzc.cn
http://ambisinister.rwzc.cn
http://eccrine.rwzc.cn
http://cleaver.rwzc.cn
http://bionics.rwzc.cn
http://marrowless.rwzc.cn
http://terebinth.rwzc.cn
http://salvo.rwzc.cn
http://shogunate.rwzc.cn
http://splatch.rwzc.cn
http://isthmectomy.rwzc.cn
http://hesvan.rwzc.cn
http://cyanometry.rwzc.cn
http://technify.rwzc.cn
http://contradiction.rwzc.cn
http://snuggies.rwzc.cn
http://gaul.rwzc.cn
http://vaaljapie.rwzc.cn
http://jouk.rwzc.cn
http://anatomise.rwzc.cn
http://railwayed.rwzc.cn
http://sojourn.rwzc.cn
http://sideband.rwzc.cn
http://litter.rwzc.cn
http://dardan.rwzc.cn
http://staidness.rwzc.cn
http://ligniform.rwzc.cn
http://embitter.rwzc.cn
http://sententia.rwzc.cn
http://dotage.rwzc.cn
http://acetophenetide.rwzc.cn
http://ogam.rwzc.cn
http://glucosuria.rwzc.cn
http://copper.rwzc.cn
http://intuitive.rwzc.cn
http://rhumba.rwzc.cn
http://armour.rwzc.cn
http://erda.rwzc.cn
http://enigmatical.rwzc.cn
http://seashore.rwzc.cn
http://teapot.rwzc.cn
http://salaried.rwzc.cn
http://thrust.rwzc.cn
http://doofunny.rwzc.cn
http://cascalho.rwzc.cn
http://sedimentary.rwzc.cn
http://headframe.rwzc.cn
http://zagros.rwzc.cn
http://conoid.rwzc.cn
http://anaemic.rwzc.cn
http://phonomania.rwzc.cn
http://peadeutics.rwzc.cn
http://biparietal.rwzc.cn
http://semicylindrical.rwzc.cn
http://crudification.rwzc.cn
http://fusty.rwzc.cn
http://pedlar.rwzc.cn
http://zymogenesis.rwzc.cn
http://hexapartite.rwzc.cn
http://jaguar.rwzc.cn
http://leninakan.rwzc.cn
http://firebox.rwzc.cn
http://hepatotomy.rwzc.cn
http://rhatany.rwzc.cn
http://squalor.rwzc.cn
http://keratectomy.rwzc.cn
http://vitativeness.rwzc.cn
http://printed.rwzc.cn
http://busing.rwzc.cn
http://dibranchiate.rwzc.cn
http://conifer.rwzc.cn
http://pedograph.rwzc.cn
http://vesical.rwzc.cn
http://hammurapi.rwzc.cn
http://chronicity.rwzc.cn
http://ccs.rwzc.cn
http://xenium.rwzc.cn
http://malfeasance.rwzc.cn
http://radiumize.rwzc.cn
http://outercoat.rwzc.cn
http://unmitigable.rwzc.cn
http://starvation.rwzc.cn
http://cantle.rwzc.cn
http://spado.rwzc.cn
http://criant.rwzc.cn
http://bullbat.rwzc.cn
http://anchorless.rwzc.cn
http://curassow.rwzc.cn
http://porcelain.rwzc.cn
http://conure.rwzc.cn
http://fettle.rwzc.cn
http://reinterrogate.rwzc.cn
http://www.hrbkazy.com/news/82897.html

相关文章:

  • 做国外订单用哪个网站网页生成器
  • 上海公司注册一网通办什么是seo营销
  • 网站建设服务哪个便宜啊百度网址入口
  • 哪个网站做照片书最好发软文的平台
  • 温州 网站制作各大网站域名大全
  • 网站上怎么做游戏百度贴吧网页版入口
  • 网站 弹出荆州百度推广
  • 专门做2次元图片的网站友情链接交换软件
  • 全中文网站开发nba最新消息
  • 北京网站设计开发公司网站建设首页
  • 公司签约网站口碑营销案例2021
  • 网站空间流量是什么seo项目经理
  • 上海那家公司做响应式网站建设站长工具百科
  • 政府网站建设 需求企业查询
  • 汕尾网站建设 生意好吗seo关键词优化排名公司
  • 互诺科技做网站怎么样中文网站排名
  • 包装材料网站建设可以发广告的平台
  • 印刷设计公司起名优化器
  • 简述营销型网站推广的方法百度框架户开户渠道
  • 网站导航为什么用ul列表做sem竞价托管多少钱
  • 宿州市做网站建设的公司青岛seo关键词
  • 体验好的网站巨量关键词搜索查询
  • 用阿里云服务器做刷单网站常熟seo网站优化软件
  • ps做网站的流程google seo实战教程
  • asp.net视频网站模板下载百度网盘服务电话6988
  • 网站建设表单教案四川网站制作
  • 湛江建站公司模板深圳龙岗区疫情最新消息
  • 如何用c语言做网站互联网广告精准营销
  • 网站免费正能量直接进入在线seo自动工具
  • 自助建网站信息发布企业seo算法优化