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


Example.9.3 - часть 2


NumQueues = 0;

while (queuenamelen != 0)

{

fgets(queue[NumQueues], 48, fptr);

queuenamelen = strlen(queue[NumQueues]) - 1;

queue[NumQueues][queuenamelen] = ' ';

NumQueues++;

}

}

fclose (fptr);

--NumQueues; /* NumQueues - Number of Queue name */

/* Allocate response records, object records and put message records */

pRR = (PMQRR)malloc( NumQueues * sizeof(MQRR));

pOR = (PMQOR)malloc( NumQueues * sizeof(MQOR));

pPMR = (pPutMsgRec)malloc( NumQueues * sizeof(PutMsgRec));

if((NULL == pRR) || (NULL == pOR) || (NULL == pPMR))

{

printf("%s(%d) malloc failed\n", __FILE__, __LINE__);

exit(4);

}

/* Use parameters as the name of the target queues */

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

{

strncpy( (pOR+Index)->ObjectName, queue[Index], (size_t)MQ_Q_NAME_LENGTH);

strncpy( (pOR+Index)->ObjectQMgrName, QManager, (size_t)MQ_Q_MGR_NAME_LENGTH);

}

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

{

MQCONN((pOR+Index)->ObjectQMgrName, &Hcon, &((pRR+Index)->CompCode), &((pRR+Index)->Reason));

if ((pRR+Index)->CompCode == MQCC_FAILED)

{

continue;

}

if ((pRR+Index)->CompCode == MQCC_OK)

{

DisconnectRequired = True ;

}

Connected = True;

break ;

}

/* Print any non zero responses */

print_responses("MQCONN", pRR, Index, pOR);

/* Print If failed to connect to queue manager then exit. */

if( False == Connected )

{

printf("Unable to connect to queue manager\n");

exit(3) ;

}

if ( (fp=fopen ("distlist.dat","r" )) == NULL )

{printf("Cannot open distlist.dat file" ); exit(2); }

else{

fgets(buffer, 100, fptr);

buflen = (MQLONG)strlen(buffer); /* length without null */

if (buffer[buflen-1] == '\n') /* last char is a new-line */

{

buffer[buflen-1] = '\0'; /* replace new-line with null */

--buflen; /* reduce buffer length */

}

}

fclose (fp);

tmr = time(NULL);

strcpy ( buf, ctime(&tmr));

buf[strlen(buf)-5]=0;

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




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



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