25 lines
805 B
C++
25 lines
805 B
C++
#pragma once
|
|
#include "IMessageQueue.h"
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
class XRABBITMQCLIENT_EXPORT RabbitMQClient : public IMessageQueue
|
|
{
|
|
public:
|
|
// 传入必要的连接参数
|
|
RabbitMQClient(const std::string &host, int port, const std::string &username, const std::string &password);
|
|
|
|
// 注意:使用 unique_ptr 配合 Pimpl 时,析构函数必须在 .cpp 中实现
|
|
~RabbitMQClient() override;
|
|
|
|
// 实现接口方法
|
|
bool Connect() override;
|
|
bool Publish(const std::string &routing_key, const std::string &message) override;
|
|
std::string Consume(const std::string &queue_name) override;
|
|
|
|
private:
|
|
// Pimpl 核心:前向声明具体的实现类
|
|
struct Impl;
|
|
// 使用 unique_ptr 管理实现类的生命周期
|
|
std::unique_ptr<Impl> pimpl_;
|
|
}; |