无法在 WebSphere 中以编程方式创建 JMS 主题
Not able to create JMS topic programatically in WebSphere
我无法创建 SIB JMS 主题或队列。我试过下面的代码。代码运行无任何异常或错误
public void createSIBJMSTopic(String topicName, String jndiName, String busName, String topicSpace) {
try {
String server = "server1";
String description = "abc";
Session session = new Session();
CommandMgr commandMgr = CommandMgr.getCommandMgr(client);
configService = new ConfigServiceProxy(client);
System.out.println("Commands list" + commandMgr.listAllCommands().toString());
AdminCommand cmd = commandMgr.createCommand("createSIBJMSTopic");
System.out.println(session);
ObjectName targetObject = configService.resolve(session, null, "Node=mbaastest40Node02,Server=server1")[0];
cmd.setTargetObject(targetObject);
cmd.setParameter("name", topicName);
cmd.setParameter("jndiName", jndiName);
cmd.setParameter("busName", busName);
cmd.setParameter("topicSpace", topicSpace);
System.out.println("Before Execute");
cmd.execute();
CommandResult result = cmd.getCommandResult();
System.out.println("after execute");
if (result.isSuccessful())
System.out.println(result.toString());
if (!result.isSuccessful())
throw new AdminException(result.getException());
System.out.println("done");
configService.save(session, true);
System.out.println("After save");
}
catch (Exception e) {
e.printStackTrace();
}
}
您需要 link AdminCommand 配置 Session 通过:
AdminCommand cmd = commandMgr.createCommand("createSIBJMSTopic");
cmd.setConfigSession(session);
您还应注意 recommendation 完成后调用 configService.discard(session)
:
这是一个很好的开始 article 也可能有帮助。
我无法创建 SIB JMS 主题或队列。我试过下面的代码。代码运行无任何异常或错误
public void createSIBJMSTopic(String topicName, String jndiName, String busName, String topicSpace) {
try {
String server = "server1";
String description = "abc";
Session session = new Session();
CommandMgr commandMgr = CommandMgr.getCommandMgr(client);
configService = new ConfigServiceProxy(client);
System.out.println("Commands list" + commandMgr.listAllCommands().toString());
AdminCommand cmd = commandMgr.createCommand("createSIBJMSTopic");
System.out.println(session);
ObjectName targetObject = configService.resolve(session, null, "Node=mbaastest40Node02,Server=server1")[0];
cmd.setTargetObject(targetObject);
cmd.setParameter("name", topicName);
cmd.setParameter("jndiName", jndiName);
cmd.setParameter("busName", busName);
cmd.setParameter("topicSpace", topicSpace);
System.out.println("Before Execute");
cmd.execute();
CommandResult result = cmd.getCommandResult();
System.out.println("after execute");
if (result.isSuccessful())
System.out.println(result.toString());
if (!result.isSuccessful())
throw new AdminException(result.getException());
System.out.println("done");
configService.save(session, true);
System.out.println("After save");
}
catch (Exception e) {
e.printStackTrace();
}
}
您需要 link AdminCommand 配置 Session 通过:
AdminCommand cmd = commandMgr.createCommand("createSIBJMSTopic");
cmd.setConfigSession(session);
您还应注意 recommendation 完成后调用 configService.discard(session)
:
这是一个很好的开始 article 也可能有帮助。