开发者

How to check jndi bind/unbind status?

I'm looking for way of checking bind status of object and appropriate jndi name.

For example, I've got some ldap jms queue name: "/TheRootContext/SomeSubContext/SOME.QUEUE.NAME:queue"

I need to check that appropriate queue exists and it is binded with passed name.

What will be the correct way to check "bind status"?

I see such algorithm:

  1. Perform jn开发者_高级运维di lookup to ensure that provided name exists.

    Object obj = ctx.lookup("/TheRootContext/SomeSubContext/SOME.QUEUE.NAME:queue");

  2. %I don't know what to do next%, but suggest something like checking that:

    obj != null && obj instanceof javax.jms.Queue

Am I correct? What is the correct way?


Most likely if object is not found lookup will throw a NamingException in 1. You need to either catch an exception or try to use list method to check if object exists.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜