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

优化网站内链南阳做网站公司电话

优化网站内链,南阳做网站公司电话,ps怎么做网站,营销型企业网站推广的方法有哪些概述 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.yayakq.cn/news/393804/

相关文章:

  • 火车头采集器wordpress发布模块国内好的seo网站
  • 怎样在网站做咨询医生挣钱wordpress mu安装
  • 素材网站的素材可以商用吗人工智能搭建
  • 无需下载国外黄冈网站推广网站建设宽带
  • 应税服务网站开发开票如何推广运营网站
  • 浙江建设职业技术学院尔雅网站深圳的网站建设的公司
  • 天津网站制作软件科技成果转化网站建设
  • 大连旅顺博物馆福田网站建设公司乐云seo
  • 岐山县住房和城市建设局网站建设银行开通网银网站
  • 域名和空间都有了怎么做网站优化一个网站多少钱
  • 优化网站搜索排名模板网站是什么意思
  • php网站开发实施方案网络营销推广案例有哪些
  • 国外做鞋子的网站没有网站怎么做链接视频播放器
  • 深圳福田做网站怎么可以建网站
  • 珠海自适应网站设计旅游做哪个网站好
  • 网站受到攻击会怎么样网站建设与推广范文
  • 周口市规划建设局网站自用电脑做网站
  • 北京做网站制作的公司专门做二手手机的网站
  • 网站建设和开发沈阳建设工程城乡建设厅
  • 网站免费部署工业设计作品网站
  • 四川建设厅官方网站查询罗湖商城网站设计多少钱
  • 定制建站公司网站引导页动画
  • asp.net 跳转别的网站做网站想要中立
  • 成都市网站建设费用及企业北京关键词排名推广
  • flask api式网站开发网站为什么要seo?
  • 哪个网站做美食视频网站cn域名网站
  • 石家庄手机端seo关键词优化排名有哪些牛霸天的软件1
  • 网站开发公司介绍品牌推广公司简介
  • 网站建设推广哪里实惠专业app网站建设
  • 哪里可以做寄生虫网站中国建筑工程机械人才培训网官网