Skip to content

Commit 613b735

Browse files
committed
modify:break time task and left task when get message
1 parent 5cfd4c4 commit 613b735

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

XEngine_Source/XEngine_MQServiceApp/MQService_TCPTask.cpp

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -467,15 +467,40 @@ BOOL MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCTSTR lpszC
467467
return FALSE;
468468
}
469469
//得到消息
470-
st_MessageQueue.nQueueSerial = st_UserKey.nKeySerial;
471-
_tcscpy(st_MessageQueue.tszQueueName, st_MQProtocol.tszMQKey);
472-
if (!DBModule_MQData_Query(&st_MessageQueue))
470+
while (TRUE)
473471
{
474-
pSt_ProtocolHdr->wReserve = 724;
475-
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
476-
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
477-
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("%s消息端:%s,主题:%s,序列:%lld,获取消息数据失败,无法继续,错误:%lX"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, st_MQProtocol.nSerial, DBModule_GetLastError());
478-
return FALSE;
472+
st_MessageQueue.nQueueSerial = st_UserKey.nKeySerial;
473+
_tcscpy(st_MessageQueue.tszQueueName, st_MQProtocol.tszMQKey);
474+
if (!DBModule_MQData_Query(&st_MessageQueue))
475+
{
476+
pSt_ProtocolHdr->wReserve = 724;
477+
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, &st_MQProtocol, tszSDBuffer, &nSDLen);
478+
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
479+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("%s消息端:%s,主题:%s,序列:%lld,获取消息数据失败,无法继续,错误:%lX"), lpszClientType, lpszClientAddr, st_MQProtocol.tszMQKey, st_MQProtocol.nSerial, DBModule_GetLastError());
480+
return FALSE;
481+
}
482+
//跳过定时任务
483+
if (_tcslen(st_MessageQueue.tszQueuePublishTime) > 0)
484+
{
485+
st_UserKey.nKeySerial++;
486+
continue;
487+
}
488+
//跳过过期任务
489+
if (_tcslen(st_MessageQueue.tszQueueLeftTime) > 0)
490+
{
491+
__int64x nTimeDiff = 0;
492+
TCHAR tszTimeEnd[128];
493+
memset(tszTimeEnd, '\0', sizeof(tszTimeEnd));
494+
495+
BaseLib_OperatorTime_TimeToStr(tszTimeEnd);
496+
BaseLib_OperatorTimeSpan_GetForStr(st_MessageQueue.tszQueueLeftTime, tszTimeEnd, &nTimeDiff, 3);
497+
if (nTimeDiff > 0)
498+
{
499+
st_UserKey.nKeySerial++;
500+
continue;
501+
}
502+
}
503+
break;
479504
}
480505
st_MQProtocol.nSerial = st_UserKey.nKeySerial;
481506
//移动序列号

0 commit comments

Comments
 (0)