【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)
        {
        }
    };
};
相关推荐
赖small强5 分钟前
【Linux C/C++开发】Linux C/C++ 堆栈溢出:原理、利用与防护深度指南
linux·c语言·c++·stack·堆栈溢出
爱学习的梵高先生7 分钟前
C++:基础知识
开发语言·c++·算法
oioihoii11 分钟前
C++对象生命周期与析构顺序深度解析
java·开发语言·c++
xlq2232214 分钟前
24.map set(下)
数据结构·c++·算法
晚风吹长发40 分钟前
初步了解Linux中文件描述符-fd
linux·运维·服务器·c++·开发·文件
赖small强44 分钟前
【Linux C/C++开发】Linux C/C++ 高效延迟崩溃分析:基于 mprotect 的内存陷阱技术 (Electric Fence)
linux·c语言·c++·mprotect·buffer overflow
繁华似锦respect1 小时前
C++ & Linux 中 GDB 调试与内存泄漏检测详解
linux·c语言·开发语言·c++·windows·算法
锡兰_CC1 小时前
无缝触达,卓越体验:开启openEuler世界的任意门
服务器·网络·数据库·c++·图像处理·qt·nginx
王燕龙(大卫)1 小时前
滑动窗口问题记录
c++
不会代码的小猴1 小时前
C++的第十二天笔记
开发语言·c++·笔记