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 Java / JMS » Java PCF code to return string constant of integer

Post new topic  Reply to topic
 Java PCF code to return string constant of integer « View previous topic :: View next topic » 
Author Message
tczielke
PostPosted: Fri Jun 05, 2015 11:55 am    Post subject: Java PCF code to return string constant of integer Reply with quote

Guardian

Joined: 08 Jul 2010
Posts: 939
Location: Illinois, USA

Does anyone know if the MQ Java PCF code has functionality to return the equivalent string constant value for a PCF integer field? For example, if I made a PCF call to get the queue attributes of Q1 that had a DEFPRESP(SYNC), then I would get returned to me the string "SYNC" instead of the integer 1 (1 is the numeric value for SYNC) for the DEFPRESP for Q1. I looked through the PCFMessage class documentation for Java, and I could not find any method that could do that. But just curious if that functionality is out there and I am missing it.
_________________
Working with MQ since 2010.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Jun 05, 2015 12:08 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

perhaps markt has something to say on this.
Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Fri Jun 05, 2015 12:22 pm    Post subject: Re: Java PCF code to return string constant of integer Reply with quote

Jedi Knight

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

tczielke wrote:
if I made a PCF call to get the queue attributes of Q1 that had a DEFPRESP(SYNC), then I would get returned to me the string "SYNC" instead of the integer 1 (1 is the numeric value for SYNC) for the DEFPRESP for Q1.

I don't believe so. If the field is an integer field (MQIACF_* vs MQCACF_*) then that is what you get. I haven't played with anything from MQ V8 but it would be interesting if it did.

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
markt
PostPosted: Sat Jun 06, 2015 4:01 am    Post subject: Reply with quote

Knight

Joined: 14 May 2002
Posts: 502

MQConstants.lookup(value,filter)

But you need to know which filter to apply. For example,
if the parameter is for MQIA_PM_DELIVERY, then you would have to know to use the filter "MQDLV_.*".
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sat Jun 06, 2015 7:50 am    Post subject: Reply with quote

Grand High Poobah

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

markt wrote:
MQConstants.lookup(value,filter)

But you need to know which filter to apply. For example,
if the parameter is for MQIA_PM_DELIVERY, then you would have to know to use the filter "MQDLV_.*".

Agreed. MQV8 is much better at this. Not all versions of MQ can handle this right. And then there is the case when the integer represents different options like for MQOO_ or MQGMO_ etc... I believe MQV8 has a function for this either in the PCFConstants or in the MQConstants. For earlier versions you will have to roll your own...

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
tczielke
PostPosted: Sat Jun 06, 2015 12:53 pm    Post subject: Reply with quote

Guardian

Joined: 08 Jul 2010
Posts: 939
Location: Illinois, USA

Thanks all for the information. I was asking because I recently wrote a C PCF client program to get information like queue attributes, channel attributes, etc. I wanted to be able to see the actual constant values that are returned(i.e. DEFPRESP(SYNC) instead of DEFPRESP(1) ) so I ended up writing some code to do that conversion for the PCF queue attributes, channel attributes, queue manager attributes and cluster queue manager attributes. However, it was very tedious to do. So I was hoping there might be an easier way to do it in Java. It sounds like there is a little more help with Java PCF programming, but not what I was hoping for.
_________________
Working with MQ since 2010.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sat Jun 06, 2015 7:20 pm    Post subject: Reply with quote

Grand High Poobah

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

Don't know how you'd do it in C but java reflection makes it quite easy.
The way it works:
Field name is being checked against the regular expression and the Field value is then being checked against the value passed (or the mask for options (bit check)).
The field name is being returned...

Hope this helps some.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
tczielke
PostPosted: Sun Jun 07, 2015 5:28 am    Post subject: Reply with quote

Guardian

Joined: 08 Jul 2010
Posts: 939
Location: Illinois, USA

fjb_saper wrote:
Don't know how you'd do it in C but java reflection makes it quite easy.
The way it works:
Field name is being checked against the regular expression and the Field value is then being checked against the value passed (or the mask for options (bit check)).
The field name is being returned...

Hope this helps some.


I am new to Java, so I need to do some more research to better understand what you said there. If you already had a code snippet that you would not mind sharing, that would be helpful .

Looking at my C code, I did not state exactly what I was looking for correctly. What I was really hoping for was some way in Java where you could just start with a MQCFIN instance (let's say an instance that holds the equivalent of a DEFPRESP of SYNC), and then with some method calls you would get returned to you that the MQCFIN.Parameter is a "DEFPRESP" and the MQCFIN.Value is "SYNC". I have written some C code that can do that for the PCF inquire queue, channel, etc. attributes, but it was very tedious to write.
_________________
Working with MQ since 2010.
Back to top
View user's profile Send private message
markt
PostPosted: Sun Jun 07, 2015 7:11 am    Post subject: Reply with quote

Knight

Joined: 14 May 2002
Posts: 502

Quote:
java reflection makes it quite easy.


Not really. Or at least, it doesn't really solve the problem Tim is asking about. The MQConstants.lookup() method is actually using reflection to generate the strings that get returned, so that bit is easy, but the fundamental point is that there is no inbuilt way to find which enumerated sets of constants are used by which object attributes. So if I want to get the possible strings associated with the DEFPSIST attribute of an object then MQConstants.lookup will help only if I also know that that associated enumerated set begin with "MQPER_". Otherwise I might be just doing a lookup of the number "1" - and you can see from cmq*.h just how many definitions have that value if there is no filter on the strings.
Code:

#define MQPER_PERSISTENCE_AS_PARENT    (-1)
#define MQPER_NOT_PERSISTENT           0
#define MQPER_PERSISTENT               1
#define MQPER_PERSISTENCE_AS_Q_DEF     2
#define MQPER_PERSISTENCE_AS_TOPIC_DEF 2

And in the DEFPSIST example, there's a further wrinkle in that the most appropriate string may depend on whether it's a queue or topic object...

In MS0P SupportPac I have the mqidecode program which is just a wrapper around the MQConstants.lookup method - you can play with that to see just how many definitions and duplicate/overlapping values that might apply. Simple example of a problem - what happens when you try to get the "platform" attribute.
Code:

C:\MS0P\mqidecode>mqidecode -p MQPL -v 1 -e
MQPL_MVS/MQPL_OS390/MQPL_ZOS

Several possibilities returned. Which may be equivalent in this case, but what should you print?

I am hoping that in "a future update to MQ" (to use a standard RFE response) there may be some example C code to help with this problem. Even though it will still may not solve it completely. But I'm not promising what might finally get from my personal directory into shipped product.

Formatting this stuff is very similar in Java and C; the benefit of Java is that you get the lookup function builtin. In C I had to write something comparable myself - which started as an awk script to generate tables out of cmq*.h. But in both my new C code and the older Java in MS0P that formats object attributes (eg configuration events) end up having blocks of switch statements to select the appropriate filter for each attribute.

I've also been writing up some of this to go into one of the presentations I'm doing at MQTC in September ... Try to give some of my experiences working with PCF.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sun Jun 07, 2015 8:49 am    Post subject: Reply with quote

Grand High Poobah

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

Hope this snippet helps...
Code:
StringBuffer sb = new StringBuffer();
//make this part of a class definition
Field[] mqcfields = MQConstants.class.getFields();

// lookup method starts here...
String fieldname;
// might have to unbox from Integer to int
Object fieldvalue
for (int i = 0; i < mqcfields.length; i++){
   //check if fieldname matches
   fieldname = mqcfields[i].getName();
   // input name  is a regex like "MQPER_.*"
   if (fieldname.matches(inputname){
       fieldvalue = mqcfields[i].get(null);
       classname = fieldvalue.getClass().getSimpleName();
       if (classname.equals("Integer")){
           fieldvalue = ((Integer)fieldvalue).intValue();
           // gets more complex here if you need to check for options
           // as you'd have to match byte per byte
           // like (((value & inputvalue) == value ) && value != 0)
           if (fieldvalue == inputvalue) {
               sb.append(fieldname);
               sb.append(" ");
           }
       }
   }
}
return sb.toString();

_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
tczielke
PostPosted: Mon Jun 08, 2015 4:19 am    Post subject: Reply with quote

Guardian

Joined: 08 Jul 2010
Posts: 939
Location: Illinois, USA

fjb_saper - Thanks for the code snippet.

markt - Thanks for the extra information. Also, looking forward to your PCF Programming session at MQTC.
_________________
Working with MQ since 2010.
Back to top
View user's profile Send private message
vsathyan
PostPosted: Fri Feb 12, 2016 10:56 pm    Post subject: Reply with quote

Centurion

Joined: 10 Mar 2014
Posts: 121

Hi tczielke,

If you want the MQSC output of the attributes, why dont you use the PCF 'ESCAPE' method?

Hope this helps.

Thanks,
vsathyan
_________________
Custom WebSphere MQ Tools Development C# & Java
WebSphere MQ Solution Architect Since 2011
WebSphere MQ Admin Since 2004


Last edited by vsathyan on Sat Feb 13, 2016 5:51 am; edited 2 times in total
Back to top
View user's profile Send private message
vsathyan
PostPosted: Fri Feb 12, 2016 11:12 pm    Post subject: Reply with quote

Centurion

Joined: 10 Mar 2014
Posts: 121

Sample code to dump queue manager data using my library

Code:

using CT.WMQ;

main()
{
    try
            {
                MQAgent mqa = new MQAgent(qmgrName, serverName, portNumber, channelName);
                if (mqa.IsConnected)
                {
                    mqa.DumpAllObjectData("C:\\Queue_Manager_Data.txt");
                }
                mqa.DisconnectFromQueueManager();
                MessageBox.Show("Dumping queue manager data complete");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
}

_________________
Custom WebSphere MQ Tools Development C# & Java
WebSphere MQ Solution Architect Since 2011
WebSphere MQ Admin Since 2004
Back to top
View user's profile Send private message
tczielke
PostPosted: Sat Feb 13, 2016 4:42 am    Post subject: Reply with quote

Guardian

Joined: 08 Jul 2010
Posts: 939
Location: Illinois, USA

Hi vsathyan,

Thanks for the information. Yes, the PCF ESCAPE approach would be a good way to go. My PCF inquiry program is currently written in C. I originally did this post as I was thinking of changing to a Java approach. Also, I didn't think the PCF ESCAPE approach was supported on z/OS, but I have found out later that it is but with a slightly different approach of doing it. Anyway, at this point, I will probably just stick with the C program and change it to use PCF ESCAPE for distributed and the z/OS way of doing the equivalent.

Thanks,
Tim
_________________
Working with MQ since 2010.
Back to top
View user's profile Send private message
vsathyan
PostPosted: Sat Feb 13, 2016 5:53 am    Post subject: Reply with quote

Centurion

Joined: 10 Mar 2014
Posts: 121

Hi tczielke,

Ok, thats nice.
Also i've updated / edited my previous post and removed the API download link. Thanks,

Regards,
vsathyan
_________________
Custom WebSphere MQ Tools Development C# & Java
WebSphere MQ Solution Architect Since 2011
WebSphere MQ Admin Since 2004
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 » IBM MQ Java / JMS » Java PCF code to return string constant of integer
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.