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 » Retrieving MQ Headers other than MQMD

Post new topic  Reply to topic
 Retrieving MQ Headers other than MQMD « View previous topic :: View next topic » 
Author Message
cronydude
PostPosted: Fri Jul 18, 2003 11:04 pm    Post subject: Retrieving MQ Headers other than MQMD Reply with quote

Voyager

Joined: 11 Nov 2001
Posts: 85
Location: US

Hi folks,

How can we retrieve and separate headers like Tranmission Queue Header, Dead Letter Queue Header etc from the messages (in transmission queues and dead letter queues) programatically especially in java?

Any help is greatly appreciated....
_________________
Regs,
crony
IBM Certified Specialist - MQSeries
Back to top
View user's profile Send private message
EddieA
PostPosted: Tue Jul 22, 2003 8:50 am    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

As far as the application is concerned, these will be part of the payload.

So, you would need to check the MQMD Format to see what the 1st part of the payload is. If it's an MQ Header, then you would have to read the Format from that header, to see what the next piece is. Plus skip over the header. They all have either a fixed length, of a field that contains the length. And continue doing this until you get to the data you want.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
bduncan
PostPosted: Tue Jul 22, 2003 4:18 pm    Post subject: Reply with quote

Padawan

Joined: 11 Apr 2001
Posts: 1554
Location: Silicon Valley

Yes, if you look at the DeadLetterHandler program in the C++ section of the software repository, you'll see how it extracts the dead letter header from the MQMD in the fashion Eddie described...
_________________
Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator
Back to top
View user's profile Send private message Visit poster's website AIM Address
mqonnet
PostPosted: Wed Jul 23, 2003 8:11 am    Post subject: Reply with quote

Grand Master

Joined: 18 Feb 2002
Posts: 1114
Location: Boston, Ma, Usa.

This would be one of the very few times i gave up on a particular thing. As far as i can see, You CANNOT do this using Java. There are many reasons for this.

1) MQ support for java doesnt have something like cmqc.h to give you all the structure definitions.
2) Even if you tried to somehow make it up by yourself, the other issue that you would run into is arrays. Its not the same as in C/C++.
3) Parsing??? This is the 3rd most important issue. When you are using C/C++ structures that are using arrays, they are stored in the memory allocated to them when these were defined. Which meant, that any members of that structrue were using all of the space assigned to them. For example, you define char test[10], it would use all of 10 bytes of memory even if you have only "HI" in it as the value. Hence if you have two such data members in a class like, char test[10] followed by char test1[20] containing values "HI" and "HELLO", C/C++ looks them "as is". Because either language is looking at the actualy memory location, since these are pointers. As opposed to Java, where it is considered as a message "HIHELLO". Now how on earth would anyone figure out a way to parse them out. There is no way this is possible.

Moreover there are no methods that are supplied in either MA88 nor in 5.3 that would help you in this case.

The only solution that i think is possible even using java is calling the JNI interface. With which you write the parsing rule for the DLH structure in C/C++. Make it a dll. Call it from your java app.

Hope this helps.

Cheers
Kumar
Back to top
View user's profile Send private message Send e-mail Visit poster's website
EddieA
PostPosted: Wed Jul 23, 2003 2:09 pm    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Kumar,

I beg to differ on that. I've written a small Java program that I use to 'investigate' messages.

Currently it understands, and displays all the fields, from the MQMDE, MQXMIT, MQDLH, and MQRFH2. Plus, if it finds that the message is an MQEVENT, it displays what the event really is.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
syangloo
PostPosted: Wed Jul 23, 2003 4:34 pm    Post subject: Reply with quote

Centurion

Joined: 01 Oct 2002
Posts: 120
Location: Kuala Lumpur

Hi Eddie

Can you share you source code and some sample result to us?

Regards
Syangloo
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
mqonnet
PostPosted: Wed Jul 23, 2003 4:59 pm    Post subject: Reply with quote

Grand Master

Joined: 18 Feb 2002
Posts: 1114
Location: Boston, Ma, Usa.

Eddie, i am mystified too. If you can, share the code, you really got my curiosity level on the higher end.

In fact the only reason i was trying this was to add this code to the forums repository as many people have asked about it. Now you can do this for all of us.

Cheers
Kumar
Back to top
View user's profile Send private message Send e-mail Visit poster's website
EddieA
PostPosted: Thu Jul 24, 2003 7:06 am    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Here's a snippet of the code, where I break down the RFH2:

Code:

  public String DisplayRFH2(MQMessage gotMessage) throws IOException {

   String rfhStrucID = gotMessage.readString(4);
    int rfhVersion = gotMessage.readInt();
    int rfhStrucLength = gotMessage.readInt();
    int rfhEncoding = gotMessage.readInt();
    int rfhCodedCharSetId = gotMessage.readInt();
    String rfhFormat = gotMessage.readString(8);
    int rfhFlags = gotMessage.readInt();
    int rfhNameValueCCSID = gotMessage.readInt();

    gotMessage.characterSet = rfhNameValueCCSID;
//  gotMessage.characterSet = 437;               // #### Some combinations of JRE/MA88 blow up by reading too much

    int hdrOffset = gotMessage.getDataOffset();

    if (doHdrs.equalsIgnoreCase("yes") ||
        doHdrs.equalsIgnoreCase("rfh2")) {
      messageVars[0] = new String("MQRFH2");
      PrintMessage(14, messageVars);

      System.out.println();
      System.out.println("StrucId          : '" + rfhStrucID +"'");
      System.out.println("Version          : " + rfhVersion);
      System.out.println("StrucLength      : " + rfhStrucLength);
      System.out.println("Encoding         : " + rfhEncoding);
      System.out.println("CodedCharSetId   : " + rfhCodedCharSetId);
      System.out.println("Format           : '" + rfhFormat +"'");
      System.out.println("Flags            : " + new Format ("%-10i").format(rfhFlags) +
                         "(" + InfoString("MQRFH", rfhFlags) + ")");
      System.out.println("NameValueCCSID   : " + rfhNameValueCCSID);

      int lenPairs;
      String valuePairs;
      while (hdrOffset < rfhStrucLength) {
        lenPairs = gotMessage.readInt();
        valuePairs = gotMessage.readString(lenPairs);

        boolean didItParse = parseV(valuePairs);
        if (!didItParse) {
          System.out.println(InfoString("MQShowMSG", 23));
        }
        System.out.println("");
        hdrOffset += lenPairs + 4;
      };
      System.out.println();
      messageVars[0] = new String("MQRFH2");
      PrintMessage(15, messageVars);
      System.out.println();
    }
    else {
      hdrOffset = gotMessage.skipBytes(rfhStrucLength - hdrOffset);
    }

    gotMessage.encoding = rfhEncoding;
    gotMessage.characterSet = rfhCodedCharSetId;

    return rfhFormat;
  };


I did think about posting this, and a 'remote' runmqsc I have to the repository, but I couldn't see how too.

Plus, I am a little embarrassed about my code as my Java skills are very rudimentary.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
bower5932
PostPosted: Thu Jul 24, 2003 9:41 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

I don't think you can post to the repository. I've always sent my code to Brandon and he has put it out.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
mqonnet
PostPosted: Thu Jul 24, 2003 4:58 pm    Post subject: Reply with quote

Grand Master

Joined: 18 Feb 2002
Posts: 1114
Location: Boston, Ma, Usa.

Hmmm...

Thanks Eddie for sharing that piece of code. When i get a chance i shall try it out too.

Cheers
Kumar
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bduncan
PostPosted: Fri Jul 25, 2003 12:35 pm    Post subject: Reply with quote

Padawan

Joined: 11 Apr 2001
Posts: 1554
Location: Silicon Valley

Right... Eddie, feel free to email me anything you want posted to the repository (bduncan (AT) mqseries.net) and I'll add it for you. I just didn't want people to be adding things to the repository willy nilly since people are going to be downloading these things and executing them on their machines. The last thing I need is someone uploading a virus, so I screen everything before putting it out for general consumption.
_________________
Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator
Back to top
View user's profile Send private message Visit poster's website AIM Address
capmanoj8
PostPosted: Mon Nov 27, 2006 1:20 pm    Post subject: Looking for DLH reader code in Java Reply with quote

Newbie

Joined: 27 Nov 2006
Posts: 1

Can anyone please tell me where i can get sample java code that reads DLH specifically reason field value?
Back to top
View user's profile Send private message
EddieA
PostPosted: Mon Nov 27, 2006 2:09 pm    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Code:
  public String DisplayDLH(MQMessage gotMessage) throws IOException {

    String dlhStrucID = gotMessage.readString(4);
    int dlhVersion = gotMessage.readInt();
    int dlhReason = gotMessage.readInt();
    String dlhDestQName = gotMessage.readString(48);
    String dlhDestQMgrName = gotMessage.readString(48);
    int dlhEncoding = gotMessage.readInt();
    int dlhCodedCharSetId = gotMessage.readInt();
    String dlhFormat = gotMessage.readString(8);
    int dlhPutApplType = gotMessage.readInt();
    String dlhPutApplName = gotMessage.readString(28);
    String dlhPutDate = gotMessage.readString(8);
    String dlhPutTime = gotMessage.readString(8);

  }


Cheers.
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
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 » Retrieving MQ Headers other than MQMD
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.