【问题标题】:JMS CreateQueue QuestionJMS 创建队列问题
【发布时间】:2014-02-13 22:15:22
【问题描述】:

我有一个关于 JMS createQueue 方法的一般性问题。在 WebSphere MQ 中,此方法是否用作 JNDI 查找的替代方法?我在想我可以动态创建一个队列。这可能吗?谢谢。

【问题讨论】:

    标签: java jms ibm-mq


    【解决方案1】:

    假设您的意思是QueueSession.createQueue,这是一种非常具有误导性的方法,并且不会像您想的那样:

    在给定队列的情况下创建队列标识 名字。

    此设施是为稀有的 客户需要的情况 动态操作队列标识。 它允许创建队列 提供者特定的身份 姓名。依赖于此的客户 能力不可移植。

    请注意,此方法不适用于 创建物理队列。这 队列的物理创建是 行政任务,而不是 由 JMS API 发起。唯一的那个 例外是临时创建 队列,这是通过 createTemporaryQueue 方法。

    JMS API 不提供动态创建队列的方法(除非您指的是临时队列,这是请求-响应消息传递使用的一种非常不同的野兽)。如果您想在运行时创建队列,那将是 WebSphere 专有的。

    【讨论】:

    【解决方案2】:

    是的,根据规格并在上面的答案中正确指出

    Creates a queue identity given a Queue name.
    
    This facility is provided for the rare cases where clients need to dynamically
    manipulate queue identity. It allows the creation of a queue identity with a
    provider-specific name. Clients that depend on this ability are not portable.
    
    Note that this method is not for creating the physical queue.
    The physical creation of queues is an administrative task and is not to be
    initiated by the JMS API. The one exception is the creation of temporary queues,
    which is accomplished with the createTemporaryQueue method.
    

    所以 JMS 不提供动态创建队列的直接方法。其完成方式将特定于 JMS 提供者。 JMS 提供者可能会提供某种控制台或管理 API,您可以通过这些 API 执行此操作。

    就 Session 的createQueue() 方法而言,如果它已经创建,它将返回对 Queue 的引用。如果不是 JMSException 将被抛出。

    还要注意的是createTemporaryQueue() 创建实际的物理队列。您必须致电delete() 来清理相关资源。

    【讨论】:

      猜你喜欢
      • 2011-02-10
      • 2012-12-15
      • 2018-08-03
      • 2015-05-31
      • 2023-03-29
      • 1970-01-01
      • 2011-07-31
      • 2015-03-12
      • 2011-02-01
      相关资源
      最近更新 更多