123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- #include "rabbitmq_message.h"
- Rabbitmq_message::Rabbitmq_message() {
- m_message_type = message::Message_type::eBase_msg;
- m_receive_time = std::chrono::system_clock::now();
- m_timeout_ms = std::chrono::milliseconds(0); //超时默认0秒
- m_sender = message::Communicator::eEmpty;
- m_receiver = message::Communicator::eEmpty;
- // m_message_buf = "";
- }
- 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) {
- m_message_type = (message::Message_type) (base_info.msg_type());
- m_receive_time = std::chrono::system_clock::now();
- m_timeout_ms = std::chrono::milliseconds(base_info.timeout_ms());
- m_sender = (message::Communicator) (base_info.sender());
- m_receiver = (message::Communicator) (base_info.receiver());
- m_message_buf = receive_string;
- m_channel = channel;
- m_delivery_tag = delivery_tag;
- m_exchange_name = exchange_name;
- m_routing_key = routing_key;
- }
- Rabbitmq_message::Rabbitmq_message(std::string receive_string, int channel, std::string exchange_name,
- std::string routing_key, int timeout_ms = 0) {
- m_timeout_ms = std::chrono::milliseconds(timeout_ms);
- m_message_buf = receive_string;
- m_channel = channel;
- m_exchange_name = exchange_name;
- m_routing_key = routing_key;
- }
- Rabbitmq_message::~Rabbitmq_message() {
- }
- bool Rabbitmq_message::is_over_time() {
- if (std::chrono::system_clock::now() - m_receive_time > m_timeout_ms) {
- return true;
- } else {
- return false;
- }
- }
- void
- Rabbitmq_message::reset(const message::Base_info &base_info, std::string receive_string, int channel, int delivery_tag,
- std::string exchange_name, std::string routing_key) {
- m_message_type = (message::Message_type) (base_info.msg_type());
- m_receive_time = std::chrono::system_clock::now();
- m_timeout_ms = std::chrono::milliseconds(base_info.timeout_ms());
- m_sender = (message::Communicator) (base_info.sender());
- m_receiver = (message::Communicator) (base_info.receiver());
- m_message_buf = receive_string;
- m_channel = channel;
- m_delivery_tag = delivery_tag;
- m_exchange_name = exchange_name;
- m_routing_key = routing_key;
- }
- void
- Rabbitmq_message::reset(std::string receive_string, int channel, std::string exchange_name, std::string routing_key,
- int timeout_ms = 0) {
- m_timeout_ms = std::chrono::milliseconds(timeout_ms);
- m_message_buf = receive_string;
- m_channel = channel;
- m_exchange_name = exchange_name;
- m_routing_key = routing_key;
- }
- message::Message_type Rabbitmq_message::get_message_type() {
- return m_message_type;
- }
- message::Communicator Rabbitmq_message::get_sender() {
- return m_sender;
- }
- message::Communicator Rabbitmq_message::get_receiver() {
- return m_receiver;
- }
- std::string Rabbitmq_message::get_message_buf() {
- return m_message_buf;
- }
- std::chrono::system_clock::time_point Rabbitmq_message::get_receive_time() {
- return m_receive_time;
- }
|