Skip to content

Commit 8581c9d

Browse files
committed
fixed:sql insert is incorrent
modify:message attr process method
1 parent e1cccd5 commit 8581c9d

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

XEngine_Source/MQCore_DBModule/DBModule_Define.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ typedef struct
2525
XCHAR tszQueueCreateTime[64]; //创建时间
2626
__int64x nQueueSerial; //包序列号
2727
int nMsgLen; //消息大小
28+
XSHOT nMsgAttr; //消息属性
2829
XBYTE byMsgType; //消息类型,参考:ENUM_XENGINE_PROTOCOLHDR_PAYLOAD_TYPE
29-
XBYTE byMsgAttr; //消息属性
3030
}XENGINE_DBMESSAGEQUEUE;
3131
typedef struct
3232
{

XEngine_Source/MQCore_DBModule/DBModule_MQData/DBModule_MQData.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ bool CDBModule_MQData::DBModule_MQData_Insert(XENGINE_DBMESSAGEQUEUE* pSt_DBInfo
100100
memset(tszSQLCoder, '\0', sizeof(tszSQLCoder));
101101

102102
DataBase_MySQL_Coder(xhDBSQL, pSt_DBInfo->tszMsgBuffer, tszSQLCoder, &pSt_DBInfo->nMsgLen);
103-
__int64u nRet = _xstprintf(tszSQLStatement, _X("INSERT INTO `%s` (tszUserName,tszUserBelong,tszQueueName,nQueueSerial,tszQueueLeftTime,tszQueuePublishTime,tszQueueData,nDataType,nDataAttr,tszQueueCreateTime) VALUES('%s','%s','%s',%lld,'%s','%s','"), pSt_DBInfo->tszQueueName, pSt_DBInfo->tszUserBelong, pSt_DBInfo->tszUserName, pSt_DBInfo->tszQueueName, pSt_DBInfo->nQueueSerial, pSt_DBInfo->tszQueueLeftTime, pSt_DBInfo->tszQueuePublishTime);
103+
__int64u nRet = _xstprintf(tszSQLStatement, _X("INSERT INTO `%s` (tszUserName,tszUserBelong,tszQueueName,nQueueSerial,tszQueueLeftTime,tszQueuePublishTime,tszQueueData,nDataType,nDataAttr,tszQueueCreateTime) VALUES('%s','%s','%s',%lld,'%s','%s','"), pSt_DBInfo->tszQueueName, pSt_DBInfo->tszUserName, pSt_DBInfo->tszUserBelong, pSt_DBInfo->tszQueueName, pSt_DBInfo->nQueueSerial, pSt_DBInfo->tszQueueLeftTime, pSt_DBInfo->tszQueuePublishTime);
104104
memcpy(tszSQLStatement + nRet, tszSQLCoder, pSt_DBInfo->nMsgLen);
105105
nRet += pSt_DBInfo->nMsgLen;
106106

107107
memset(tszSQLCoder, '\0', sizeof(tszSQLCoder));
108-
int nLen = _xstprintf(tszSQLCoder, _X("',%d,%d,now())"), pSt_DBInfo->byMsgType, pSt_DBInfo->byMsgAttr);
108+
int nLen = _xstprintf(tszSQLCoder, _X("',%d,%d,now())"), pSt_DBInfo->byMsgType, pSt_DBInfo->nMsgAttr);
109109
memcpy(tszSQLStatement + nRet, tszSQLCoder, nLen);
110110
nRet += nLen;
111111

@@ -208,7 +208,7 @@ bool CDBModule_MQData::DBModule_MQData_Query(XENGINE_DBMESSAGEQUEUE* pSt_DBInfo)
208208
nPos++;
209209
if (NULL != pptszResult[nPos])
210210
{
211-
pSt_DBInfo->byMsgAttr = _ttxoi(pptszResult[nPos]);
211+
pSt_DBInfo->nMsgAttr = _ttxoi(pptszResult[nPos]);
212212
}
213213
nPos++;
214214
if (NULL != pptszResult[nPos])
@@ -254,7 +254,7 @@ bool CDBModule_MQData::DBModule_MQData_Modify(XENGINE_DBMESSAGEQUEUE* pSt_DBInfo
254254
nRet += pSt_DBInfo->nMsgLen;
255255

256256
memset(tszSQLCoder, '\0', sizeof(tszSQLCoder));
257-
int nLen = _xstprintf(tszSQLCoder, _X("',nDataType = %d,nDataAttr = %d WHERE tszUserName = '%s' AND tszQueueName = '%s' AND nQueueSerial = %lld"), pSt_DBInfo->byMsgType, pSt_DBInfo->byMsgAttr, pSt_DBInfo->tszUserName, pSt_DBInfo->tszQueueName, pSt_DBInfo->nQueueSerial);
257+
int nLen = _xstprintf(tszSQLCoder, _X("',nDataType = %d,nDataAttr = %d WHERE tszUserName = '%s' AND tszQueueName = '%s' AND nQueueSerial = %lld"), pSt_DBInfo->byMsgType, pSt_DBInfo->nMsgAttr, pSt_DBInfo->tszUserName, pSt_DBInfo->tszQueueName, pSt_DBInfo->nQueueSerial);
258258
memcpy(tszSQLStatement + nRet, tszSQLCoder, nLen);
259259
nRet += nLen;
260260

@@ -377,7 +377,7 @@ bool CDBModule_MQData::DBModule_MQData_List(LPCXSTR lpszQueueName, __int64x nSer
377377
nPos++;
378378
if (NULL != pptszResult[nPos])
379379
{
380-
(*pppSt_DBMessage)[i]->byMsgAttr = _ttxoi(pptszResult[nPos]);
380+
(*pppSt_DBMessage)[i]->nMsgAttr = _ttxoi(pptszResult[nPos]);
381381
}
382382
nPos++;
383383
if (NULL != pptszResult[nPos])
@@ -492,7 +492,7 @@ bool CDBModule_MQData::DBModule_MQData_GetSerial(LPCXSTR lpszName, __int64x* pIn
492492
nPos++;
493493
if (NULL != pptszResult[nPos])
494494
{
495-
pSt_DBStart->byMsgAttr = _ttxoi(pptszResult[nPos]);
495+
pSt_DBStart->nMsgAttr = _ttxoi(pptszResult[nPos]);
496496
}
497497
nPos++;
498498
if (NULL != pptszResult[nPos])
@@ -562,7 +562,7 @@ bool CDBModule_MQData::DBModule_MQData_GetSerial(LPCXSTR lpszName, __int64x* pIn
562562
nPos++;
563563
if (NULL != pptszResult[nPos])
564564
{
565-
pSt_DBEnd->byMsgAttr = _ttxoi(pptszResult[nPos]);
565+
pSt_DBEnd->nMsgAttr = _ttxoi(pptszResult[nPos]);
566566
}
567567
nPos++;
568568
if (NULL != pptszResult[nPos])

XEngine_Source/MQCore_ProtocolModule/ProtocolModule_Packet/ProtocolModule_Packet.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ bool CProtocolModule_Packet::ProtocolModule_Packet_UNReadInsert(XHANDLE xhToken,
574574
for (int i = 0; i < nListCount; i++)
575575
{
576576
XENGINE_PROTOCOL_MSGATTR st_MSGAttr;
577-
memcpy(&st_MSGAttr, &(*pppSt_DBMessage)[i]->byMsgAttr, sizeof(XENGINE_PROTOCOL_MSGATTR));
577+
memcpy(&st_MSGAttr, &(*pppSt_DBMessage)[i]->nMsgAttr, sizeof(XENGINE_PROTOCOL_MSGATTR));
578578

579579
if ((0 == st_MSGAttr.byAttrSelf) && (0 == _tcsxnicmp(lpszUserName, (*pppSt_DBMessage)[i]->tszUserName, _tcsxlen((*pppSt_DBMessage)[i]->tszUserName))))
580580
{
@@ -589,8 +589,8 @@ bool CProtocolModule_Packet::ProtocolModule_Packet_UNReadInsert(XHANDLE xhToken,
589589
st_JsonObject["tszQueueCreateTime"] = (*pppSt_DBMessage)[i]->tszQueueCreateTime;
590590
st_JsonObject["nQueueSerial"] = (Json::Value::Int64)(*pppSt_DBMessage)[i]->nQueueSerial;
591591
st_JsonObject["nMsgLen"] = (*pppSt_DBMessage)[i]->nMsgLen;
592+
st_JsonObject["nMsgAttr"] = (*pppSt_DBMessage)[i]->nMsgAttr;
592593
st_JsonObject["byMsgType"] = (*pppSt_DBMessage)[i]->byMsgType;
593-
st_JsonObject["byMsgAttr"] = (*pppSt_DBMessage)[i]->byMsgAttr;
594594
st_JsonObject["tszMsgBuffer"] = (*pppSt_DBMessage)[i]->tszMsgBuffer;
595595
st_JsonSub.append(st_JsonObject);
596596
}
@@ -791,9 +791,9 @@ bool CProtocolModule_Packet::ProtocolModule_Packet_WSCommon(XENGINE_PROTOCOLHDR*
791791
st_JsonMQProtocol["nKeepTime"] = pSt_MQProtocol->nKeepTime;
792792
st_JsonMQProtocol["nPubTime"] = (Json::Value::Int64)pSt_MQProtocol->nPubTime;
793793

794-
XBYTE byMSGAttr = 0;
795-
memcpy(&byMSGAttr, &pSt_MQProtocol->st_MSGAttr, sizeof(XENGINE_PROTOCOL_MSGATTR));
796-
st_JsonMQProtocol["byMSGAttr"] = byMSGAttr;
794+
XSHOT nMSGAttr = 0;
795+
memcpy(&nMSGAttr, &pSt_MQProtocol->st_MSGAttr, sizeof(XENGINE_PROTOCOL_MSGATTR));
796+
st_JsonMQProtocol["nMSGAttr"] = nMSGAttr;
797797
st_JsonRoot["st_MQProtocol"] = st_JsonMQProtocol;
798798
}
799799

XEngine_Source/MQCore_ProtocolModule/ProtocolModule_Parse/ProtocolModule_Parse.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ bool CProtocolModule_Parse::ProtocolModule_Parse_Websocket(LPCXSTR lpszMsgBuffer
137137
{
138138
st_MQProtocol.nPubTime = st_JsonMQProtocol["nPubTime"].asInt64();
139139
}
140-
if (!st_JsonMQProtocol["byMSGAttr"].isNull())
140+
if (!st_JsonMQProtocol["nMSGAttr"].isNull())
141141
{
142-
XBYTE byMSGAttr = st_JsonMQProtocol["byMSGAttr"].asUInt();
143-
memcpy(&st_MQProtocol.st_MSGAttr, &byMSGAttr, sizeof(XENGINE_PROTOCOL_MSGATTR));
142+
XSHOT nMSGAttr = st_JsonMQProtocol["nMSGAttr"].asUInt();
143+
memcpy(&st_MQProtocol.st_MSGAttr, &nMSGAttr, sizeof(XENGINE_PROTOCOL_MSGATTR));
144144
}
145145
*pInt_MsgLen += sizeof(XENGINE_PROTOCOL_XMQ);
146146
memcpy(ptszMsgBuffer + nPos, &st_MQProtocol, sizeof(XENGINE_PROTOCOL_XMQ));

XEngine_Source/XEngine_MQServiceApp/MQService_TCPTask.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
330330
st_DBQueue.nQueueSerial = st_MQProtocol.nSerial;
331331
st_DBQueue.nMsgLen = nMsgLen - sizeof(XENGINE_PROTOCOL_XMQ);
332332
_tcsxcpy(st_DBQueue.tszUserName, tszUserName);
333+
_tcsxcpy(st_DBQueue.tszUserBelong, st_MQProtocol.tszMQUsr);
333334
_tcsxcpy(st_DBQueue.tszQueueName, st_MQProtocol.tszMQKey);
334335
memcpy(st_DBQueue.tszMsgBuffer, lpszMsgBuffer + sizeof(XENGINE_PROTOCOL_XMQ), st_DBQueue.nMsgLen);
335336

@@ -552,7 +553,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
552553
}
553554
//是不是自己发布的
554555
XENGINE_PROTOCOL_MSGATTR st_MSGAttr;
555-
memcpy(&st_MSGAttr, &st_MessageQueue.byMsgAttr, sizeof(XENGINE_PROTOCOL_MSGATTR));
556+
memcpy(&st_MSGAttr, &st_MessageQueue.nMsgAttr, sizeof(XENGINE_PROTOCOL_MSGATTR));
556557
//如果不能发送自己并且是自己的消息,那么就跳过
557558
if (0 == st_MSGAttr.byAttrSelf && (0 == _tcsxnicmp(st_MessageQueue.tszUserName, tszUserName, _tcsxlen(tszUserName))))
558559
{

XEngine_Source/XQueue_ProtocolHdr.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ typedef struct
6464
XBYTE byAttrResver6 : 1;
6565
XBYTE byAttrResver7 : 1;
6666
XBYTE byAttrResver;
67-
XSHOT nAttrResver;
6867
}XENGINE_PROTOCOL_MSGATTR, * LPXENGINE_PROTOCOL_MSGATTR;
6968
//消息队列服务协议
7069
typedef struct

0 commit comments

Comments
 (0)