Author |
Message
|
notoneword |
Posted: Tue May 17, 2011 3:39 pm Post subject: Accessing Message Properties using MQMessage class |
|
|
 Apprentice
Joined: 17 May 2011 Posts: 37
|
Is there any way to access *ALL* message properties of a message (or at least all their names) using the MQMessage class? I thought I'd be able to do this w/o using JMS classes.
I've tried using getPropertyNames("%") hoping that that would return all the property names, but it doesn't seem to be working. Basically I need the java equivalent of MQINQMP in C. The docs say there is no equivalent, but there has to be some way to do this, right?
There's the get*Property methods, but you need to know both the type and name of the property to call those.
I know I'm missing something here, please, be the first to point out my stupidity!
.. any help would be appreciated, thanks! |
|
Back to top |
|
 |
mvic |
Posted: Tue May 17, 2011 4:39 pm Post subject: Re: Accessing Message Properties using MQMessage class |
|
|
 Jedi
Joined: 09 Mar 2004 Posts: 2080
|
Maybe there is a way, though I am not aware of it, personally.
What are you trying to achieve in your app, that has led to the requirement to enumerate the properties available in a message?
Why, for example, does your app not know the properties in its messages? |
|
Back to top |
|
 |
notoneword |
Posted: Tue May 17, 2011 5:16 pm Post subject: |
|
|
 Apprentice
Joined: 17 May 2011 Posts: 37
|
This is a general purpose message browser. So, it needs to be able to show what message properties a message contains, if any. Seems a strange thing to not be able to do in the Java API.
Is the only option to use the JMS objects? Or is that even an option when you're dealing with messages that may or may not have message properties? Thanks for the reply |
|
Back to top |
|
 |
notoneword |
Posted: Wed May 18, 2011 7:24 am Post subject: |
|
|
 Apprentice
Joined: 17 May 2011 Posts: 37
|
Hmm, I'm doing something else wrong though. Even when I call getPropertyNames, passing in the exact name of the property I know should be there, it's coming back empty. I bet there's an open/get message option that I'm missing. |
|
Back to top |
|
 |
markt |
Posted: Wed May 18, 2011 8:05 am Post subject: |
|
|
 Knight
Joined: 14 May 2002 Posts: 508
|
My messsage browser (for a forthcoming supportpac update) has something like this:
Code: |
gmo.options |= CMQC.MQGMO_PROPERTIES_IN_HANDLE; // override any PROPCTL setting on queue
inputQ.get(readMsg,gmo);
...
...
Enumeration props = null;
props = readMsg.getPropertyNames("%");
if (props != null) {
while (props.hasMoreElements()) {
String propName = (String) props.nextElement();
Object propObject = readMsg.getObjectProperty(propName);
String propValue = formatObject(propObject);
printf("\n %s \t: %s", propName,propValue);
}
}
|
It's possible that the fact I'm using newer MQ Java classes than you might make a difference, but you seem to be trying to use the right thing. |
|
Back to top |
|
 |
notoneword |
Posted: Wed May 18, 2011 8:35 am Post subject: |
|
|
 Apprentice
Joined: 17 May 2011 Posts: 37
|
Sweet! That gives me hope that it's possible to use the wildcard to access them all. So now, I just need to figure out what I'm doing wrong, but at least I"m on the right path! thanks! |
|
Back to top |
|
 |
notoneword |
Posted: Wed May 18, 2011 11:30 am Post subject: |
|
|
 Apprentice
Joined: 17 May 2011 Posts: 37
|
@markt: I don't suppose you could provide me details on what other (if any) GM options you're passing in could you? Maybe even the open options you're using on the queue? |
|
Back to top |
|
 |
notoneword |
Posted: Thu May 19, 2011 5:42 am Post subject: |
|
|
 Apprentice
Joined: 17 May 2011 Posts: 37
|
Ok, I've got this working now - I think there may have been issues with getting the right GMO values set. Now that I do getPropertyNames("%") does seem to work for querying all properties in a message. |
|
Back to top |
|
 |
mvic |
Posted: Thu May 19, 2011 5:54 am Post subject: |
|
|
 Jedi
Joined: 09 Mar 2004 Posts: 2080
|
notoneword wrote: |
there may have been issues with getting the right GMO values set. |
What GMO values did you set to make it work? |
|
Back to top |
|
 |
notoneword |
Posted: Thu May 19, 2011 5:59 am Post subject: |
|
|
 Apprentice
Joined: 17 May 2011 Posts: 37
|
As mentioned above by markt, MQGMO_PROPERTIES_IN_HANDLE works. I had been setting that (or thought I had) but it's possible my test script was passing in the wrong value. To be honest, I'm not sure what happened, I'd put this off to look at until today, then noticed in my logging that I was getting the properties back after some recent change, so I'm assuming it works now because I'm correctly setting MQGMO_PROPERTIES_IN_HANDLE. |
|
Back to top |
|
 |
|