【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)
        {
        }
    };
};
相关推荐
liulilittle7 分钟前
C++ 并发双阶段队列设计原理与实现
linux·开发语言·c++·windows·算法·线程·并发
森G18 分钟前
五、Linux字符设备驱动
linux·arm开发·c++·ubuntu
繁星蓝雨29 分钟前
我与C++的故事(杂谈)
开发语言·c++
CrazyClaz34 分钟前
分布式事务专题5
分布式·分布式事务
Queenie_Charlie1 小时前
和为k的连续区间
数据结构·c++·map
灯下夜无眠2 小时前
spark集群文件分发问题
大数据·分布式·spark
white-persist2 小时前
【攻防世界】reverse | Mysterious 详细题解 WP
c语言·开发语言·网络·汇编·c++·python·安全
赖small强2 小时前
【Linux C/C++ 开发】 GCC 编译过程深度解析指南
linux·c语言·c++·预处理·链接·编译·编译过程
BestOrNothing_20152 小时前
C++ 并发四件套:并发编程 / 原子性 / 数据竞争 / 内存模型 (全解析)
c++·多线程·并发编程·线程安全·内存模型·原子操作·数据竞争
想唱rap2 小时前
C++之unordered_set和unordered_map
c++·算法·哈希算法