【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)
        {
        }
    };
};
相关推荐
GHL28427109013 分钟前
用PDH库获取CPU使用率(源码)
c++
让我们一起加油好吗14 分钟前
【基础算法】多源 BFS
c++·算法·bfs·宽度优先·多源bfs
冷崖17 分钟前
定时器的学习(二)
linux·c++·学习
大胆飞猪22 分钟前
高并发内存池日志
c++·项目
想唱rap36 分钟前
C++ string类的使用
开发语言·c++·笔记·算法·新浪微博
JAVA学习通37 分钟前
Replication(下):事务,一致性与共识
大数据·分布式·算法
胖咕噜的稞达鸭37 分钟前
C++中的父继子承(2)多继承菱形继承问题,多继承指针偏移,继承组合分析+高质量习题扫尾继承多态
c语言·开发语言·数据结构·c++·算法·链表·c#
小苏兮1 小时前
【C++】priority_queue和deque的使用与实现
开发语言·c++·学习
Mr_WangAndy2 小时前
C++设计模式_行为型模式_迭代器模式Iterator
c++·设计模式·迭代器模式
FL16238631292 小时前
C++基于opencv实现的暗通道的先验图像去雾
c++·opencv·计算机视觉