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 IndexGeneral IBM MQ Supportamqsget0 buffer

Post new topicReply to topic
amqsget0 buffer View previous topic :: View next topic
Author Message
John terry
PostPosted: Mon Jun 05, 2017 9:21 pm Post subject: amqsget0 buffer Reply with quote

Newbie

Joined: 05 Jun 2017
Posts: 1

I have a question, when I try to display the messages from the MQGET buffer I could get only the first string of the whole record.
for example:
Queue message:
JOHN 21 CALIFORNIA
SMITH 26 TEXAS

displayed message:
JOHN
SMITH

code used:
Code:
CompCode = OpenCode;
   while (more_msgs == 1 && CompCode != MQCC_FAILED)
   {
      md.BackoutCount = 0;
      buflen = sizeof(buffer) - 1;
      gmo.Options = MQGMO_SYNCPOINT
         + MQGMO_FAIL_IF_QUIESCING
         + MQGMO_WAIT
         + MQGMO_CONVERT;
      gmo.WaitInterval = 15000;

      memcpy(md.MsgId, MQMI_NONE, sizeof(md.MsgId));
      memcpy(md.CorrelId, MQCI_NONE, sizeof(md.CorrelId));

 MQGET(Hcon,
 Hobj,
 &md,
 &gmo,
 buflen,
 buffer,
 &messlen,
 &CompCode,
 &Reason);

/* report reason, if any */
 if (Reason != MQRC_NONE)
 {
 printf(Into reasoncode-1.\n);
if (Reason == MQRC_NO_MSG_AVAILABLE)
 {
 fprintf(fperror, No more messages.\n);
printf(No more messages.\n);
more_msgs = 0;
 break;
 }
 else
 {
 fprintf(fperror, MQGET ended with reason code %ld\n, Reason);
 printf(MQGET ended with reason code %ld\n, Reason);
 /* treat truncated message as a failure */
 if (Reason == MQRC_TRUNCATED_MSG_FAILED)
 {
 CompCode = MQCC_FAILED;
 }
 }
 } /* end of check Get return code */

/* Get the Quote Info from the message */

buffer[messlen] = \0; /* add terminator
 printf(message \n, buffer);
 }


please help me to resolve this.

thanks,
John
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Jun 05, 2017 10:12 pm Post subject: Reply with quote

Grand Poobah

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

John terry wrote:

Code:

/* Get the Quote Info from the message */

buffer[messlen] = \0; /* add terminator
 printf(message \n, buffer);
 


please help me to resolve this.

thanks,
John

I don't believe this line does what you think it does... This is where your error would be???
Should it not bee something like
Code:

// new display buffer
dbuffer= new buffer[buffer.length + 1];
memcopy (buffer, dbuffer);
dbuffer[dbuffer.length -1] = \0;
printf ("message \n", dbuffer);



_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
hughson
PostPosted: Tue Jun 06, 2017 4:40 pm Post subject: Reply with quote

Shaman

Joined: 09 May 2013
Posts: 730
Location: Bay of Plenty, New Zealand

Are you certain of the format of your messages on the queue.

If you use the amqsbcg sample it will browse them and print them out in hex so you can see what the separator character is between the 'sections'. It looks rather like you might have a null character between "JOHN" and "21" for example, when you are thinking it is something printable.

Cheers
Morag
_________________
Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
MQGem Software
Back to top
View user's profile Send private message Visit poster's website
rekarm01
PostPosted: Sun Jun 11, 2017 1:37 pm Post subject: Re: amqsget0 buffer Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1274

The code would be easier to read if it were indented. It also contains non-ASCII "smart" quotes, which C compilers should report as syntax errors.

John terry wrote:
Code:
buflen = sizeof(buffer) - 1;

How is buffer declared?

John terry wrote:
Code:
buffer[messlen] = '\0'; /* add terminator
 printf("message \n", buffer);
 }

This printf() statement is commented out, due to the missing comment terminator in the preceding line. Not only that, it's missing a format specifier (such as "%s"), so it wouldn't print out buffer anyway.

The posted code does not match the posted output, making it difficult to answer any questions about program behavior.
Back to top
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexGeneral IBM MQ Supportamqsget0 buffer
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.