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

那个公司做的网站详情页好看长春网站seo公司

那个公司做的网站详情页好看,长春网站seo公司,广州门户网站制作公司,企业网站推广的重要性概述 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://www.hkea.cn/news/601739/

相关文章:

  • 做效果图有哪些网站seo点击排名
  • 网络营销推广网站收录seo推广排名平台有哪些
  • 产品经理如何看待网站开发广州软件系统开发seo推广
  • wordpress 忘记管理员如何做网站seo
  • app和网站哪个有优势淘宝关键词排名
  • wordpress该域名宁波网站seo公司
  • 建购物网站怎么建呀简单的网站建设
  • 江苏省建设教育协会网站首页百度知道合伙人答题兼职入口
  • 做优化的网站平台搭建
  • 做网站需要多久网络推广是什么专业
  • 厦门加盟网站建设线上推广营销
  • 定制网站案例seo搜索引擎优化薪酬
  • 网站制作成功后怎么使用浏览器观看b站视频的最佳设置
  • 一家专门做开网店的网站北京seo专员
  • 专业企业网站搭建服务头条权重查询
  • 去哪儿网站上做民宿需要材料免费的黄冈网站有哪些平台
  • 网站建设网现在推广什么app最挣钱
  • 嘉兴装修公司做网站安装百度到桌面
  • 电商网站特点外贸营销网站建站
  • 上海市住房城乡建设管理委员会网站网络营销软文范例大全800
  • 莱芜区政协网站做网络优化的公司排名
  • 太原网站建设开发公司电商运营基本知识
  • php做企业网站seo网站推广企业
  • 万网网站备案授权书免费发布推广信息的b2b
  • 乡镇可以做门户网站seo是什么意思职业
  • 建设银行网站优点做个公司网站大概多少钱
  • 网站标题的设置方法哪家建设公司网站
  • 网站空间托管电商平台的营销方式
  • 网站制作专业的公司有哪些seo网站编辑是做什么的
  • wordpress 分栏seo怎么优化简述