fix mq
This commit is contained in:
@@ -401,6 +401,8 @@ public:
|
|||||||
// 设置 nameserver 地址
|
// 设置 nameserver 地址
|
||||||
SetProducerNameServerAddress(producer_, nameServer.c_str());
|
SetProducerNameServerAddress(producer_, nameServer.c_str());
|
||||||
|
|
||||||
|
SetProducerSessionCredentials(producer_, G_MQCONSUMER_ACCESSKEY.c_str(),G_MQCONSUMER_SECRETKEY.c_str(), "");
|
||||||
|
|
||||||
// 启动生产者
|
// 启动生产者
|
||||||
StartProducer(producer_);
|
StartProducer(producer_);
|
||||||
|
|
||||||
@@ -411,6 +413,32 @@ public:
|
|||||||
RocketMQProducer(const RocketMQProducer&) = delete;
|
RocketMQProducer(const RocketMQProducer&) = delete;
|
||||||
RocketMQProducer& operator=(const RocketMQProducer&) = delete;
|
RocketMQProducer& operator=(const RocketMQProducer&) = delete;
|
||||||
|
|
||||||
|
void printSendResult(const CSendResult& result) {
|
||||||
|
std::cout << "SendResult:" << std::endl;
|
||||||
|
std::cout << " Status: ";
|
||||||
|
switch (result.sendStatus) {
|
||||||
|
case E_SEND_OK:
|
||||||
|
std::cout << "E_SEND_OK";
|
||||||
|
break;
|
||||||
|
case E_SEND_FLUSH_DISK_TIMEOUT:
|
||||||
|
std::cout << "E_SEND_FLUSH_DISK_TIMEOUT";
|
||||||
|
break;
|
||||||
|
case E_SEND_FLUSH_SLAVE_TIMEOUT:
|
||||||
|
std::cout << "E_SEND_FLUSH_SLAVE_TIMEOUT";
|
||||||
|
break;
|
||||||
|
case E_SEND_SLAVE_NOT_AVAILABLE:
|
||||||
|
std::cout << "E_SEND_SLAVE_NOT_AVAILABLE";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
std::cout << "UNKNOWN(" << result.sendStatus << ")";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
std::cout << " MsgID : " << result.msgId << std::endl;
|
||||||
|
std::cout << " Offset: " << result.offset << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
// 发送消息
|
// 发送消息
|
||||||
void sendMessage(const char* strbody, const char* topic, const std::string& tags, const std::string& keys) {
|
void sendMessage(const char* strbody, const char* topic, const std::string& tags, const std::string& keys) {
|
||||||
CSendResult result;
|
CSendResult result;
|
||||||
@@ -439,12 +467,23 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//调试用
|
//调试用
|
||||||
/*
|
/*int sendResult = SendMessageSync(
|
||||||
|
producer_,
|
||||||
|
msg,
|
||||||
|
&result
|
||||||
|
);
|
||||||
|
int ret = SendMessageSync(producer_, msg, &result);
|
||||||
|
if (ret == 0) {
|
||||||
|
printSendResult(result);
|
||||||
|
} else {
|
||||||
|
std::cerr << "SendMessageSync failed with ret=" << ret << std::endl;
|
||||||
|
}*/
|
||||||
|
|
||||||
if (sendResult == 0) { // 假设返回 0 表示成功
|
if (sendResult == 0) { // 假设返回 0 表示成功
|
||||||
std::cout << "Message sent successfully.topic:" << topic <<std::endl;
|
std::cout << "Message sent successfully.topic:" << topic <<std::endl;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Failed to send message." << std::endl;
|
std::cout << "Failed to send message." << std::endl;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
// 销毁消息
|
// 销毁消息
|
||||||
DestroyMessage(msg);
|
DestroyMessage(msg);
|
||||||
|
|||||||
BIN
pt61850netd_pqfe
Normal file
BIN
pt61850netd_pqfe
Normal file
Binary file not shown.
BIN
pt61850netd_pqfed
Normal file
BIN
pt61850netd_pqfed
Normal file
Binary file not shown.
Reference in New Issue
Block a user