【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)
        {
        }
    };
};
相关推荐
她说可以呀7 分钟前
RabbitMQ Confirm与Returns模式
分布式·rabbitmq
库克克32 分钟前
【C++】类和对象--this指针详解
java·开发语言·c++
Mr__Miss35 分钟前
Session、Cookie、JWT 详解:从单体到分布式的认证方案演进
分布式
ch0sen1pm1 小时前
加班之余从零写了个 spdlog 风格的日志库
c++
吃着火锅x唱着歌1 小时前
Effective C++ 学习笔记 条款33 避免遮掩继承来的名称
c++·笔记·学习
Database_Cool_1 小时前
阿里云 PolarDB-X vs OceanBase 国产分布式数据库深度对比
分布式·阿里云·oceanbase
她说可以呀1 小时前
RabbitMQ重试机制
分布式·rabbitmq
wuqingshun3141591 小时前
RabbitMQ 中消息什么时候会进入死信交换机?
分布式·rabbitmq
hdsoft_huge2 小时前
SpringBoot系列12:整合RabbitMQ消息队列,异步解耦、死信队列完整业务案例
spring boot·rabbitmq·java-rabbitmq
库克克2 小时前
【C++】类和对象--类对象模型与大小计算
开发语言·jvm·c++