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


Example.9.1 - часть 2


{

strcpy(QManager, ""); /* Работаем с менеджером очередей по умолчанию */

if ( (fptr=fopen ("rewriter.ini","r" )) == NULL )

{printf("Cannot open rewriter.ini file" ); exit(1); }

else{ /* Открываем ini-файл и присваиваем значения переменным */

fgets(queue1, 48, fptr);

queuenamelen = strlen(queue1) - 1;

queue1[queuenamelen] = ' ';

fgets(queue2, 48, fptr);

queuenamelen = strlen(queue2) - 1;

queue2[queuenamelen] = ' ';

fgets(logfilename, 48, fptr);

queuenamelen = strlen(logfilename) - 1;

logfilename[queuenamelen] = ' ';

tmr = time(NULL);

strcpy ( buf, ctime(&tmr));

buf[strlen(buf)-1]=0; // переход на новую строку

strncat (logfilename, buf,10);

strcpy(odG.ObjectName, queue1);

strcpy(odP.ObjectName, queue2);

fclose (fptr);

}

MQCONN(QManager, &Hcon, &CompCode, &CReason);

if (CompCode == MQCC_FAILED)

{

printf("MQCONN ended with reason code %ld\n", CReason);

exit(CReason);

}

O_options = MQOO_INPUT_SHARED + MQOO_FAIL_IF_QUIESCING;

MQOPEN(Hcon, &odG, O_options, &Hobj, &CompCode, &Reason); /* открываем очередь для чтения - &odG */

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

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

O_options = MQOO_OUTPUT + MQOO_FAIL_IF_QUIESCING;

MQOPEN(Hcon, &odP, O_options, &Hout, &CompCode, &Reason); /* открываем очередь для записи - &odP */

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

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

fp = fopen (logfilename,"a");

if ( fp==NULL ){ printf("Cannot open log file %s\n", logfilename); }

printf("Rewriter(C) sending messages from %s to %s and to log-file %s \n",odG.ObjectName, odP.ObjectName, logfilename);

/*****************************************************************************/

/* Читаем сообщения из QUEUE_INPUT и пишем в QUEUE_OUTPUT */




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



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