12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- //
- // Created by huli on 2020/6/29.
- //
- #ifndef __RABBITMQ_MESSAGE_H
- #define __RABBITMQ_MESSAGE_H
- #include "error_code/error_code.hpp"
- #include <time.h>
- #include <sys/time.h>
- #include <chrono>
- //#include <iosfwd>
- #include <string>
- #include "message/message_base.pb.h"
- class Rabbitmq_message {
- public:
- Rabbitmq_message();
- Rabbitmq_message(const message::Base_info &base_info, std::string receive_string, int channel, int delivery_tag,
- std::string exchange_name, std::string routing_key);
- Rabbitmq_message(std::string receive_string, int channel, std::string exchange_name, std::string routing_key,
- int timeout_ms);
- Rabbitmq_message(const Rabbitmq_message &other) = default;
- Rabbitmq_message &operator=(const Rabbitmq_message &other) = default;
- ~Rabbitmq_message();
- public://API functions
- bool is_over_time();
- public://get or set member variable
- void reset(const message::Base_info &base_info, std::string receive_string, int channel, int delivery_tag,
- std::string exchange_name, std::string routing_key);
- void
- reset(std::string receive_string, int channel, std::string exchange_name, std::string routing_key, int timeout_ms);
- message::Message_type get_message_type();
- message::Communicator get_sender();
- message::Communicator get_receiver();
- std::string get_message_buf();
- std::chrono::system_clock::time_point get_receive_time();
- public://member variable
- message::Message_type m_message_type; //消息类型
- std::chrono::system_clock::time_point m_receive_time; //接收消息的时间点
- std::chrono::milliseconds m_timeout_ms; //超时时间, 整个软件都统一为毫秒
- message::Communicator m_sender; //发送者
- message::Communicator m_receiver; //接受者
- std::string m_message_buf; //消息数据
- //rabbitmq 接受特有, 保存channel和delivery_tag, 用来ack
- //rabbitmq 通用, 填写m_channel m_exchange_name m_routing_key 用来区别消息
- int m_channel; //接受消息来源的通道
- int m_delivery_tag; //接受消息的传递编号
- std::string m_exchange_name; //交换机名称
- std::string m_routing_key; //key,识别码
- private:
- };
- #endif //__RABBITMQ_MESSAGE_H
|