|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
  |
|
amqsget0 buffer |
View previous topic :: View next topic |
Author |
Message
|
John terry |
Posted: Mon Jun 05, 2017 9:21 pm Post subject: amqsget0 buffer |
|
|
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 |
|
 |
fjb_saper |
Posted: Mon Jun 05, 2017 10:12 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 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 |
|
 |
hughson |
Posted: Tue Jun 06, 2017 4:40 pm Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 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
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
rekarm01 |
Posted: Sun Jun 11, 2017 1:37 pm Post subject: Re: amqsget0 buffer |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
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 |
|
 |
|
|
  |
|
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
|
|
|
|