ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » Mainframe, CICS, TXSeries » Help with putting messages on queue using a C program

Post new topic  Reply to topic
 Help with putting messages on queue using a C program « View previous topic :: View next topic » 
Author Message
hakghen
PostPosted: Fri Nov 21, 2008 8:33 am    Post subject: Help with putting messages on queue using a C program Reply with quote

Newbie

Joined: 21 Nov 2008
Posts: 7

Hello friends,

Sorry for troubling you all but I'm getting deeply annoyed with a program I have to run here, into a CICS transaction, to put messages on a specific queue on websphere mq.

I have the following code compiled and already defined into CICS using the CEDA transaction.:

Code:
#include<stdio.h>                                     
#include<cmqc.h>                                       
                                                       
#define qName ".MAINFRAME.CONTEST.PART3"               
                                                       
#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_OUTPUT, &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);                                       
                                                         
 }                                                       


However, everytime I execute it into CICS (using the transaction to where it's defined), I get this output on the joblog:

Code:
Opening queue ZCON039.MAINFRAME.CONTEST.PART3
MQOPEN RC: 0                                 
Putting message 0                           
Message 0 MQRC: 2051                         


According to an ebook I got from IBM, this is something about MQPUT being Inhebit from the queue, but I don't have any idea how to fix that. I already had to fix somethings in this code, like changing the qname to the local queue (mainframe.contest.part3) and not the alias queue (mainframe.contest.putq), as it gave me the 2082 RC (invalid baseqname). If it's useful, below is the JCL I used to define the queues on Websphere:

Code:
//ZCDEFQ JOB MSGCLASS=H                                             
//* INSTRUCTIONS                                                     
//*                                                                 
//* BEFORE SUBMITTING THIS JCL IT IS NECESSARY TO TAILOR IT. REPLACE
//* THE FOLLOWING WITH APPROPRIATE VALUES:                           
//* &JOBPREFIX - THE PREFIX FOR THIS JOB                             
//* &USER      - THE USERID YOU ARE RUNNING UNDER                   
//*                                                                 
//DEFQ     EXEC PGM=CSQUTIL,PARM='MQ01'                             
//STEPLIB  DD DISP=SHR,DSN=WMQ.V600.SCSQANLE                         
//         DD DISP=SHR,DSN=WMQ.V600.SCSQAUTH                         
//OUTPUTA  DD SYSOUT=*                                               
//SYSPRINT DD SYSOUT=*                                               
//SYSIN    DD *                                                     
 COMMAND DDNAME(CMDINP)                                             
//CMDINP   DD *                                               
DEFINE QLOCAL(ZCON039.MAINFRAME.CONTEST.PART3) -               
MAXMSGL(10000) DEFPRTY(8) DEFPSIST(YES) PUT(DISABLED) REPLACE 
DEFINE QALIAS(ZCON039.MAINFRAME.CONTEST.PUTQ) -               
TARGQ(ZCON039.MAINFRAME.CONTEST.PART4) REPLACE                 
/*                                                             


Well, hope the info was useful. Thanks in advance!

[]'s!
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Nov 21, 2008 9:21 am    Post subject: Re: Help with putting messages on queue using a C program Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

hakghen wrote:
Hello friends,

Sorry for troubling you all but I'm getting deeply annoyed with a program I have to run here, into a CICS transaction, to put messages on a specific queue on websphere mq.

. If it's useful, below is the JCL I used to define the queues on Websphere:

Code:
//ZCDEFQ JOB MSGCLASS=H                                             
//* INSTRUCTIONS                                                     
//*                                                                 
//* BEFORE SUBMITTING THIS JCL IT IS NECESSARY TO TAILOR IT. REPLACE
//* THE FOLLOWING WITH APPROPRIATE VALUES:                           
//* &JOBPREFIX - THE PREFIX FOR THIS JOB                             
//* &USER      - THE USERID YOU ARE RUNNING UNDER                   
//*                                                                 
//DEFQ     EXEC PGM=CSQUTIL,PARM='MQ01'                             
//STEPLIB  DD DISP=SHR,DSN=WMQ.V600.SCSQANLE                         
//         DD DISP=SHR,DSN=WMQ.V600.SCSQAUTH                         
//OUTPUTA  DD SYSOUT=*                                               
//SYSPRINT DD SYSOUT=*                                               
//SYSIN    DD *                                                     
 COMMAND DDNAME(CMDINP)                                             
//CMDINP   DD *                                               
[quote]DEFINE QLOCAL(ZCON039.MAINFRAME.CONTEST.PART3) -               
MAXMSGL(10000) DEFPRTY(8) DEFPSIST(YES) PUT(DISABLED) REPLACE [/quote]
DEFINE QALIAS(ZCON039.MAINFRAME.CONTEST.PUTQ) -               
TARGQ(ZCON039.MAINFRAME.CONTEST.PART4) REPLACE                 
/*                                                             


Well, hope the info was useful. Thanks in advance!

[]'s!


OK let's look up this MQ setup for a minute. You'll have to fix it before any programing can take place.
  • Quote:
    DEFINE QALIAS(ZCON039.MAINFRAME.CONTEST.PUTQ) -
    TARGQ(ZCON039.MAINFRAME.CONTEST.PART4) REPLACE
    While it is nice to define an Alias queue (for authorizations purposes I presume) this does not automagically define the target queue. If the target queue does not exist this definition is worthless. If this definition should link to a cluster queue hosted by a different qmgr I'd rather have it in form of a remote queue than an alias queue.
  • Quote:
    DEFINE QLOCAL(ZCON039.MAINFRAME.CONTEST.PART3) -
    MAXMSGL(10000) DEFPRTY(8 ) DEFPSIST(YES) PUT(DISABLED) REPLACE

    This is a poor way of defining a queue and should not be used to change attributes. If you want to change put authorization on a queue use ALTER QL(QUEUENAME) PUT(ENABLED|DISABLED).
    A queue defined this way needs to be altered with put (enable) before any message can be delivered to it. And remember that for the base queue to accept the message put to the alias queue the base queue must be put enabled. You would generally control the attributes on the Alias queue. Use the base queue only if the attributes are to take effect on all alias queues (one change does it all)


Don't know how well staffed your MQ department is, but it sure looks like poor communications. Get more help from your MQ department. Right now it looks like you are shooting yourself into the foot.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
hakghen
PostPosted: Fri Nov 21, 2008 9:31 am    Post subject: Reply with quote

Newbie

Joined: 21 Nov 2008
Posts: 7

Hello, thanks for the answer

Althought I have understood it all, the problem is that I'm taking part into a mainframe contest-training held by IBM. All the participants have remote access to the mainframe and have to develop some tasks. The last task, is this one, put messages on a MQ queue using a C program onto CICS and, after, extracting these messages with another program.

As it were developed for users with no experience on mainframe, they meant to ask "simple" tasks (like me, this is my first contact with the mainframe).

So, I don't know if I have enough privileges to perform the steps advised... Could you put them into an ordered way or explain me a bit more of how doing it, so I can try here ASAP and post an answer (hopefully positive, so we can close the topic and move on =D)?

Thanks once again, I appreciate the help and attention!

[]'s!
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Nov 21, 2008 9:39 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

As a contest member you need to learn team play. If the task needs steps outside the field of expertise tested by the contest you need to get the right players to help you out. Find out who they are from the contest rules.

For the rest there is a great link at the top of this page labeled Info Center.
You should at least have the topics there about defining queues and such..
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
hakghen
PostPosted: Fri Nov 21, 2008 4:29 pm    Post subject: Reply with quote

Newbie

Joined: 21 Nov 2008
Posts: 7

Hello again,

Maybe I didn't expressed it very well, but we are accessing the mainframe remotely, so, the participants are all scatered and we don't have contact with each other and, also, IBM at this part closed the communications, they gave us a guide, an url referece (and this forum was also on their reference for the questions ) and we're supposed to contact them via e-mail only once after all tasks are done, see?

I tried talking to them about the queue definition on the JCL and they told me that it's sure to be that way, maybe because for us, starters, they just wanna give an intoduction, thus, making a simple code

I changed the PUT(DISABLED) to PUT(ENABLED) and managed to put some messages, but now I'm getting RC 2030 (maybe I'll have to fix the message lenght or state the MQMF_SEGMENTATION_ALLOWED somewhere on the code).

If possible, I'd appreciate very much a tip of where it must be specified

But anyway, thanks very much for the help! Sorry if I didn't express it all too good, but I'm brazillian and althought my english seems to be at least OK, I still have some hard time expressing what I really mean to =P

[]'s!
Back to top
View user's profile Send private message
bruce2359
PostPosted: Sat Nov 22, 2008 6:35 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

Quote:
but now I'm getting RC 2030

Did you look up ReasonCode 2030 in the WMQ Messages manual. 2030 means that the message your application is MQPUTting is too big to for the queue.

Alter Increase the maximum message length attribute of the queue definition. The entire message (length) includes your application data and MQMD.
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
hakghen
PostPosted: Sun Nov 23, 2008 2:50 pm    Post subject: Reply with quote

Newbie

Joined: 21 Nov 2008
Posts: 7

Hello once again,

I'm here to thank for all the help, I was able to fix the error, here's the correct output:

Code:
Opening queue ZCON039.MAINFRAME.CONTEST.PART3
MQOPEN RC: 0
Putting message 0
Message 0 MQRC: 0
Putting message 1
Message 1 MQRC: 0
Putting message 2
Message 2 MQRC: 0
Putting message 3
Message 3 MQRC: 0
Putting message 4
Message 4 MQRC: 0


Thanks once again!

[]'s!
Back to top
View user's profile Send private message
bruce2359
PostPosted: Sun Nov 23, 2008 2:58 pm    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

Quote:
I was able to fix the error

Please share with us what you did to fixed this?
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
hakghen
PostPosted: Sun Nov 23, 2008 3:43 pm    Post subject: Reply with quote

Newbie

Joined: 21 Nov 2008
Posts: 7

First I searched on the C code where was the definition of the messages length, then I found this:

Code:
 MQLONG msgLen[5] =                                   
 {                                                     
   100,                                               
   1000,                                               
   100000,                                             
   1000,                                               
   100                                                 
 };                                                   


The third message had a high ammount, and it was exactly on it where I was having the 2030 RC, so, I went to the queue definition JCL and modified this line:

Code:
DEFINE QLOCAL(ZCON039.MAINFRAME.CONTEST.PART3) -               
[b]MAXMSGL(10000)[/b] DEFPRTY(8) DEFPSIST(YES) PUT(ENABLED) REPLACE


to

Code:

DEFINE QLOCAL(ZCON039.MAINFRAME.CONTEST.PART3) -               
[b]MAXMSGL(100000)[/b] DEFPRTY(8) DEFPSIST(YES) PUT(ENABLED) REPLACE


But I didn't knew I could send MQ commands directly thru SDSF, so I edited and submitted the JCL again, but as you told me, I could use the ALTER INCREASE to change the values.

Well, that's everything

[]'s!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » Mainframe, CICS, TXSeries » Help with putting messages on queue using a C program
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.