使用配置管理器管理代理域

开始之前

在开始本主题之前,您必须已完成使用配置管理器连接至配置管理器

使用 CMP 可能会更改域中对象的状态,即创建、删除、修改和部署存储在配置管理器内的对象。下列示例试图设置称为 B1 的代理的详细描述字段:
import com.ibm.broker.config.proxy.*;
public class SetLongDescription {
public static void main(String[] args) {
ConfigManagerProxy cmp = null;
try {
ConfigManagerConnectionParameters cmcp =
new MQConfigManagerConnectionParameters(
"localhost",
1414,
"");
cmp = ConfigManagerProxy.getInstance(cmcp);
} catch (ConfigManagerProxyException cmpex) {
System.out.println("Error connecting: "+cmpex);
}
if (cmp != null) {
System.out.println("Connected to Config Manager!");
describeBroker(cmp, "B1", "this is my broker");
cmp.disconnect();
}
}
private static void describeBroker(ConfigManagerProxy cmp,
String brokerName,
String newDesc)
{
	BrokerProxy b = null;
try {
TopologyProxy topology = cmp.getTopology();
if (topology != null) {
b = topology.getBrokerByName(brokerName);
}
} catch(ConfigManagerProxyPropertyNotInitializedException
ex) {
System.err.println("Comms problem! "+ex);
}
if (b != null) {
try {
b.setLongDescription(newDesc);
} catch (ConfigManagerProxyException ex) {
	System.err.println("Could not send request to CM: "+ex);
}
} else {
System.err.println("Broker "+brokerName+" not found");
}
}
}
通过要求配置管理器修改代理 B1 的(键, 值)属性来使用 setLongDescription() 方法,其中键的名称表示详细描述标记,而值为新的详细描述。所以调用 setLongDescription() 的备用项是:
Properties p = new Properties();
p.setProperty(AttributeConstants.LONG_DESCRIPTION_PROPERTY,
newDesc);
b.setProperties(p);
当更改属性的请求发送至配置管理器时,在配置管理器报告其属性复本已成功更改之前,CMP 的内部属性表不会更新。这样做是为了保持所有信息副本的一致性。该过程如下所示。


请注意,如果当前用户没有必需的权限,则当使用 SetLongDescription.java 时,不可能确定是否 配置管理器 拒绝了请求。 如果,且仅当执行操作的消息无法发送至配置管理器时,设置详细描述字段的 CMP 方法才抛出 ConfigManagerProxyException。这表示从程序的输出完全一样,即便配置管理器无法更改必需属性也是如此。

这样做的原因是配置管理器异步处理来自 CMP 的请求,因此在配置管理器上执行该操作之前,理论上可能有很多时间。 如果方法(如本主题中描述的一个方法)未在完成代码可用之前返回对程序的控制,则 CMP 应用程序的执行将完全取决于配置管理器执行。

下一步:

多数更改状态的 CMP 方法设计为不通知调用应用程序请求的结果而直接返回。要找到这些信息,请参阅使用配置管理器代理检查代理域管理的结果

相关任务
配置用于开发和运行配置管理器应用程序的环境
使用配置管理器连接至配置管理器
声明 | 商标 | 下载 | | 支持 | 反馈
Copyright IBM Corporation 1999, 2006 最后更新:2006/05/19
ae33050_