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 IBM MQ Support » Problem of Version of Message Descriptor

Post new topic  Reply to topic
 Problem of Version of Message Descriptor « View previous topic :: View next topic » 
Author Message
Bahan
PostPosted: Mon Jul 17, 2006 12:06 am    Post subject: Problem of Version of Message Descriptor Reply with quote

Apprentice

Joined: 16 Jul 2006
Posts: 47
Location: France

Hi everyone.

I'm currently using MQseries on two servers. Let's call them Sender and Receiver.

On Sender, I send MQseries messages by using Java.
On Receiver, I receive messages by using the C language.

And I have a little problem. I can't get the message I sent.
All I have is a string of 3 elements : MDE
I don't really understand why...

If I use the following command :
Code:
./amqsbcg QUEUE QUEUEMANAGER


I can get my messages correctly. But by using the following functions in the C language :
Code:
MQCONN
MQOPEN
MQGET

etc...

Maybe is the problem coming from the two way I use to send and receive messages ? I don't really know what I can do.

Hope you can help me.

Thank you in advance.

Bahan
_________________
Close the world.||.txen eht nepO


Last edited by Bahan on Mon Jul 17, 2006 4:18 am; edited 2 times in total
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Jul 17, 2006 12:38 am    Post subject: Re: A question about MQseries working Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Bahan wrote:
I can't get the message I sent.


I really think we're going to need just a little more information than this! Things like what options you're using in your code in both C & Java, perhaps some examples, that sort of thing? You really havn't given us a lot to go on

Given that, it sounds like a a code bug someplace in the C code. If bcg can read a message it's been put correctly - I'd recommend you look at the bcg source code. Also be aware that if you're sending a message from Java to C you need to set TARGCLIENT to N in the Java to supress the JMS header.

(I'm not a Java programmer - RTM if you want an explaination! )

Failing that, provide us with some more details.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Bahan
PostPosted: Mon Jul 17, 2006 1:19 am    Post subject: Reply with quote

Apprentice

Joined: 16 Jul 2006
Posts: 47
Location: France

Hi, thank you for your quick answer.

Sorry for my confusion.

From the sender :
I'm using this code :

Code:
 MYJAVAPATH/java com.nmarque.mqseries.MQTrans -q:MYQMANAGER\\MYQLOCAL \
        -f:${MYDIRECTORY}/MYFILE -m:PutMove


Being not the author of this code and being only beginner with MQseries, I don't really know where I have to look for the parameter TARGCLIENT. It is on the Sender or on the Receiver that I have to look ?

On the receiver :

Code:
long RecMsg(
     MQHCONN lConnexion,
     MQHOBJ lObj,

     long lContinu= 1L;
     char szMsg[5000];      
     long lLngMsg= 5000;

     MQLONG lCodeComp= 0L;
     MQLONG lCodeDiag= 0L;
     MQGMO stDescGet   = {MQGMO_DEFAULT};
     MQMD stDescMsg   = {MQMD_DEFAULT};
     
     stDescGet.Options = MQGMO_FAIL_IF_QUIESCING;
     stDescGet.MatchOptions = MQMO_NONE;
     stDescGet.Version = MQGMO_VERSION_2;
     stDescGet.Options |= MQGMO_CONVERT;
     stDescGet.Options |= MQGMO_ACCEPT_TRUNCATED_MSG;

     printf ("\n*** Waiting loop for messages ***\n");

     while (lContinu == 1L)
     {
          stDescMsg.Encoding = MQENC_NATIVE;
          stDescMsg.CodedCharSetId = MQCCSI_Q_MGR;

          /* getting message */
          MQGET(lConnexion, lObj, &stDescMsg, &stDescGet, lLngMsgRecu, szMsgRecu, &lLngMsgRecu, &lCodeComp, &lCodeDiag);

          if ((lCodeDiag != 0L) && (lCodeDiag == MQRC_NO_MSG_AVAILABLE))
          {
   printf("Empty queue <%ld>!\n", MQRC_NO_MSG_AVAILABLE);
   lContinu = 0L;
          }
          else if (lCodeDiag != 0L)
          {
   printf("ERROR in Message Reception : [%ld]\n", lCodeDiag);
   lContinu = 0L;
           }
           else
           {
   printf("Message : [%s]", szMsg);
            }
     }

     printf("\n*** End of reception loop ***\n");
     return(lCodeComp);
}


I think it is not necessary to give you the connection code (MQCONN, MQOPEN), because, it works.

Is it less confusing like this ?

Bahan
_________________
Close the world.||.txen eht nepO


Last edited by Bahan on Mon Jul 17, 2006 1:34 am; edited 3 times in total
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Jul 17, 2006 1:31 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

As I said, TARGCLIENT needs to be set in the Java, i.e. on the send side.

As to the C, I think you need to have another look at your code. As an example, the loop control seems to be refered to as "lContinu" and "lContinuer". That's not the only example and I don't think that's helping.

You also want to look at the open options and the parameters for the MQGET call.
_________________
Honesty is the best policy.
Insanity is the best defence.


Last edited by Vitor on Mon Jul 17, 2006 2:54 am; edited 1 time in total
Back to top
View user's profile Send private message
Bahan
PostPosted: Mon Jul 17, 2006 1:33 am    Post subject: Reply with quote

Apprentice

Joined: 16 Jul 2006
Posts: 47
Location: France

Erf, excuse me for lContinuer.
That is, i'm french, so my variable name are french, and in order to be understandable for you, i try to translate my variables names ^_^.

Bahan
_________________
Close the world.||.txen eht nepO
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Jul 17, 2006 1:46 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Fair point & I'll forgive you. The compiler won't, and like I said it's not the only example. The other that stands out goes directly to the problem you're describing - the MQGET is loading a message buffer called szMsgRecu, but you're passing something called szMsg to printf.

Post the original code - I have a little French (even though I'm English ), and I know what the code is supposed to be doing to work it out I expect.

I still have doubts about the options as well.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Bahan
PostPosted: Mon Jul 17, 2006 2:10 am    Post subject: Reply with quote

Apprentice

Joined: 16 Jul 2006
Posts: 47
Location: France

Ok, here it is :

Code:
long RecevoirMessages(MQHCONN lConnexion, MQHOBJ lObj)
{
   int iNbMessage = 1;
   long lContinuer = 1L;
   long lCodeRetour = 0L;
   long lLngMsgRecu = 5000;
   char szMsgRecu[5000];
   MQLONG lCodeRetourMQ = 0;
   MQLONG lCodeDiag= 0;
   MQLONG MQGMO stDescGet= {MQGMO_DEFAULT};
   MQMD stDescMsg = {MQMD_DEFAULT};

   stDescGet.Options = MQGMO_FAIL_IF_QUIESCING;
   
   /* initialisation des variables */
   memset(szMsgRecu, '\0', sizeof(szMsgRecu));
   
   /* Pas de lecture selective du message => pas necessaire de reinit MsgID et CorrelID */
   stDescGet.MatchOptions = MQMO_NONE;
   stDescGet.Version = MQGMO_VERSION_2;

   /* Attente de 60s pour recevoir un message */
   stDescGet.Options |= MQGMO_WAIT;
   stDescGet.WaitInterval = 60;

   /* Get du message avec conversion si com entre machines heterogenes */
   stDescGet.Options |= MQGMO_CONVERT;

   /* Si le message est trop long pour le buffer, l'accepter tronque */
   stDescGet.Options |= MQGMO_ACCEPT_TRUNCATED_MSG;

   printf ("\n*** Boucle d'attente des messages ***\n");

   while (lContinuer == 1L)
   {
      stDescMsg.Encoding = MQENC_NATIVE;
      stDescMsg.CodedCharSetId = MQCCSI_Q_MGR;

      /*
      * Recuperation du message
      */
      MQGET(lConnexion, lObj, &stDescMsg, &stDescGet, lLngMsgRecu, szMsgRecu, &lLngMsgRecu, &lCodeRetourMQ, &lCodeDiag);

      if ((lCodeDiag != 0L) && (lCodeDiag == MQRC_NO_MSG_AVAILABLE))
      {
         printf("la file est vide <%ld>/<%ld>!\n", lCodeDiag, MQRC_NO_MSG_AVAILABLE);
         lCodeRetour = 90L;
         lContinuer = 0L;
      }
      else if (lCodeDiag != 0L)
      {
         printf("ERREUR Reception de message : [%ld]\n", lCodeDiag);
         lContinuer = 0L;
      }
      else
      {
         printf("\n########\nMessage recu %d : [%s]\n########\n", iNbMessage, szMsgRecu);
         iNbMessage++;
      }
   }

   printf("\n*** Sortie de la boucle de reception ***\n");
   return(lCodeRetour);
}


I'm currently reading the amqsbcg.c to see the MQGET options and others informations.

Bahan
_________________
Close the world.||.txen eht nepO
Back to top
View user's profile Send private message
Nigelg
PostPosted: Mon Jul 17, 2006 3:02 am    Post subject: Reply with quote

Grand Master

Joined: 02 Aug 2004
Posts: 1046

If a msg put with non-default MD v2 atributes is retrieved by an app specifying only a v1 MD, the msg is prepended with a MQMDE header containing the MD v2 values, followed by the msg data.
This will have the effect of displaying only the 3 chars MDE when printed as a string (actually 4, since there is a trailing space), because the next character is a NULL, which terminates the output.
In this case the receiving app is certainly supplying a v1 MD.
Add a line
Code:

stDescMsg.Version = 2;

before calling MQGET each time, where you set the Encoding and CCSID.
This will cause the msg to be retrieved with a v2 MD.

Alternatively, check for the presence of an MDE eyecatcher, and display the msg from (msgptr + sizeof(MQMDE)).
_________________
MQSeries.net helps those who help themselves..
Back to top
View user's profile Send private message
Bahan
PostPosted: Mon Jul 17, 2006 4:15 am    Post subject: Reply with quote

Apprentice

Joined: 16 Jul 2006
Posts: 47
Location: France

Thank you for your help.

Bahan
_________________
Close the world.||.txen eht nepO
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 » General IBM MQ Support » Problem of Version of Message Descriptor
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.