【RabbitMQ 项目】客户端:消费者模块

和服务端的消费者实现方式一模一样,只不过服务端的消费者的回调函数是把消息封装成响应并发送,固定都是这个动作,而客户端消费者回调是用来处理消息,是用户自己设置的。

cpp 复制代码
#pragma once
#include "../common/Log.hpp"
#include "../common/message.pb.h"
#include <functional>
#include <memory>
#include <atomic>
#include <mutex>
#include <vector>
#include <unordered_map>
namespace ns_consumer
{
    using namespace ns_log;

    struct Consumer;
    using ConsumerPtr = std::shared_ptr<Consumer>;
    using ConsumerCallback_t = std::function<void(const ns_data::Message& msg)>;
    struct Consumer
    {
        std::string _id;
        std::string _qname;
        ConsumerCallback_t _callback;
        bool _autoAck;

        Consumer(const std::string id, const std::string &qname, ConsumerCallback_t callback, bool autoAck)
            : _id(id),
              _qname(qname),
              _callback(callback),
              _autoAck(autoAck)
        {
        }
    };
};
相关推荐
fqbqrr6 分钟前
2607d,C++细节比不上d
c++·d
^yi7 分钟前
【C++】继承的那些事儿~
c++·继承·菱形继承·隐藏·final·继承原理·多继承的指针偏移
ShineWinsu2 小时前
对于Linux:模版方法类的解析以及socket、TcpSocket的封装
linux·c++·面试·socket·模板方法模式·封装·tcpsocket
hold?fish:palm3 小时前
9 找到字符串中所有字母异位词
c++·算法·leetcode
风中凌乱3 小时前
kafka新版本集群的安装与部署
分布式·kafka
SLD_Allen4 小时前
大规模分布式AI训练基础设施
人工智能·分布式·模型训练
啦啦啦啦啦zzzz4 小时前
算法:回溯算法
c++·算法·leetcode
Lzg_na4 小时前
订阅发布模块事例
c++
攻城狮Soar4 小时前
C++子类访问父类成员
c++·算法
郝学胜-神的一滴4 小时前
[简化版 GAMES 104] 现代游戏引擎 02:拆解现代游戏引擎5+1层级架构,吃透引擎底层核心逻辑
c++·unity·架构·游戏引擎·图形渲染·unreal engine·系统设计