【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)
        {
        }
    };
};
相关推荐
呜喵王阿尔萨斯15 分钟前
git命令解析
c++·git
ACRELKY3 小时前
光伏运维迎来云端革命!AcrelCloud-1200如何破解分布式光伏四大痛点?
运维·分布式
Murphy_lx5 小时前
Lambda表达式
开发语言·c++
yangpipi-5 小时前
C++并发编程-23. 线程间切分任务的方法
开发语言·c++
楼田莉子6 小时前
C++算法专题学习——分治
数据结构·c++·学习·算法·leetcode·排序算法
子非鱼@Itfuture6 小时前
【Kafka】Kafka使用场景用例&Kafka用例图
分布式·中间件·kafka
ulias2127 小时前
各种背包问题简述
数据结构·c++·算法·动态规划
程序喵大人7 小时前
分享个C++线程池的实现源码
开发语言·c++·线程池
零千叶7 小时前
【面试】RabbitMQ 常见问题
面试·职场和发展·rabbitmq
kobe_OKOK_7 小时前
rabbitmq 入门知识点
分布式·rabbitmq·ruby