【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)
        {
        }
    };
};
相关推荐
实心儿儿20 小时前
C++ —— 模板进阶
开发语言·c++
q***235721 小时前
RabbitMQ介绍以及基本使用
qt·rabbitmq·ruby
go_bai21 小时前
Linux-线程2
linux·c++·经验分享·笔记·学习方法
j_xxx404_1 天前
C++:继承(概念及定义|作用域|基类与派生类转换|默认成员函数|与友元、静态成员关系|多继承|组合)
数据结构·c++
欧阳x天1 天前
C++入门(二)
开发语言·c++
这人很懒没留下什么1 天前
SpringBoot2.7.4整合RabbitMq
rabbitmq·springboot
zl9798991 天前
RabbitMQ-Work Queues
分布式·rabbitmq
编程之路,妙趣横生1 天前
STL(五) priority_queue 基本用法 + 模拟实现
c++
一念一花一世界1 天前
Arbess从初级到进阶(9) - 使用Arbess+GitLab实现C++项目自动化部署
c++·ci/cd·gitlab·arbess
大锦终1 天前
【Linux】Reactor
linux·运维·服务器·c++