Интеграция приложений на основе WebSphere MQ


Example.9.3 - часть 3


/* Open the target message queue for output */

od.Version = MQOD_VERSION_2 ;

od.RecsPresent = NumQueues ;

od.ObjectRecPtr = pOR;

od.ResponseRecPtr = pRR ;

O_options = MQOO_OUTPUT + MQOO_FAIL_IF_QUIESCING;

MQOPEN(Hcon, &od, O_options, &Hobj, &OpenCode, &Reason);

if (Reason == MQRC_MULTIPLE_REASONS)

{

print_responses("MQOPEN", pRR, NumQueues, pOR);

}

else

{

if (Reason != MQRC_NONE)

{

printf("MQOPEN returned CompCode=%d, Reason=%d\n", OpenCode, Reason);

}

}

/* Read message from the file

/* Loop until null line or end of file, or there is a failure */

CompCode = OpenCode; /* use MQOPEN result for initial test */

pmo.Version = MQPMO_VERSION_2 ;

pmo.RecsPresent = NumQueues ;

pmo.PutMsgRecPtr = pPMR ;

pmo.PutMsgRecFields = PutMsgRecFields ;

pmo.ResponseRecPtr = pRR ;

/* Put buffer to the message queue */

if (buflen > 0)

{

for( Index = 0 ; Index < NumQueues ; Index ++)

{

memcpy( (pPMR+Index)->MsgId, MQMI_NONE, sizeof((pPMR+Index)->MsgId));

memcpy( (pPMR+Index)->CorrelId, MQCI_NONE, sizeof((pPMR+Index)->CorrelId));

}

memcpy(md.Format, MQFMT_STRING, (size_t)MQ_FORMAT_LENGTH);

MQPUT(Hcon, Hobj, &md, &pmo, buflen, buffer, &CompCode, &Reason);

if (Reason == MQRC_MULTIPLE_REASONS)

{

print_responses("MQPUT", pRR, NumQueues, pOR);

}

else

{

if (Reason != MQRC_NONE)

{

printf("MQPUT returned CompCode=%d, Reason=%d\n", OpenCode, Reason);

}

}

tmr = time(NULL);

strcpy ( buf, ctime(&tmr));

buf[strlen(buf)-5]=0; // strip new line

printf("Distlist finish send message to list queue %s\n", buf);

}

else /* satisfy end condition when empty line is read */

CompCode = MQCC_FAILED;

//}

if (OpenCode != MQCC_FAILED)

{

C_options = 0;

MQCLOSE(Hcon, &Hobj, C_options, &CompCode, &Reason);

if (Reason != MQRC_NONE)

{

printf("MQCLOSE ended with reason code %d\n", Reason);

}

}

if (DisconnectRequired==True)

{

MQDISC(&Hcon, &CompCode, &Reason);




Начало  Назад  Вперед



Книжный магазин