Topic (Java EE 5)

Java EE API


javax.jms Interface Topic

All Superinterfaces:
Destination
All Known Subinterfaces:
TemporaryTopic

public interface Topic
extends Destination

Implements: Destination
Implemented by: TemporaryTopic

Topic 对象封装特定于提供者的主题名称。客户端通过这种方式将主题的身份指定给 JMS API 方法。对于那些将 Destination 用作形参的方法,Topic 对象可用作实参。例如,通过调用以下两个方法,可以使用 Topic 创建 MessageConsumerMessageProducer
  • Session.CreateConsumer(Destination destination)
  • Session.CreateProducer(Destination destination)

许多发布/订阅 (pub/sub) 提供者将主题分组为层次结构,并提供各种选项来订阅层次结构的各部分。JMS API 对 Topic 对象所代表的内容不加限制。它可能是主题层次结构中的叶节点,也可能是层次结构的较大部分。

主题的组织和对主题的订阅粒度是 pub/sub 应用程序架构的重要部分。JMS API 没有为应如何执行此操作指定策略。如果应用程序使用特定于提供者的主题分组机制,它应对此进行记录。如果使用不同的提供者安装该应用程序,则管理员负责构造等效的主题架构,并创建等效的 Topic 对象。

英文文档:

A Topic object encapsulates a provider-specific topic name. It is the way a client specifies the identity of a topic to JMS API methods. For those methods that use a Destination as a parameter, a Topic object may used as an argument . For example, a Topic can be used to create a MessageConsumer and a MessageProducer by calling:

  • Session.CreateConsumer(Destination destination)
  • Session.CreateProducer(Destination destination)

Many publish/subscribe (pub/sub) providers group topics into hierarchies and provide various options for subscribing to parts of the hierarchy. The JMS API places no restriction on what a Topic object represents. It may be a leaf in a topic hierarchy, or it may be a larger part of the hierarchy.

The organization of topics and the granularity of subscriptions to them is an important part of a pub/sub application's architecture. The JMS API does not specify a policy for how this should be done. If an application takes advantage of a provider-specific topic-grouping mechanism, it should document this. If the application is installed using a different provider, it is the job of the administrator to construct an equivalent topic architecture and create equivalent Topic objects.

Version:
1.1 - February 2, 2002
Author:
Mark Hapner, Rich Burridge, Kate Stout
See Also:
Session.createConsumer(Destination), Session.createProducer(Destination), TopicSession.createTopic(String)

Method Summary
 String
 String
 

Method Detail

public String getTopicName() throws JMSException
获取此主题的名称。

依赖于该名称的客户端是不可移植的。

return 主题名称
ThrowsJMSException: 如果 Topic 的 JMS 提供者实现由于某个内部错误无法返回主题名称。

英文文档:

getTopicName

String getTopicName()
                    throws JMSException
Gets the name of this topic.

Clients that depend upon the name are not portable.

Returns:
the topic name
Throws:
JMSException - if the JMS provider implementation of Topic fails to return the topic name due to some internal error.

public String toString()
返回此对象的字符串表示形式。
return 此主题的特定于提供者的身份值
英文文档:

toString

String toString()
Returns a string representation of this object.

Overrides:
toString in class Object
Returns:
the provider-specific identity values for this topic


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!