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 » PCFeventmessage

Post new topic  Reply to topic
 PCFeventmessage « View previous topic :: View next topic » 
Author Message
anveshita
PostPosted: Tue Dec 28, 2004 9:57 am    Post subject: PCFeventmessage Reply with quote

Master

Joined: 27 Sep 2004
Posts: 254
Location: Jambudweepam

Can somebody help me how to step through PCFeventmessage in Java?
I tried using System.out.println( "Message: " + pcfeventmessage.toString());
But this dumps the whole message. what I a doing is to parse the message "Q_DEPTH_HIGH" in SYSTEM.ADMIN.PERFM.EVENT and gather the queue name which threw the message.
I also tried
PCFParameter p;
String name = null;
while (name == null)
{
p = PCFParameter.nextParameter (pcfeventmessage);

name = (String) p.getValue ();

}
This is giving 3013 error, which I do not have a clue what it is.
Please let me know
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Dec 28, 2004 10:21 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Can we see some more code?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
anveshita
PostPosted: Tue Dec 28, 2004 10:32 am    Post subject: Reply with quote

Master

Joined: 27 Sep 2004
Posts: 254
Location: Jambudweepam

I am trying to access local queue and passing the parms from command line. Here is the function that does the work I am hoping to do.
Code:
public void start(String args[]) { try {

   /******************************************************/
   /* Create a queue manager object and access the queue */
   /* that will be used for the putting of messages.     */
   /******************************************************/

   if (args.length > 1) {

      qMgr = new MQQueueManager(args[1]);



   } else { qMgr = new MQQueueManager(""); }

    int openOptions=8201;

   MQQueue mqqueue =   qMgr.accessQueue(args[0],
   openOptions, null, null, null);





   MQGetMessageOptions mqgetmessageoptions = new
   MQGetMessageOptions();

   mqgetmessageoptions.matchOptions = 0;
   mqgetmessageoptions.waitInterval = 333;

   mqgetmessageoptions.options = 8225;



   /***************************/ /* Set up a loop exit flag
   */ /***************************/ boolean flag = false;
   String evtype; int counter;



   try {

      int i = 0; while (true) {

         MQMessage mqmessage = new MQMessage();
         mqqueue.get(mqmessage,
         mqgetmessageoptions);
         System.out.println("Got an event
         message!"); SimpleDateFormat
         simpledateformat = new
         SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
         GregorianCalendar eventTime = ((MQMD)
         (mqmessage)).putDateTime; PCFMessage
         pcfeventmessage = new
         PCFMessage(mqmessage);

         



         



         switch (pcfeventmessage.getCommand()) {
         case CMQCFC.MQCMD_Q_MGR_EVENT : evtype =
         "QMGR EVENT"; break; case
         CMQCFC.MQCMD_PERFM_EVENT : evtype =
         "PERFORMANCE EVENT"; break; case
         CMQCFC.MQCMD_CHANNEL_EVENT : evtype =
         "CHANNEL EVENT"; break; default : evtype
         = "Unknown event type"; break; }
         System.out.println("evtype :  "+evtype);
         System.out.println(   "Message:  " +
         pcfeventmessage.toString());

         System.out.println(   "Parameters:  "
         + pcfeventmessage.getParameters());

      PCFParameter    p; String       name =
      null;

   while (name == null) { p = PCFParameter.nextParameter
   (pcfeventmessage); name = (String) p.getValue (); }

         



         i++;

      } } catch (Exception ex) {
      /***********************************************
      ***/ /* Probably encountered our no message
      available: */ /* write out error and mark loop
      to be exited     */
      /***********************************************
      ***/ //System.out.println("MQ exception: CC = "
      //      + ex.completionCode //      
      + " RC = " //      + ex.reasonCode);
      ex.printStackTrace(); flag = false;

   }

   mqqueue.close(); qMgr.disconnect();

} catch (Exception ex) { ex.printStackTrace(); }

}
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Dec 28, 2004 11:51 am    Post subject: Reply with quote

Grand High Poobah

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

Retrieve your message as a byte array. Instanciate a helper class with the byte array and retrieve the needed information from the helper class.
The helper class can then analyze the byte array and go after the exact parts (start, length) that is needed.

Enjoy
Back to top
View user's profile Send private message Send e-mail
anveshita
PostPosted: Tue Dec 28, 2004 12:55 pm    Post subject: Reply with quote

Master

Joined: 27 Sep 2004
Posts: 254
Location: Jambudweepam

Thanks fjb_saper,
Could you please provide a code snippet, if any?
Back to top
View user's profile Send private message
EddieA
PostPosted: Tue Dec 28, 2004 11:50 pm    Post subject: Reply with quote

Jedi

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

Here's a code snippet from a program that I have that works it's way through Event Messages. Hopefully it will be useful:
Code:
        if (mdFormat.equals(MQC.MQFMT_EVENT)) {
          System.out.println("");
          MQCFH cfh = new MQCFH (gotBody);
          System.out.println(InfoString("MQRC", cfh.reason));
          for (int i = 0; i < cfh.parameterCount; i++) {
            PCFParameter pcf = PCFParameter.nextParameter (gotBody);
            if (pcf instanceof MQCFIL) {
              System.out.println("Its a FIL");
            }
            else {
              if (pcf instanceof MQCFIN) {
                messageVars [0] = pcf.getValue();
                messageVars [1] = Integer.toHexString(((Integer)pcf.getValue()).intValue()).toUpperCase();
                DecodeParameter(pcf.getParameter(), messageVars);
              }
              else {
                if (pcf instanceof MQCFSL) {
                  System.out.println("Its a FSL");
                }
                else {
                  if (pcf instanceof MQCFST) {
                    messageVars [0] = pcf.getStringValue().trim();
                    DecodeParameter(pcf.getParameter(), messageVars);
                  }
                  else {
                    System.out.println("Unknown PCF type " + pcf.getType() + " encountered.");
                  };
                };
              };
            };
          }
        }

BTW. I'm a self taught Java guy (370 Assembler was my strength, which shows my age), so this my not be the best way of doing things.

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
Nigelg
PostPosted: Wed Dec 29, 2004 12:22 am    Post subject: Reply with quote

Grand Master

Joined: 02 Aug 2004
Posts: 1046

I have a program written in C which takes an byte stream input on stdin and interprets it as a PCF msg, if anybody is interested.
Back to top
View user's profile Send private message
anveshita
PostPosted: Wed Dec 29, 2004 7:55 am    Post subject: Reply with quote

Master

Joined: 27 Sep 2004
Posts: 254
Location: Jambudweepam

Thanks EddieA
I tried your code snippet.

if(mqmessage.format.equals(MQC.MQFMT_EVENT)){

MQCFH cfh = new MQCFH (mqmessage);
**** ***** ****
**** ***** ****
***** **** *****
}

I am getting 3001 error
Unable to load message catalog - mqji
com.ibm.mq.MQException: Completion Code 2, Reason 3001
at com.ibm.mq.pcf.MQCFH.initialize(MQCFH.java:138)
at com.ibm.mq.pcf.MQCFH.<init>(MQCFH.java:113)
at MyEventMonitor.start(MyEventMonitor.java:211)
at MyEventMonitor.main(MyEventMonitor.java:37)
Can you please let me know why?
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Dec 29, 2004 8:00 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Programmable Command Formats wrote:
3001 (X'0BB9') MQRCCF_CFH_TYPE_ERROR

Explanation: Type not valid.

The MQCFH Type field value was not valid.

Programmer Response: Specify a valid type.


EddieA, in his code, was passing in the body of the message... your code appears to be passing in the entire message...
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
anveshita
PostPosted: Wed Dec 29, 2004 8:10 am    Post subject: Reply with quote

Master

Joined: 27 Sep 2004
Posts: 254
Location: Jambudweepam

Thanks...
MQCFH constructor as per the documentation expects MQMessage as the parameter.Hence, I have passed
MQMessage insted of "gotBody".
Now if I have to pass message body, how do
I code this?
Back to top
View user's profile Send private message
EddieA
PostPosted: Wed Dec 29, 2004 10:27 am    Post subject: Reply with quote

Jedi

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

The 2 parameters into the routine are: (MQMessage gotBody, String mdFormat).

The 1st, as pointed out, is an MQMessage, the 2nd, a String containing the current message format. The full code does more than handle Events.

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
kirani
PostPosted: Wed Dec 29, 2004 10:57 am    Post subject: Reply with quote

Jedi Knight

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

There is a sample code that comes with SupportPac MS0B: MQSeries Java classes for PCF.
_________________
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
anveshita
PostPosted: Wed Dec 29, 2004 11:41 am    Post subject: Reply with quote

Master

Joined: 27 Sep 2004
Posts: 254
Location: Jambudweepam

Thanks Kirani.
I have started off with the exaples on PCF and no where it is mentioned wiaht what I am trying to do with EVENT messages. Please let me know if I am missing something here

Thanks EddieA.
I have coded similar to the way you have mentioned and I am still getting 3001 error.

I have modified the code as follow
Code:
if(mqmessage.format.equals(MQC.MQFMT_EVENT)){
   
   MQCFH cfh = new MQCFH (mqmessage);
   
   for ( i = 0; i < cfh.parameterCount; i++) {
           PCFParameter pcf = PCFParameter.nextParameter (mqmessage);
           if (pcf instanceof MQCFIL) {
            System.out.println("Its a FIL");
           }
           else {
            if (pcf instanceof MQCFIN) {
             // messageVars [0] = pcf.getValue();
             // messageVars [1] = Integer.toHexString(((Integer)pcf.getValue()).intValue()).toUpperCase();
             // DecodeParameter(pcf.getParameter(), messageVars);
             System.out.println("Its a FIN");
            }
            else {
              if (pcf instanceof MQCFSL) {
               System.out.println("Its a FSL");
              }
              else {
               if (pcf instanceof MQCFST) {
                // messageVars [0] = pcf.getStringValue().trim();
                 //DecodeParameter(pcf.getParameter(), messageVars);
                 System.out.println("Its a FST");
               }
               else {
                 System.out.println("Unknown PCF type " + pcf.getType() + " encountered.");
               }
              }
            }
           }
         }
        }


Let me tell about the mqmessage I am using here. It is the message I have browsed from SYSTEM.AMIN.PERFM.EVENT queue

Please let me know if some thing is missing in the above code
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 Discussion » PCFeventmessage
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.