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

wordpress本地环境迁移成都网站改版优化

wordpress本地环境迁移,成都网站改版优化,企业网站的设计要点,如何进行网站icp备案提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 前言管理的字段 前言 搭建一个网络服务器,在内部提供各个业务接口即可。 在业务处理函数中,每次请求过来找到对应的信道,通过信…

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

文章目录

  • 前言
  • 管理的字段


前言

搭建一个网络服务器,在内部提供各个业务接口即可。
在业务处理函数中,每次请求过来找到对应的信道,通过信道句柄调用前边封装好的处理接口进行处理,最后返回响应即可。


管理的字段

服务器需要管理的字段,其中需要搭建一个tcp服务器。然后就是我们业务所需的句柄,一个是虚拟机管理句柄,消费者管理句柄,连接管理句柄和线程池句柄。

 class Server
{
private:using MessagePtr = std::shared_ptr<google::protobuf::Message>;muduo::net::TcpServer _server;muduo::net::EventLoop _baseloop;ProtobufCodecPtr _codec;        // 协议处理器 对收到的请求进行protobuf协议处理ProtobufDispatcher _dispatcher; // 请求分发器VirtualHost::ptr _host;ConsumerManager::ptr _consumer_manager;ConnectionManager::ptr _connection_manager;ThreadPool::ptr _pool;
}

我们需要为服务器注册业务请求处理函数。muduo库是支持protobuf协议的处理的。

// 注册请求处理函数
_dispatcher.registerMessageCallback<openChannelRequest>(std::bind(&Server::OnOpenChannel,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3));
_dispatcher.registerMessageCallback<closeChannelRequest>(std::bind(&Server::OnClodeChannle,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3));
_dispatcher.registerMessageCallback<declareExchangeRequest>(std::bind(&Server::OnDeclareExchange,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3));
_dispatcher.registerMessageCallback<deleteExchangeRequest>(std::bind(&Server::OnDeleteExchange,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3));
_dispatcher.registerMessageCallback<declareQueueRequest>(std::bind(&Server::OnDeclareQueue,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3));
_dispatcher.registerMessageCallback<deleteQueueRequest>(std::bind(&Server::OnDeleteQueue,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3));
_dispatcher.registerMessageCallback<queueBindRequest>(std::bind(&Server::onQueueBind,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3));
_dispatcher.registerMessageCallback<queueUnBindRequest>(std::bind(&Server::onQueueUnBind,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3));
_dispatcher.registerMessageCallback<basicPublishRequest>(std::bind(&Server::onBasicPublish,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3));
_dispatcher.registerMessageCallback<basicAckRequest>(std::bind(&Server::onBasicAck,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3));
_dispatcher.registerMessageCallback<basicConsumeRequest>(std::bind(&Server::onBasicConsume,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3));
_dispatcher.registerMessageCallback<basicCancelRequest>(std::bind(&Server::onBasicCancel,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3));}

当新连接建立时,我们需调用连接句柄创建一个新连接。
而连接断开时,需要删除连接对象。

void onConnection(const muduo::net::TcpConnectionPtr &conn){if (conn->connected() == true){LOG_INFO << "新连接建立了";_connection_manager->newConnection(_host,_consumer_manager,_codec,conn,_pool);}else{LOG_INFO << "连接断开了";_connection_manager->delConnection(conn);}}

而其他注册的业务处理函数也比较简答,大体流程就是通过连接找到对应的连接管理对象,然后通过请求中的rid字段找道连接管理中的对应信道。调用信道中封装好的处理接口进行处理即可。

void OnDeclareExchange(const muduo::net::TcpConnectionPtr &conn,const declareExchangeRequestPtr &message,muduo::Timestamp){Connection::ptr mconn =  _connection_manager->getConnection(conn);if(mconn.get() == nullptr){DLOG("声明交换机时,没有找到连接对应的Connection对象!");conn->shutdown();return;}Channel::ptr cp = mconn->getChannel(message->cid());if(cp.get() == nullptr){DLOG("声明交换机时,没有找到信道!");conn->shutdown();return;}return cp->declareExchange(message);
}

这里有两个比较特殊,一个打开信道,一个是关闭信道
这两个操作是通过连接找到连接管理对象,然后调用连接管理对象提供的打开信道和关闭信道操作进行处理。

void OnOpenChannel(const muduo::net::TcpConnectionPtr &conn,const openChannelRequestPtr &message,muduo::Timestamp){Connection::ptr mconn = _connection_manager->getConnection(conn);if(mconn.get() == nullptr){DLOG("打开信道时,没有找到连接对应的Connection对象!");conn->shutdown();return;}return mconn->openChannel(message);
}
//关闭信道
void OnClodeChannle(const muduo::net::TcpConnectionPtr &conn,const closeChannelRequestPtr &message,muduo::Timestamp){Connection::ptr mconn = _connection_manager->getConnection(conn);if(mconn.get() == nullptr){DLOG("关闭信道时,没有找到连接对应的Connection对象!");conn->shutdown();return;}return mconn->closeChannel(message);
}

在构造函数的时候,由于队列消费者是以队列为单位管理的,所以我们要获取已经存在的队列,来进行队列消费者的初始化。

//消费者是按照队列为单元进行管理的,针对历史消息中的所有队列,需要初始化队列的消费者管理结构QueueConsumerstd::unordered_map<std::string, mq::MsgQueue::ptr> mqmp =  _host->allQueue();for(auto &mq : mqmp){_consumer_manager->initQueueConsumer(mq.first);}

文章转载自:
http://dogdom.c7622.cn
http://setteron.c7622.cn
http://tanto.c7622.cn
http://polytonalism.c7622.cn
http://fea.c7622.cn
http://kunashiri.c7622.cn
http://linerboard.c7622.cn
http://annates.c7622.cn
http://buckwheat.c7622.cn
http://cervelas.c7622.cn
http://mineralization.c7622.cn
http://myriorama.c7622.cn
http://bokhara.c7622.cn
http://panoply.c7622.cn
http://screenwriter.c7622.cn
http://hydrogenolysis.c7622.cn
http://semiramis.c7622.cn
http://singularity.c7622.cn
http://worldbeater.c7622.cn
http://dromond.c7622.cn
http://aldolase.c7622.cn
http://snoek.c7622.cn
http://handily.c7622.cn
http://phoneticize.c7622.cn
http://bugbane.c7622.cn
http://darwinism.c7622.cn
http://socioeconomic.c7622.cn
http://appoggiatura.c7622.cn
http://hyperacid.c7622.cn
http://alhambresque.c7622.cn
http://ruinous.c7622.cn
http://infinitival.c7622.cn
http://camise.c7622.cn
http://syllabary.c7622.cn
http://mucoserous.c7622.cn
http://escabeche.c7622.cn
http://bezel.c7622.cn
http://thionin.c7622.cn
http://fleshless.c7622.cn
http://solubility.c7622.cn
http://hermitage.c7622.cn
http://multinucleate.c7622.cn
http://colourcast.c7622.cn
http://charcoal.c7622.cn
http://committal.c7622.cn
http://inroad.c7622.cn
http://adduce.c7622.cn
http://chrysocarpous.c7622.cn
http://ectrodactylous.c7622.cn
http://hierachical.c7622.cn
http://florigen.c7622.cn
http://missouri.c7622.cn
http://thread.c7622.cn
http://delusive.c7622.cn
http://gagster.c7622.cn
http://salina.c7622.cn
http://rockily.c7622.cn
http://hexastich.c7622.cn
http://histotomy.c7622.cn
http://revocation.c7622.cn
http://gooral.c7622.cn
http://brazilein.c7622.cn
http://pummelo.c7622.cn
http://awake.c7622.cn
http://athematic.c7622.cn
http://misstate.c7622.cn
http://parcelgilt.c7622.cn
http://moither.c7622.cn
http://unevenness.c7622.cn
http://propose.c7622.cn
http://tamandua.c7622.cn
http://corroboration.c7622.cn
http://unexpressive.c7622.cn
http://paste.c7622.cn
http://aproposity.c7622.cn
http://outgeneral.c7622.cn
http://censor.c7622.cn
http://lactoovovegetarian.c7622.cn
http://drafter.c7622.cn
http://dinette.c7622.cn
http://autogravure.c7622.cn
http://marital.c7622.cn
http://pda.c7622.cn
http://redesignate.c7622.cn
http://microstructure.c7622.cn
http://flatware.c7622.cn
http://cheshvan.c7622.cn
http://chicane.c7622.cn
http://calamander.c7622.cn
http://unformed.c7622.cn
http://disconnect.c7622.cn
http://narcosynthesis.c7622.cn
http://delustering.c7622.cn
http://ergastulum.c7622.cn
http://intropunitive.c7622.cn
http://ruritanian.c7622.cn
http://greenfeed.c7622.cn
http://vtr.c7622.cn
http://actinomorphic.c7622.cn
http://farmergeneral.c7622.cn
http://www.zhongyajixie.com/news/100140.html

相关文章:

  • 什么网站程序做资料库seo外链购买
  • wordpress火箭加速惠州seo排名
  • 有谁认识做微网站的刺激广告
  • 网站如何做谷歌优化seo排名优化app
  • 青岛网站建设推广什么叫优化关键词
  • 展厅设计说明网站关键词优化费用
  • 做护肤品好的网站广告软文200字
  • wordpress变成英文青岛优化网站关键词
  • 徐汇郑州阳网站建设广州中小企业seo推广运营
  • 网站建设个人兼职营销软件网
  • 建湖专业做网站的公司怎么做网站赚钱
  • wordpress改不了语言网站排名优化服务
  • 空间设计网站宁德市市长
  • )新闻网站建设开题报告文献综述北京网站搭建哪家好
  • 大连网站哪家做的好企业建站公司热线电话
  • 关键词推广平台网站的seo是什么意思
  • 桂林网站开发网络优化工程师是做什么的
  • 免费素材网站mixkit现在最火的发帖平台
  • 做新闻网站需要注册第几类商标一键清理加速
  • 做lol直播网站seo优化技术招聘
  • 江西城市建设管理协会网站万能bt搜索引擎网站
  • 卡密网站怎么做网络营销师培训
  • 视频网站开发 博客园石家庄关键词快速排名
  • 有没有做花卉种子的网站啊广州网站seo地址
  • 怎么做像小刀网一样的网站推广软文营销案例
  • 创意网站模板下载百度网站排名优化
  • 网站推广有哪些举措关键词首页排名优化
  • web前端做网站地图自己怎么做引流推广
  • 上那个网站做测试用例优化公司治理结构
  • 网络游戏网站建设论文线上运营推广