Skip to content

Commit fd3a1b9

Browse files
committed
modify:support default topic name set for mq protocol
1 parent 890351d commit fd3a1b9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

XEngine_Source/XEngine_MQServiceApp/MQService_TCPTask.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,11 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
299299
return false;
300300
}
301301
memcpy(&st_MQProtocol, lpszMsgBuffer, sizeof(XENGINE_PROTOCOL_XMQ));
302-
302+
//如果没有填充消息,那就使用默认
303+
if (0 == _tcsxlen(st_MQProtocol.tszMQKey))
304+
{
305+
_tcsxcpy(st_MQProtocol.tszMQKey, st_ServiceCfg.tszTopic);
306+
}
303307
if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQPOST == pSt_ProtocolHdr->unOperatorCode)
304308
{
305309
pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPPOST;
@@ -308,7 +312,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
308312

309313
memset(&st_DBQueue, '\0', sizeof(XENGINE_DBMESSAGEQUEUE));
310314
memset(&st_DBIndex, '\0', sizeof(XENGINE_DBMESSAGEQUEUE));
311-
315+
312316
st_DBQueue.byMsgType = pSt_ProtocolHdr->byVersion;
313317
st_DBQueue.nQueueSerial = st_MQProtocol.nSerial;
314318
st_DBQueue.nMsgLen = nMsgLen - sizeof(XENGINE_PROTOCOL_XMQ);
@@ -476,6 +480,7 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
476480

477481
memset(&st_MessageQueue, '\0', sizeof(XENGINE_DBMESSAGEQUEUE));
478482
memset(&st_UserKey, '\0', sizeof(XENGINE_DBUSERKEY));
483+
479484
pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REPGET;
480485
if (st_MQProtocol.nSerial > 0)
481486
{

XEngine_Source/XQueue_ProtocolHdr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ typedef struct
6868
//消息队列服务协议
6969
typedef struct
7070
{
71-
XCHAR tszMQKey[MAX_PATH]; //此消息的KEY,不能为空
71+
XCHAR tszMQKey[MAX_PATH]; //此消息的KEY,不填就是 XEngine_CommKey
7272
XCHAR tszMQUsr[MAX_PATH]; //此消息接受用户
7373
__int64x nSerial; //包序列号
7474
__int64x nPubTime; //发布时间,根据自己需求配置时区,-1表示投递的消息通过用户主动获取,0表示即时发布消息给当前订阅的在线用户,>0表示发布的日期

0 commit comments

Comments
 (0)