简体   繁体   中英

retrieve property values from message broker bar file with java api

I'm trying to read the property values from a bar file created by message broker.

I want to do this via java. The api is here: http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Fbe43410_.htm

However, I can only figure out how to get the names of the properties NOT THEIR VALUES by using the deployment descriptor. I can see how to override the value that a property has, but once again, not how to retrieve the value. Another words I can see only how to write to the property not read from it. I want to do both! Call me greedy ;)

If I use the command line based utility: http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Faf03900_.htm I can get the property values no problem.

But I want to get them via java if at all possible.

Thanks in advance for any help on this!

For some reason settings are not written to file, if they are not overriden or not changed.(the reason is the lack of necessity to keep the property's default value:) ) so the way to get the properties is to know their default values. But I would recommend you to use com.ibm.mq.jar library if you're able to connect to broker to read properties using method

java.util.Properties MessageFlowProxy.Node.getProperties()

from already deployed .bar.

The problem was I was misunderstanding how the deployment descriptor worked. I thought that when the java API referred to overridden properties it meant ones that were over ridden in my java code. But it actually meant all the properties that had a value in the bar file.

That being said getting the values is not strait forward. You have to get all the identifiers and then pass them to getOverride();

BarFile b = BarFile.loadBarFile("C:\\BarParamTest\\myBar.bar");
DeploymentDescriptor d =  b.getDeploymentDescriptor();

Enumeration<String> properties = d.getPropertyIdentifiers();

while(properties.hasMoreElements())
{
    String p = properties.nextElement();
    System.out.println(p + " = " + d.getOverride(p));
}

or use the following to only list properties that have values

Enumeration<String> properties = d.getOverriddenPropertyIdentifiers();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM