【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)
        {
        }
    };
};
相关推荐
国科安芯2 小时前
ASL706S:让 MCU 不再“失忆跑飞“的守护芯片
分布式·单片机·嵌入式硬件·安全·fpga开发·架构
夜不会漫长3 小时前
C++入门(1)
开发语言·c++·算法
阿无,4 小时前
RabbitMQ面试题
分布式·rabbitmq
旖旎夜光4 小时前
LeetCode 852:山脉数组的峰顶索引(二分查找) —— 题解
数据结构·c++·算法·leetcode·二分查找
..Dauntless..4 小时前
【C++】继承——基类和派生类的配合
开发语言·c++·算法
程与留5 小时前
05_Qt 核心模块概览——Qt Core、Gui、Widgets、Quick 的职责划分
c++·qt
buhuizhiyuci5 小时前
【QT-百日筑基篇】修真世界摸爬滚打多年,终于黄天不负有心人,突破炼器中期——常用控件QWight的属性
开发语言·c++·qt·gui·图形化
盛世宏博智慧档案6 小时前
全国100个分布式机房环境温湿度智能监测系统建设方案
分布式·机房·温湿度
六bring个六7 小时前
分布式设备连接对端失败问题分析
分布式·分布式软总线
冻柠檬飞冰走茶9 小时前
《数据结构实验指导-C++语言版》 求单链表list中的元素个数,即表长
开发语言·数据结构·c++·算法·list