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 » General Discussion » New Line character in message. Need Help

Post new topic  Reply to topic
 New Line character in message. Need Help « View previous topic :: View next topic » 
Author Message
jjain76
PostPosted: Sun Dec 19, 2004 11:15 pm    Post subject: New Line character in message. Need Help Reply with quote

Newbie

Joined: 26 Apr 2004
Posts: 7

Hi All,
In MQ message we are receiving new line character in MQ Message. Message format is MQFMT_STRING at both sides(receiving and sending). When message is retrieived, message till new line character is retrieved. Rest is lost.
We need to retrieve the complete message including new line character.
Please help.
Back to top
View user's profile Send private message
kirani
PostPosted: Sun Dec 19, 2004 11:40 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Can you provide more information about your app? How do you know that the complete message is present in your input queue? Try using one of the existing program like amqsbcg to browse the queue. Is it possible that your program is reading the complete message but it's displaying only part of the message?
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
jjain76
PostPosted: Mon Dec 20, 2004 12:05 am    Post subject: Reply with quote

Newbie

Joined: 26 Apr 2004
Posts: 7

We have browsed the message using amqsbcg and therefore we came to know that in input queue complete message is present. As far as our application in concerned,we are reading the message as a string and then printing but it is showing message till new line character only.
Back to top
View user's profile Send private message
kirani
PostPosted: Mon Dec 20, 2004 12:21 am    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Can you post part of the code where you read and print your message?
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
jjain76
PostPosted: Mon Dec 20, 2004 12:59 am    Post subject: Reply with quote

Newbie

Joined: 26 Apr 2004
Posts: 7

/* set msgid to none */
memcpy(OlcParms.CtParm3.MsgID, MQMI_NONE, sizeof(OlcParms.CtParm3.MsgID));

/* set correlid to none */
memcpy(OlcParms.CtParm3.CorrelID, MQCI_NONE, sizeof(OlcParms.CtParm3.CorrelID));

/* Specify the get message option to retrieve the request
message from the request queue */
/* Subba : added MQGMO_ACCEPT_TRUNCATED_MSG option on 30-Aug-2002 */
OlcParms.CtParm3.Options = MQGMO_WAIT + MQGMO_SYNCPOINT + MQGMO_ACCEPT_TRUNCATED_MSG + MQGMO_CONVERT;

/* Set the wait interval to unlimited */
OlcParms.CtParm3.WaitInterval = MQWI_UNLIMITED;

WriteToLog(fp_log, "----------------------------\n",LVL1, iDbgMode, 0);

WriteToLog(fp_log, "Going Into Wait for Message\n", LVL1, iDbgMode, 1);

/* Added by subba for MQ Transaction */
CITIBEGN(&OlcParms.CtParm3.CtParm2.CtParm1);

WriteToLog(fp_log, "MQ Manager Begin option is set \n", LVL1, iDbgMode, 1);

/* Call CITIGET to retrieve the first available message from the In queue */
CITIGET(&OlcParms);


MQGET Function is as follows:

void CITIGET(PCTPARMS pCtPARMS)
{
MQMD msgDesc = {MQMD_DEFAULT};
MQGMO gmo = {MQGMO_DEFAULT};

/* MQGMO_CONVERT option requests that the application data */
/* in the message be converted before the data is copied. */
/* An exclusive OR, |, operation is performed here. */
gmo.Options = pCtPARMS->CtParm3.Options | MQGMO_CONVERT \
| MQGMO_FAIL_IF_QUIESCING;

gmo.WaitInterval = pCtPARMS->CtParm3.WaitInterval;

/* message descriptor structure describes the attributes of */
/* the message being sent. */
memcpy(msgDesc.MsgId,
pCtPARMS->CtParm3.MsgID,
MQ_MSG_ID_LENGTH);

memcpy(msgDesc.CorrelId,
pCtPARMS->CtParm3.CorrelID,
MQ_CORREL_ID_LENGTH);

MQGET(pCtPARMS->CtParm3.CtParm2.CtParm1.HConn,
pCtPARMS->CtParm3.CtParm2.HObj,
&msgDesc,
&gmo,
pCtPARMS->CtParm3.BuffLength,
pCtPARMS->ApplData,
&pCtPARMS->CtParm3.DataLength,
&pCtPARMS->CtParm3.CtParm2.CtParm1.CtStatus.APIComCode,
&pCtPARMS->CtParm3.CtParm2.CtParm1.CtStatus.APIReason);

pCtPARMS->CtParm3.Persistence = msgDesc.Persistence;

pCtPARMS->CtParm3.MsgType = msgDesc.MsgType;

memcpy(pCtPARMS->CtParm3.RepQName,
msgDesc.ReplyToQ,
MQ_Q_NAME_LENGTH);

memcpy(pCtPARMS->CtParm3.RepQMName,
msgDesc.ReplyToQMgr,
MQ_Q_MGR_NAME_LENGTH);

memcpy(pCtPARMS->CtParm3.MsgID,
msgDesc.MsgId,
MQ_MSG_ID_LENGTH);

memcpy(pCtPARMS->CtParm3.CorrelID,
msgDesc.CorrelId,
MQ_CORREL_ID_LENGTH);

memcpy(pCtPARMS->CtParm3.ApplIdentityData,
msgDesc.ApplIdentityData,
MQ_APPL_ID_LENGTH);

pCtPARMS->CtParm3.FeedBack = msgDesc.Feedback;

pCtPARMS->CtParm3.BackoutCount = msgDesc.BackoutCount;

pCtPARMS->CtParm3.Priorty = msgDesc.Priority;

memcpy(pCtPARMS->CtParm3.Reserved, msgDesc.PutApplName, MQ_PUT_APPL_NAME_LENGTH);

strncpy(pCtPARMS->CtParm3.Format, msgDesc.Format, MQ_FORMAT_LENGTH);
}
Back to top
View user's profile Send private message
newwmq
PostPosted: Mon Dec 20, 2004 1:40 am    Post subject: Reply with quote

Newbie

Joined: 07 Oct 2004
Posts: 8

What rubbish code. Where did you learn to program, off the back of a cornflakes packet? What is the point of the structures in structures and so on?
Anyway, where is the code where you print out the msg?
Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Mon Dec 20, 2004 8:59 am    Post subject: Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3264
Location: London, ON Canada

Quote:
Where did you learn to program, off the back of a cornflakes packet? What is the point of the structures in structures and so on?

If you don't know 'C', why stick your foot in your month. The beauty of C is that you pass around pointers (and pointers to pointers) and NOT globs of data like Java. And if I was in a code review session with you and you didn't do this, I'd fire your @ss back to the stone-age.

Attention newbies. If you don't know or understand a programming language, keep your stupid comments to yourself!!!!!!!!!!!!!!!

Now back to the real question.

jjain76, what is the value of pCtPARMS->CtParm3.BuffLength ?? When you used another tool to view the message (i.e. amqsbcg or a GUI tool) did see a binary zero ( x'00'). Hence, printf would terminate the string.

Regards,
Roger Lacroix
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
kirani
PostPosted: Mon Dec 20, 2004 11:46 am    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

As Roger said, most likely you have X'00' in your message after newline character.
Value into CtParm3.DataLength paramter will tell you how long the original MQ message is. I suggest that you print this value also.
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
csmith28
PostPosted: Mon Dec 20, 2004 3:52 pm    Post subject: Reply with quote

Grand Master

Joined: 15 Jul 2003
Posts: 1196
Location: Arizona

I ran into a similar problem trying to do a POC on sending messages larger than 4meg.

We were trying to create a 5meg file to put using the sample amqsput utility but it wouldn't send the file as one message. Every time it hit an End of Line it would break the file up into another message. So in stead of one 5meg message we had hundreds of smaller ones.
_________________
Yes, I am an agent of Satan but my duties are largely ceremonial.
Back to top
View user's profile Send private message
jjain76
PostPosted: Mon Dec 20, 2004 6:22 pm    Post subject: Reply with quote

Newbie

Joined: 26 Apr 2004
Posts: 7

The value of pCtPARMS->CtParm3.BuffLength is 6288 characters.
Message extract through amqsbcg "000001A0: 5445 5354 3031 0A0A 4355 5354 2052 4546 'TEST01..CUST REF'"
I am able to get the message till "TEST01" After that nothing. if you see the hex values are 0A that is ascii 10 for message terminating character.
amqsbcg utility syas that "length - 6288 bytes".
Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Mon Dec 20, 2004 10:08 pm    Post subject: Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3264
Location: London, ON Canada

Quote:
the hex values are 0A that is ascii 10 for message terminating character.

x'0A' is LineFeed.

It is time for you show us the code where you print out the message. Are you using printf? (Show the entire printf).

Regards,
Roger Lacroix
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
jjain76
PostPosted: Tue Dec 21, 2004 3:50 am    Post subject: Reply with quote

Newbie

Joined: 26 Apr 2004
Posts: 7

LOG(sInStr)
where LOG is defined as below


#define LOG(MSG) \
if ( zlMsgSeqNo >0 ) \
{ \
sprintf(sLogStr, "[%d]:%s", zlMsgSeqNo, MSG); \
WriteToLog(fp_log, sLogStr, LVL0, iDbgMode, 0); \
} \
else \
WriteToLog(fp_log, MSG, LVL0, iDbgMode, 0);

Its not only printing of message which is giving problem but while proceessing also data is incomplete.
Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Tue Dec 21, 2004 2:52 pm    Post subject: Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3264
Location: London, ON Canada

Hi,

We also need the code to WriteToLog().

Regards,
Roger Lacroix
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
kman
PostPosted: Mon Jan 10, 2005 12:24 am    Post subject: Reply with quote

Partisan

Joined: 21 Jan 2003
Posts: 309
Location: Kuala Lumpur, Malaysia

Disclaimer: Do not reply to topic as "What rubbish code"

I have a little piece of code here in C++ that I use to wrap around the text a file, so instead of sending smaller messages as in
Quote:
We were trying to create a 5meg file to put using the sample amqsput utility but it wouldn't send the file as one message. Every time it hit an End of Line it would break the file up into another message. So in stead of one 5meg message we had hundreds of smaller ones.


I called this program wraparound since that is what it did.

Code:
static char * sccsid = (char*) "@(#) wrapfile.cpp";
extern "C" {
#include <stdio.h>
#include <stdlib.h>
}
#include <iostream>
#include <fstream>
using namespace std;

inline string trim(const string& s) {
   if(s.length() == 0)
      return s;
   int b = s.find_first_not_of(" \t");
   int e = s.find_last_not_of(" \t");
   if(b == -1) // No non-spaces
      return "";
   return string(s, b, e - b + 1);
}

// *******************************************************************
// * main()
// *******************************************************************
void main(int agrc, char *argv[])
{
   int    buflen = 1;                 // Buffer length
   char  *buffer;
   const int sz = 1000;
   char buf[sz] = "";
   string sBuf;
   FILE *outFile;
   char *inputfile;
   char *outputfile;
      
   inputfile=argv[1];
   outputfile=argv[2];
   ifstream inFile(inputfile);
   if (!inFile) {
    cerr << "file could not be found\n";
   }
   if((outFile = fopen(outputfile, "w+")) == NULL)
     cerr << "Failed to open file for writing \n";

   while(inFile.getline(buf, sz)) {
      sBuf = trim(string(buf));
      buffer = (char*) sBuf.c_str();
      fprintf(outFile,buffer);
   }
   fflush(outFile);
   fclose(outFile);
   
}


I used this code to test sending big messages using the amqsput while reading off a big text file. Enjoy


p/s if there is need correction, please do so. Share with us.
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General Discussion » New Line character in message. Need Help
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.