Skip to content

Commit 3b9fdc6

Browse files
committed
added:delete topic support for http
1 parent 74e3347 commit 3b9fdc6

File tree

4 files changed

+48
-2
lines changed

4 files changed

+48
-2
lines changed

XEngine_Source/MQCore_DBModule/DBModule_MQUser/DBModule_MQUser.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ bool CDBModule_MQUser::DBModule_MQUser_OwnerDelete(XENGINE_DBTOPICOWNER* pSt_DBO
10701070
return false;
10711071
}
10721072
}
1073-
else
1073+
else if ((_tcsxlen(pSt_DBOwner->tszUserName) > 0) && (_tcsxlen(pSt_DBOwner->tszQueueName) <= 0))
10741074
{
10751075
_xstprintf(tszSQLStatement, _X("DELETE FROM `KeyOwner` WHERE tszUserName = '%s'"), pSt_DBOwner->tszUserName);
10761076
if (!DataBase_MySQL_Execute(xhDBSQL, tszSQLStatement))
@@ -1080,6 +1080,16 @@ bool CDBModule_MQUser::DBModule_MQUser_OwnerDelete(XENGINE_DBTOPICOWNER* pSt_DBO
10801080
return false;
10811081
}
10821082
}
1083+
else
1084+
{
1085+
_xstprintf(tszSQLStatement, _X("DELETE FROM `KeyOwner` WHERE tszKeyName = '%s'"), pSt_DBOwner->tszQueueName);
1086+
if (!DataBase_MySQL_Execute(xhDBSQL, tszSQLStatement))
1087+
{
1088+
DBModule_IsErrorOccur = true;
1089+
DBModule_dwErrorCode = DataBase_GetLastError();
1090+
return false;
1091+
}
1092+
}
10831093

10841094
return true;
10851095
}

XEngine_Source/XEngine_MQServiceApp/MQService_HttpTask.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,30 @@ bool MessageQueue_Http_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LPCXST
168168
//type = 0 删除主题
169169
memset(tszValue, '\0', MAX_PATH);
170170
BaseLib_String_GetKeyValue(ppSt_ListUrl[nMethodPos + 3], _X("="), tszKey, tszValue);
171+
172+
XENGINE_DBTOPICOWNER st_DBOwner = {};
173+
XENGINE_DBUSERKEY st_UserKey = {};
174+
XENGINE_DBTIMERELEASE st_DBInfo = {};
175+
176+
_tcsxcpy(st_DBOwner.tszQueueName, tszValue);
177+
_tcsxcpy(st_UserKey.tszKeyName, tszValue);
178+
_tcsxcpy(st_DBInfo.tszQueueName, tszValue);
179+
if (!DBModule_MQUser_OwnerDelete(&st_DBOwner))
180+
{
181+
ProtocolModule_Packet_Http(tszPKTBuffer, &nPKTLen, ERROR_XENGINE_MESSAGE_HTTP_NOTFOUND, "topic name not found");
182+
XEngine_MQXService_Send(lpszClientAddr, tszPKTBuffer, nPKTLen, XENGINE_MQAPP_NETTYPE_HTTP);
183+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("HTTP客户端:%s,请求HTTP删除主题失败,主题不存在:%s"), lpszClientAddr, tszValue);
184+
return false;
185+
}
186+
//清楚数据库
187+
APIHelp_Counter_SerialDel(tszValue);
188+
DBModule_MQData_DeleteTable(tszValue);
189+
DBModule_MQUser_KeyDelete(&st_UserKey);
190+
DBModule_MQUser_TimeDelete(&st_DBInfo);
191+
192+
ProtocolModule_Packet_Http(tszPKTBuffer, &nPKTLen);
193+
XEngine_MQXService_Send(lpszClientAddr, tszPKTBuffer, nPKTLen, XENGINE_MQAPP_NETTYPE_HTTP);
194+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("HTTP客户端:%s,请求主题删除成功,主题名:%s"), lpszClientAddr, tszValue);
171195
}
172196
else
173197
{
@@ -185,7 +209,7 @@ bool MessageQueue_Http_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LPCXST
185209

186210
if (!DBModule_MQUser_UserQuery(&st_UserInfo))
187211
{
188-
ProtocolModule_Packet_Http(tszPKTBuffer, &nPKTLen, ERROR_XENGINE_MESSAGE_AUTH_USERPASS, "user name not found");
212+
ProtocolModule_Packet_Http(tszPKTBuffer, &nPKTLen, ERROR_XENGINE_MESSAGE_HTTP_NOTFOUND, "user name not found");
189213
XEngine_MQXService_Send(lpszClientAddr, tszPKTBuffer, nPKTLen, XENGINE_MQAPP_NETTYPE_HTTP);
190214
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("HTTP客户端:%s,请求HTTP删除用户失败,用户不存在:%s"), lpszClientAddr, st_UserInfo.tszUserName);
191215
return false;

XEngine_Source/XEngine_MQServiceApp/MQService_TCPTask.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,17 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
776776
_tcsxcpy(st_UserKey.tszKeyName, st_MQProtocol.tszMQKey);
777777
_tcsxcpy(st_DBInfo.tszQueueName, st_MQProtocol.tszMQKey);
778778

779+
if (_tcsxlen(st_DBOwner.tszUserName) <= 0)
780+
{
781+
if (pSt_ProtocolHdr->byIsReply)
782+
{
783+
pSt_ProtocolHdr->wReserve = ERROR_XENGINE_MESSAGE_XMQ_DELOWNER;
784+
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
785+
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
786+
}
787+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s消息端:%s,删除主题失败,删除所有者失败,主题名称:%s,用户名为空"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, tszUserName);
788+
return false;
789+
}
779790
if (!DBModule_MQUser_OwnerDelete(&st_DBOwner))
780791
{
781792
if (pSt_ProtocolHdr->byIsReply)

XEngine_Source/XQueue_ProtocolHdr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484

8585
#define ERROR_XENGINE_MESSAGE_HTTP_PARAMENT 0x201 //HTTP请求参数错误
8686
#define ERROR_XENGINE_MESSAGE_HTTP_AUTHORIZE 0x202 //验证失败没有权限
87+
#define ERROR_XENGINE_MESSAGE_HTTP_NOTFOUND 0x203 //没有找到请求的数据
8788
///////////////////////////////////////////////////////////////////////////
8889
// 导出的数据结构
8990
///////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)