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 » IBM MQ Performance Monitoring » Event Monitoring Using Java

Post new topic  Reply to topic
 Event Monitoring Using Java « View previous topic :: View next topic » 
Author Message
mandos_
PostPosted: Tue Jan 16, 2007 1:10 pm    Post subject: Event Monitoring Using Java Reply with quote

Novice

Joined: 17 Nov 2006
Posts: 17

Hail!

I was trying to learn about the analysis of event messages, but when I try to access the parameters from the message got from Event Queue, a java.io.UnsupportedEncodingException is trhow in runtime.

As the code shows:

Code:
package com.ivs.event;

import java.io.IOException;

import com.ibm.mq.MQC;
import com.ibm.mq.MQException;
import com.ibm.mq.MQGetMessageOptions;
import com.ibm.mq.MQMessage;
import com.ibm.mq.MQQueue;
import com.ibm.mq.MQQueueManager;
import com.ibm.mq.pcf.CMQC;
import com.ibm.mq.pcf.MQCFH;
import com.ibm.mq.pcf.PCFParameter;

public class EventMessageTest {

   public static void main(String[] args) {
      new EventMessageTest().go();
   }
   
   public void go(){
      try{
         MQQueueManager Qm = new MQQueueManager("QM1");
         MQQueue queue = Qm.accessQueue("SYSTEM.ADMIN.PERFM.EVENT", (MQC.MQOO_INPUT_AS_Q_DEF));
         MQMessage message = new MQMessage();
         MQGetMessageOptions gmo = new MQGetMessageOptions();
         queue.get(message, gmo);
         MQCFH cfh = new MQCFH(message);
         PCFParameter p;
         if (cfh.reason == CMQC.MQRC_Q_DEPTH_HIGH){
            String qname ="";
            for (int i = 0; i < cfh.parameterCount; i++){
               p = PCFParameter.nextParameter(message);
               if(p.getParameter() == CMQC.MQCA_Q_NAME){
                  qname = (String) p.getValue();
               }
            }
            System.out.println(qname);
         }
      }
      catch(MQException e){
         e.printStackTrace();
      }
      catch(IOException e){
         e.printStackTrace();
      }
      
   }

}


And the exception is:

Code:
java.io.UnsupportedEncodingException: Cp437
   at sun.io.Converters.getConverterClass(Unknown Source)
   at sun.io.Converters.newConverter(Unknown Source)
   at sun.io.ByteToCharConverter.getConverter(Unknown Source)
   at java.lang.StringCoding.decode(Unknown Source)
   at java.lang.String.<init>(Unknown Source)
   at java.lang.String.<init>(Unknown Source)
   at com.ibm.mq.MQMessage.readStringOfByteLength(MQMessage.java:758)
   at com.ibm.mq.pcf.MQCFST.initialize(MQCFST.java:176)
   at com.ibm.mq.pcf.MQCFST.<init>(MQCFST.java:142)
   at com.ibm.mq.pcf.PCFParameter.nextParameter(PCFParameter.java:117)
   at com.ibm.mq.pcf.PCFMessage.initialize(PCFMessage.java:512)
   at com.ibm.mq.pcf.PCFMessage.<init>(PCFMessage.java:100)
   at com.ivs.event.EventMessageTest.go(EventMessageTest.java:38)
   at com.ivs.event.EventMessageTest.main(EventMessageTest.java:23)


Anyone can help me and tell why this exception is throw? May the encoding of the message be wrong?

Thanks.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Jan 16, 2007 1:23 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

I would use the classes in the Support Pac MS0B instead of trying to write your own.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
mandos_
PostPosted: Tue Jan 16, 2007 6:19 pm    Post subject: Reply with quote

Novice

Joined: 17 Nov 2006
Posts: 17

I'm using the classes in the MS0B (Like PCFParameter and MQCFH)...

I'm just trying to ANALYZE an event message, and, as these messages came with parameters, i try using the same way as analyzing responses of an PCF command.

Have any other way to analyze an Event Message?

Thanks.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Jan 16, 2007 6:30 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981


_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Jan 17, 2007 5:18 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Okay. To redeem myself, I'm going to suggest you try two things.

  1. Code:
    qname = p.getStringValue();
  2. Code:
    PCFMessage pcf = new PCFMessage(message);
    qname = pcf.getStringParameterValue(CMQC.MQCA_Q_NAME);

_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Jan 17, 2007 5:56 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Man, I'm just not doing well here.

Neither of those will work - it's the BASE_Q_NAME.

This works for me.
Code:
if(p.getParameter() == CMQC.MQCA_BASE_Q_NAME){
                qname = p.getStringValue();;
               }

_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
mandos_
PostPosted: Wed Jan 17, 2007 8:23 am    Post subject: Reply with quote

Novice

Joined: 17 Nov 2006
Posts: 17

Thanks, jefflowrey!

But, when I try
Code:
PCFMessage pcf = new PCFMessage(message);

the same exception is trhow....

Code:
java.io.UnsupportedEncodingException: Cp437
   at sun.io.Converters.getConverterClass(Unknown Source)
   at sun.io.Converters.newConverter(Unknown Source)
   at sun.io.ByteToCharConverter.getConverter(Unknown Source)
   at java.lang.StringCoding.decode(Unknown Source)
   at java.lang.String.<init>(Unknown Source)
   at java.lang.String.<init>(Unknown Source)
   at com.ibm.mq.MQMessage.readStringOfByteLength(MQMessage.java:758)
   at com.ibm.mq.pcf.MQCFST.initialize(MQCFST.java:176)
   at com.ibm.mq.pcf.MQCFST.<init>(MQCFST.java:142)
   at com.ibm.mq.pcf.PCFParameter.nextParameter(PCFParameter.java:117)
   at com.ibm.mq.pcf.PCFMessage.initialize(PCFMessage.java:512)
   at com.ibm.mq.pcf.PCFMessage.<init>(PCFMessage.java:100)
   at com.ivs.event.EventMessageTest.go(EventMessageTest.java:30)
   at com.ivs.event.EventMessageTest.main(EventMessageTest.java:20)


Where (EventMessageTest.java:30) is the line PCFMessage pcf = new PCFMessage(message)...

I was thinking that the encoding is wrong... but... Why?

Can you show your code to me to test?

Thanks.
Back to top
View user's profile Send private message
mandos_
PostPosted: Wed Jan 17, 2007 8:55 am    Post subject: Reply with quote

Novice

Joined: 17 Nov 2006
Posts: 17

Just for knowledge:

The SupportPack mo01 (http://www-1.ibm.com/support/docview.wss?uid=swg24000676) when I try to execute it, trhow the same exception (java.io.UnsupportedEncodingException: Cp437)...

May it be a wrong MQ Configuration?
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Jan 17, 2007 9:16 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

It is probably some kind of wrong MQ configuration. It could potentially be a path/classpath issue, but it's not as likely.

The new PCFMessage code doesn't work at all - event messages aren't castable as PCFMessage objects, I guess.

The code I got working is the same as yours, except I called getStringValue rather than getValue.

You do have a full, proper, MQ install on the machine you're using, right?
From what you've coded, I would expect that QM1 is a local queue manager.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Jan 17, 2007 3:50 pm    Post subject: Reply with quote

Grand High Poobah

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

It might just take the encoding from the request message. Make sure the encoding has a correct value by using the litterals. Remember the encoding field can take any int value but only a few make sense.

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Wed Jan 17, 2007 4:11 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

fjb_saper wrote:
It might just take the encoding from the request message.


Except he's reading Event Messages, not PCF Response messages.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Jan 17, 2007 4:25 pm    Post subject: Reply with quote

Grand High Poobah

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

jefflowrey wrote:
fjb_saper wrote:
It might just take the encoding from the request message.


Except he's reading Event Messages, not PCF Response messages.

Not the right version? Displacement in the header ??

An encoding error message sounds strange here...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Wed Jan 17, 2007 4:27 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

My thought is that the character conversion tables aren't available somehow.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
mandos_
PostPosted: Thu Jan 18, 2007 10:28 am    Post subject: Reply with quote

Novice

Joined: 17 Nov 2006
Posts: 17

Hail!

I have found the problem...

Strangely it was the Java Version... I was running my code with the JRE 1.5 Update 9 and the problem always occurred.

When I ran the code in another PC (JRE 1.5 Update 8) It works fine...

Then, as I already have installed the JRE1.5 Update 10, I have tried to run with this one... And it works!!!!

Probably the problem was that, the java Version. If you want, try to run with the Update 9 and tell me if the problem occurs.

Thanks, anyway!
Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Sun Jan 21, 2007 10:24 am    Post subject: Reply with quote

Jedi Knight

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

mandos_ wrote:
Strangely it was the Java Version... I was running my code with the JRE 1.5 Update 9 and the problem always occurred.

I would guess that you download the USA / English only version and not the international version of the JRE, as I have had similar problems before.

Regards,
Roger Lacroix
Capitalware Inc.
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Performance Monitoring » Event Monitoring Using Java
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.