I'm having to compile a program here (C) that, when used by a CICS transaction, will put some messages on the MQ, to, moreafter, extract them using another program, also in C. However, after I compile and define the transactions, i'm getting a MQOPEN RC (Reason Code) on the joblog, telling me this:
0024TPUT 20081116213714 UserID :ZCON039:
0024TPUT 20081116213714 Opening queue ZCON039.MAINFRAME.CONTEST.PUTQ
0024TPUT 20081116213714 MQOPEN RC: 2082
0024TPUT 20081116213714 Opening queue ZCON039.MAINFRAME.CONTEST.PUTQ
0024TPUT 20081116213714 MQOPEN RC: 2082
The source for the C program to put the messages is this as follows, I have to modify something to make it work and came here to ask some help if possible:
#include<stdio.h>
#include<cmqc.h>
#define qName ".MAINFRAME.CONTEST.PUTQ"
#define MsgCount 5
MQLONG persistence[5] =
{
MQPER_NOT_PERSISTENT,
MQPER_PERSISTENCE_AS_Q_DEF,
MQPER_PERSISTENT,
MQPER_PERSISTENT,
MQPER_NOT_PERSISTENT
};
MQLONG syncpoint[5] =
{
MQPMO_NO_SYNCPOINT,
MQPMO_SYNCPOINT,
MQPMO_SYNCPOINT,
MQPMO_NO_SYNCPOINT,
MQPMO_SYNCPOINT
};
MQLONG priority[5] =
{
0,
MQPRI_PRIORITY_AS_Q_DEF,
7,
0,
0
};
MQLONG msgLen[5] =
{
100,
1000,
100000,
1000,
100
};
int PutMessages(MQHCONN, MQHOBJ);
int main(int argc, char** argv)
{
MQOD myOD = {MQOD_DEFAULT};
MQHOBJ myOBJ;
MQHCONN myHConn;
MQLONG mqcc, mqrc;
char* pUser;
int retcode;
myHConn = MQHC_DEF_HCONN;
pUser = USERID;
printf("UserID :%s:\n", pUser);
myOD.ObjectType = MQOT_Q;
strcpy(myOD.ObjectName, pUser);
memcpy(myOD.ObjectName+strlen(pUser), qName, strlen(qName));
printf("Opening queue %s\n", myOD.ObjectName);
MQOPEN(myHConn, &myOD, MQOO_INPUT_SHARED, &myOBJ, &mqcc, &mqrc);
printf("MQOPEN RC: %d\n", mqrc);
if( mqrc != MQRC_NONE )
exit(3);
retcode = PutMessages(myHConn, myOBJ);
return(retcode);
}
int PutMessages(MQHCONN hConn, MQHOBJ hObj)
{
int iMsg;
MQMD myMD = {MQMD_DEFAULT};
MQPMO myPMO = {MQPMO_DEFAULT};
MQLONG mqcc, mqrc;
char* pBuffer;
int retcode;
retcode = 0;
pBuffer = (char*)malloc(100000);
if( pBuffer == NULL )
{
printf("unable to allocate buffer\n");
exit(21);
}
for( iMsg = 0; iMsg < MsgCount; iMsg++ )
{
printf("Putting message %d\n", iMsg);
myMD.Persistence = persistence[iMsg];
myMD.Priority = priority[iMsg];
memset( myMD.MsgId, 0, MQ_MSG_ID_LENGTH);
memset( myMD.CorrelId, 0, MQ_CORREL_ID_LENGTH);
myPMO.Options = syncpoint[iMsg];
memset(pBuffer, 0, 100000);
sprintf(pBuffer, "Message %d Length %d", iMsg, msgLen[iMsg]);
MQPUT(hConn, hObj, &myMD, &myPMO, msgLen[iMsg], pBuffer,
&mqcc, &mqrc);
printf("Message %d MQRC: %d\n", iMsg, mqrc);
retcode = (int)mqrc;
if( mqrc != MQRC_NONE )
{
EXEC CICS SYNCPOINT ROLLBACK;
break;
}
}
return(retcode);
}
#include<cmqc.h>
#define qName ".MAINFRAME.CONTEST.PUTQ"
#define MsgCount 5
MQLONG persistence[5] =
{
MQPER_NOT_PERSISTENT,
MQPER_PERSISTENCE_AS_Q_DEF,
MQPER_PERSISTENT,
MQPER_PERSISTENT,
MQPER_NOT_PERSISTENT
};
MQLONG syncpoint[5] =
{
MQPMO_NO_SYNCPOINT,
MQPMO_SYNCPOINT,
MQPMO_SYNCPOINT,
MQPMO_NO_SYNCPOINT,
MQPMO_SYNCPOINT
};
MQLONG priority[5] =
{
0,
MQPRI_PRIORITY_AS_Q_DEF,
7,
0,
0
};
MQLONG msgLen[5] =
{
100,
1000,
100000,
1000,
100
};
int PutMessages(MQHCONN, MQHOBJ);
int main(int argc, char** argv)
{
MQOD myOD = {MQOD_DEFAULT};
MQHOBJ myOBJ;
MQHCONN myHConn;
MQLONG mqcc, mqrc;
char* pUser;
int retcode;
myHConn = MQHC_DEF_HCONN;
pUser = USERID;
printf("UserID :%s:\n", pUser);
myOD.ObjectType = MQOT_Q;
strcpy(myOD.ObjectName, pUser);
memcpy(myOD.ObjectName+strlen(pUser), qName, strlen(qName));
printf("Opening queue %s\n", myOD.ObjectName);
MQOPEN(myHConn, &myOD, MQOO_INPUT_SHARED, &myOBJ, &mqcc, &mqrc);
printf("MQOPEN RC: %d\n", mqrc);
if( mqrc != MQRC_NONE )
exit(3);
retcode = PutMessages(myHConn, myOBJ);
return(retcode);
}
int PutMessages(MQHCONN hConn, MQHOBJ hObj)
{
int iMsg;
MQMD myMD = {MQMD_DEFAULT};
MQPMO myPMO = {MQPMO_DEFAULT};
MQLONG mqcc, mqrc;
char* pBuffer;
int retcode;
retcode = 0;
pBuffer = (char*)malloc(100000);
if( pBuffer == NULL )
{
printf("unable to allocate buffer\n");
exit(21);
}
for( iMsg = 0; iMsg < MsgCount; iMsg++ )
{
printf("Putting message %d\n", iMsg);
myMD.Persistence = persistence[iMsg];
myMD.Priority = priority[iMsg];
memset( myMD.MsgId, 0, MQ_MSG_ID_LENGTH);
memset( myMD.CorrelId, 0, MQ_CORREL_ID_LENGTH);
myPMO.Options = syncpoint[iMsg];
memset(pBuffer, 0, 100000);
sprintf(pBuffer, "Message %d Length %d", iMsg, msgLen[iMsg]);
MQPUT(hConn, hObj, &myMD, &myPMO, msgLen[iMsg], pBuffer,
&mqcc, &mqrc);
printf("Message %d MQRC: %d\n", iMsg, mqrc);
retcode = (int)mqrc;
if( mqrc != MQRC_NONE )
{
EXEC CICS SYNCPOINT ROLLBACK;
break;
}
}
return(retcode);
}
Well, hope this information helps.
Thanks once again for all the help in advance!
[]'s,
Andre Luiz