|   | 
	 
  
    | 
RSS Feed - WebSphere MQ Support
 | 
RSS Feed - Message Broker Support
 |   
 
  
	     | 
	 | 
   
 
  
	|  fail to print the MQMD contents from router exit | 
	« View previous topic :: View next topic »  | 
   
  
  	
	  
		
		
		  | Author | 
		  Message
		 |  
		
		  | nilendu | 
		  
		    
			  
				 Posted: Wed Sep 20, 2006 2:39 am    Post subject: fail to print the MQMD contents from router exit | 
				     | 
			   
			 
		   | 
		 
		
		   Novice
 
 Joined: 14 Sep 2006 Posts: 16
  
  | 
		  
		    
			  
				Hi All,
 
 
 
I have written a message router exit.
 
The structure MQPXP that is passed to the exit funtion is PMQMD or pointer to the MQMD structure.
 
 
I would like to print the contents of the MQMD structure.
 
I could successfully print the variables of type long or integer, but failed to print the char/unsigned char variables.
 
 
for e.g:
 
 
following variables could be printed successfully:
 
 
   MQLONG    Offset;            /* Offset of data in physical message from start of logical message */
 
   MQLONG    MsgFlags;          /* Message flags */
 
   MQLONG    OriginalLength;    /* Length of original message */
 
 
 
But couldnt print the these variables:
 
 
   MQCHAR48  ReplyToQ;          /* Name of reply queue */
 
   MQCHAR48  ReplyToQMgr;       /* Name of reply queue manager */
 
   MQCHAR12  UserIdentifier;    /* User identifier */
 
   MQBYTE24  MsgId;             /* Message identifier */
 
 
 
On using memcopy or strcpy to copy the content of the struct to a local variable, I get an access violation error 'amqfcxba.exe has encountered a problem and need to close....'
 
And a blank values is returned if we try to print the contents directly:
 
 
fprintf(fp,"ReplyToQ %s",pExitParm->MsgDescPtr->ReplyToQ); 
 
 
 
 
 
Surprisingly I could print the 'char' variables that are part of the MQPXP 
 
structure.
 
 
i.e I could print the value of 'DestinationQMgrName' from the below struct but not 'PutDate'  
 
 
 
struct MQPXP {
 
.....
 
MQCHAR48  DestinationQMgrName;
 
PMQMD     MsgDescPtr;
 
.....
 
 
} 
 
 
struct MQMD {
 
....
 
MQCHAR8   PutDate;
 
....
 
}
 
 
 
 
 
 
 
Here is my exit code
 
 
void MQENTRY RoutingExit(PMQPXP pExitParm)
 
{
 
 
 MQCHAR48 ReplyToQ;
 
 
  
 
strcpy(ReplyToQ,pExitParm->MsgDescPtr->ReplyToQ);  //VIOLATION 
 
 
memcpy(ReplyToQ,pExitParm->MsgDescPtr->ReplyToQ,sizeof(MQCHAR48));
 
 
 fp =fopen("C:\\MESSAGEEXIT.TXT","w");
 
 
 fprintf(fp,"ReplyToQ %s",ReplyToQ);
 
 
 fprintf(fp,"DestinationQMgrName %s",pExitParm->DestinationQMgrName); /// PRINTED SUCCESSFULLY
 
 
 fclose(fp);
 
 
 
}
 
 
 
 
Has anyone tried to print the contents of the MQPXP struct?
 
What am I doing wrong?
 
Please advice...
 
 
thanks and regards,
 
Nilendu | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | jefflowrey | 
		  
		    
			  
				 Posted: Wed Sep 20, 2006 3:08 am    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		   Grand Poobah
 
 Joined: 16 Oct 2002 Posts: 19981
  
  | 
		  
		    
			  
				I wonder what print does if you send it a null value? _________________ I am *not* the model of the modern major general. | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | wschutz | 
		  
		    
			  
				 Posted: Wed Sep 20, 2006 4:08 am    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		    Jedi Knight
 
 Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired) 
  | 
		  
		    
			  
				character variables in MQMD are NOT null terminated strings ... strcpy will not work.... _________________ -wayne | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | nilendu | 
		  
		    
			  
				 Posted: Wed Sep 20, 2006 9:24 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		   Novice
 
 Joined: 14 Sep 2006 Posts: 16
  
  | 
		  
		    
			  
				Hi jefflowrey,
 
 
The contents of the variable is not null. I have tried with the following check as well
 
 
Please advice!!
 
 
if(pExitParm->MsgDescPtr->ReplyToQ!=NULL)
 
{
 
fprintf(fp,"NOT NULL");
 
fprintf(fp,"ReplyToQ %s",pExitParm->MsgDescPtr->ReplyToQ);  //I get a blank output.
 
}
 
 
 
Hi wschutz,
 
 
 
How about memcpy? Will that work?
 
 
Please advice!!!
 
 
regards,
 
Nilendu | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | wschutz | 
		  
		    
			  
				 Posted: Thu Sep 21, 2006 1:32 am    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		    Jedi Knight
 
 Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired) 
  | 
		  
		    
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | nilendu | 
		  
		    
			  
				 Posted: Fri Sep 22, 2006 3:29 am    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		   Novice
 
 Joined: 14 Sep 2006 Posts: 16
  
  | 
		  
		    
			  
				wschutz,
 
 
Thanks for your crisp and to the point answer.
 
 
regards,
 
Nilendu | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | 
		    
		   | 
		 
	   
	 | 
   
 
  
	     | 
	 | 
	Page 1 of 1 | 
   
 
 
 
  
  	
	  
		
		  
 
  | 
		  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
  | 
  		 
	   
	 | 
   
 
  	 | 
	  |