【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)
        {
        }
    };
};
相关推荐
hPw0eKIqD18 小时前
C++ 模板参数推导问题小记(非推导上下文)
开发语言·c++
程序员爱德华19 小时前
Python与C++:异同点对比
c++·python
888CC++1 天前
C语言与C++的区别:从面向过程到面向对象
java·c语言·c++
学者猫头鹰1 天前
分布式事务实战教程
java·分布式
Darkwanderor1 天前
Linux系统编程实战项目:模拟实现shell
linux·c++
himobrinehacken1 天前
揭秘Windows程序启动的神秘之旅
c++·安全
库玛西1 天前
C++ 运行时多态 :核心总结与原理图解
c语言·c++·笔记
笨蛋不要掉眼泪1 天前
RabbitMQ消息队列:MQ的可靠性
分布式·rabbitmq·java-rabbitmq
Byron Loong1 天前
【C++】重定向是什么
开发语言·c++
hansang_IR1 天前
【题解】LC:Z 算法(Z Algorithm)
c++·算法·字符串