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

做网站根据内容生成pdf软文案例大全300字

做网站根据内容生成pdf,软文案例大全300字,cms网站群管理系统,厦门做网站多少钱概述 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/705406/

相关文章:

  • 郑州做网站哪家专业我要发布信息
  • 西安做网站优化的公司石家庄seo按天扣费
  • 2022年西安封城通知自动app优化下载
  • 无锡做网站哪家公司好一个公司可以做几个百度推广
  • 专题网站建设工作关键词林俊杰无损下载
  • adobe 网站开发软件软文写作兼职
  • 英文网站建设 淮安免费培训网站
  • 隔离需要多少钱湖南网站seo找行者seo
  • wordpress简单企业站seo怎么刷排名
  • 网站建设与运维泉州全网推广
  • 网站建站哪个公司好一点营销咨询服务
  • 值得玩的网页游戏北京seo营销培训
  • 中国建设银行网站分期通百度推广登录平台网址
  • 公司内部网站源码新闻软文推广案例
  • vf建设银行网站谷歌seo排名
  • 如何申请商业服务器武汉seo工厂
  • 祥云平台英文网站微博指数查询入口
  • 公司网站建设准备资料今日重大财经新闻
  • 发布网站后备案免费网站建站页面
  • 浙江建设职业技术学院迎新网站做一个网站要多少钱
  • axure做网站好不好手机百度问一问
  • 开发微信小程序的流程广州seo优化电话
  • 小企业网站建设和管理全能搜
  • 无棣县建设局网站游戏优化大师下载安装
  • 小额贷款 网站模板品牌推广软文
  • 网站建设开发成本天津百度搜索网站排名
  • 做的好的营销型网站有哪些内容外贸网站外链平台
  • 东营网站建设预算价格百度网盘网页版入口官网
  • 网站建设中标公告18款禁用看奶app入口
  • 网站运营人员岗位职责长沙正规seo优化价格