09c2d08c
Hu Chunming
arm交付版
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/*
* @Author: yangzilong
* @Date: 2021-12-15 15:00:28
* @Last Modified by: yangzilong
* @Email: yangzilong@objecteye.com
* @Description:
*/
#include "./mq_manager.hpp"
#include "../common/logger.hpp"
#ifdef POST_USE_RABBITMQ
namespace mq
{
Manager::Manager()
{
};
bool Manager::add_conn(const key_t &key, const value_param_t& value_param)
{
if (task_status_to_mq_handle_.find(key) != task_status_to_mq_handle_.end())
return false;
std::shared_ptr<value_t> value = std::make_shared<value_t>();
if (!value->init(value_param))
return false;
task_status_to_mq_handle_[key] = value;
return true;
}
bool Manager::del_conn(const key_t &key)
{
if (task_status_to_mq_handle_.find(key) == task_status_to_mq_handle_.end())
return false;
task_status_to_mq_handle_.erase(key);
return true;
}
bool Manager::publish(const key_t &key, const char *msg, bool verbose)
{
if (task_status_to_mq_handle_.find(key) == task_status_to_mq_handle_.end())
return false;
bool status;
if (!(status = task_status_to_mq_handle_[key]->sync_publish(msg)))
LOG_ERROR("rbMQ publish {} failed", msg);
else
if (verbose)
LOG_DEBUG("rbMQ publish {} successful", msg);
return status;
}
}
#endif // #ifdef POST_USE_RABBITMQ
|