0
我正在使用websphere版本9並使用示例程序進行訂閱以訂閱主題。以下是我的代碼。我已將工作單元引入樣本。IBM Websphere MQ - MQGET不會從隊列中刪除郵件
問題是 - 在每個MQGET並提交隊列中的消息不會被清除之後。
有什麼想法?這與創建隊列的方式有關嗎?持久,耐用等。?
MQSUB(Hcon, /* connection handle */
&sd, /* object descriptor for queue */
&Hobj, /* object handle (output) */
&Hsub, /* object handle (output) */
&S_CompCode, /* completion code */
&Reason); /* reason code */
CompCode = S_CompCode; /* use MQOPEN result for initial test */
gmo.Options = MQGMO_WAIT /* wait for new messages */
| MQGMO_SYNCPOINT /* transaction */
| MQGMO_CONVERT; /* convert if necessary */
gmo.WaitInterval = MQWI_UNLIMITED;
while (CompCode != MQCC_FAILED)
{
buflen = sizeof(buffer) - 1; /* buffer size available for GET */
memcpy(md.MsgId, MQMI_NONE, sizeof(md.MsgId));
memcpy(md.CorrelId, MQCI_NONE, sizeof(md.CorrelId));
md.Encoding = MQENC_NATIVE;
md.CodedCharSetId = MQCCSI_Q_MGR;
/************************************************************************/
/* Start a unit of work */
/************************************************************************/
MQBEGIN (Hcon, &bo, &CompCode, &Reason);
MQGET(Hcon, /* connection handle */
Hobj, /* object handle */
&md, /* message descriptor */
&gmo, /* get message options */
buflen, /* buffer length */
buffer, /* message buffer */
&messlen, /* message length */
&CompCode, /* completion code */
&Reason); /* reason code */
/****************************************************************/
/* Display each message received */
/****************************************************************/
if (CompCode != MQCC_FAILED)
{
buffer[messlen] = '\0'; /* add terminator */
char* strings[] = {buffer};
bool client_commit_status = callback(strings);
if(client_commit_status){
MQCMIT(Hcon, &CompCode, &Reason);
if (MQCC_OK != CompCode){
MQBACK(Hcon, &CompCode, &Reason);
}
}else{
MQBACK(Hcon, &CompCode, &Reason);
}
}
你怎麼知道'MQCMIT()'被調用?什麼是'callback()'返回? 'MQCMIT()'失敗了,事務被回滾了嗎?一些'printf()'語句可以打印出'client_commit_status'的值,並顯示是否調用'MQBACK()'可以清除它。 – mhawke
我添加了'printf()'並確認MQCMIT正在被調用。我已經從發佈的代碼中刪除了它們,以減少行數。 – Muthukumar
好的,你是否還證實'MQBACK()'不被調用? – mhawke