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


Example.9.2 - часть 2


if (CompCode == MQCC_FAILED) { exit(Reason); }

O_options = MQOO_BROWSE + MQOO_INPUT_SHARED ;

MQOPEN(Hcon, &odR, O_options, &Hrep, &CompCode, &Reason);

if (Reason != MQRC_NONE) { printf("MQOPEN %s ended with reason code %ld\n", queue_reply, Reason); }

if (CompCode == MQCC_FAILED) { exit(Reason); }

O_options = MQOO_OUTPUT ;

MQOPEN(Hcon, &odP, O_options, &Hout, &CompCode, &Reason);

if (Reason != MQRC_NONE) { printf("MQOPEN %s ended with reason code %ld\n", queue_output, Reason); }

if (CompCode == MQCC_FAILED) { exit(Reason); }

while (CompCode == MQCC_OK)

{

buflen = sizeof(buffer) - 1;

memcpy(md.MsgId, MQMI_NONE, sizeof(md.MsgId));

memcpy(md.CorrelId, MQCI_NONE, sizeof(md.CorrelId));

gmo.Options = MQGMO_ACCEPT_TRUNCATED_MSG + MQGMO_WAIT + MQGMO_SYNCPOINT;

gmo.WaitInterval = 3000 ;

MQBEGIN (Hcon, &mbo, &CompCode, &Reason);

MQGET(Hcon, Hobj, &md, &gmo, buflen, buffer, &messlen, &CompCode, &Reason);

//if (Reason != MQRC_NONE) { printf("MQGET from %s ended with reason code %ld\n", queue_input, Reason); }

if ((CompCode == MQCC_OK) || (CompCode == MQCC_WARNING))

{

buffer[messlen] = '\0'; /* заносим символ конец строки в буфер с прочитанным сообщением */

buflen = messlen;

md.MsgType = MQMT_REQUEST;

md.Report = MQRO_EXCEPTION_WITH_DATA;

strncpy(md.ReplyToQ, queue_reply, MQ_Q_NAME_LENGTH);

memcpy(md.Format, MQFMT_STRING, MQ_FORMAT_LENGTH);

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

if (Reason != MQRC_NONE)

{

printf("MQPUT to %s ended ended unsuccessfully with reason code %ld CompCode %ld\n", queue_output, Reason, CompCode );

MQBACK( Hcon, &CompCode, &Reason ) ;

CompCode = MQCC_FAILED ;

}

else

{

while (CompCode != MQCC_FAILED)

{

/** осуществляется проверка queue_reply **/

gmo.Options = MQGMO_ACCEPT_TRUNCATED_MSG + MQGMO_WAIT ;

gmo.WaitInterval = 3000 ;

memcpy(md.MsgId, MQMI_NONE, sizeof(md.MsgId));




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



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