TopicConnection (Java EE 5)

Java EE API


javax.jms Interface TopicConnection

All Superinterfaces:
Connection
All Known Subinterfaces:
XATopicConnection

public interface TopicConnection
extends Connection

Implements: Connection
Implemented by: XATopicConnection

TopicConnection 对象是到发布/订阅 JMS 提供者的活动连接。客户端使用 TopicConnection 对象创建一个或多个生产和使用消息的 TopicSession 对象。

TopicConnection 可用于创建 TopicSession,可以从 TopicSession 中创建专门的与主题有关的对象。一种更常用且建议采用的方法是使用 Connection 对象。

应该使用 TopicConnection 对象支持现有代码。

英文文档:

A TopicConnection object is an active connection to a publish/subscribe JMS provider. A client uses a TopicConnection object to create one or more TopicSession objects for producing and consuming messages.

A TopicConnection can be used to create a TopicSession, from which specialized topic-related objects can be created. A more general, and recommended approach is to use the Connection object.

The TopicConnection object should be used to support existing code.

Version:
1.1 - February 2, 2002
Author:
Mark Hapner, Rich Burridge, Kate Stout
See Also:
Connection, ConnectionFactory, TopicConnectionFactory

Method Summary
 ConnectionConsumer
 ConnectionConsumer
 TopicSession
 
Methods inherited from interface javax.jms.Connection
 

Method Detail

public TopicSession createTopicSession(boolean transacted, int acknowledgeMode) throws JMSException
创建 TopicSession 对象。
transacted 指示会话是否是事务性的
acknowledgeMode 指示使用方或客户端是否将确认收到的任何消息;如果会话是事务性的,则忽略此参数。合法值有 Session.AUTO_ACKNOWLEDGESession.CLIENT_ACKNOWLEDGESession.DUPS_OK_ACKNOWLEDGE
return 新建的主题会话
ThrowsJMSException: 如果 TopicConnection 对象由于某个内部错误或缺少对特定事务和确认模式的支持无法创建会话。
See also AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE
英文文档:

createTopicSession

TopicSession createTopicSession(boolean transacted,
                                int acknowledgeMode)
                                throws JMSException
Creates a TopicSession object.

Parameters:
transacted - indicates whether the session is transacted
acknowledgeMode - indicates whether the consumer or the client will acknowledge any messages it receives; ignored if the session is transacted. Legal values are Session.AUTO_ACKNOWLEDGE, Session.CLIENT_ACKNOWLEDGE, and Session.DUPS_OK_ACKNOWLEDGE.
Returns:
a newly created topic session
Throws:
JMSException - if the TopicConnection object fails to create a session due to some internal error or lack of support for the specific transaction and acknowledgement mode.
See Also:
Session.AUTO_ACKNOWLEDGE, Session.CLIENT_ACKNOWLEDGE, Session.DUPS_OK_ACKNOWLEDGE

public ConnectionConsumer createConnectionConsumer(Topic topic, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException
创建此连接的连接使用方(可选操作)。这是一个专家级工具,常规 JMS 客户端不使用。
topic 要访问的主题
messageSelector 仅包括那些属性匹配所传送的消息选择器表达式的消息。值为 null 或空字符串表示该消息使用方没有消息选择器。
sessionPool 与此连接使用方关联的服务器会话池
maxMessages 可以一次分配给服务器会话的最大消息数
return 连接使用方
ThrowsJMSException: 如果 TopicConnection 对象由于某个内部错误或 sessionPoolmessageSelector 的无效参数无法创建连接使用方。
ThrowsInvalidDestinationException: 如果指定了无效的主题。
ThrowsInvalidSelectorException: 如果消息选择器无效。
See also javax.jms.ConnectionConsumer
英文文档:

createConnectionConsumer

ConnectionConsumer createConnectionConsumer(Topic topic,
                                            String messageSelector,
                                            ServerSessionPool sessionPool,
                                            int maxMessages)
                                            throws JMSException
Creates a connection consumer for this connection (optional operation). This is an expert facility not used by regular JMS clients.

Parameters:
topic - the topic to access
messageSelector - only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
sessionPool - the server session pool to associate with this connection consumer
maxMessages - the maximum number of messages that can be assigned to a server session at one time
Returns:
the connection consumer
Throws:
JMSException - if the TopicConnection object fails to create a connection consumer due to some internal error or invalid arguments for sessionPool and messageSelector.
InvalidDestinationException - if an invalid topic is specified.
InvalidSelectorException - if the message selector is invalid.
See Also:
ConnectionConsumer

public ConnectionConsumer createDurableConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException
创建此连接的持久连接使用方(可选操作)。这是一个专家级工具,常规 JMS 客户端不使用。
topic 要访问的主题
subscriptionName 持久订阅名称
messageSelector 仅包括那些属性匹配所传送的消息选择器表达式的消息。值为 null 或空字符串表示该消息使用方没有消息选择器。
sessionPool 关联此持久连接使用方的服务器会话池
maxMessages 可以一次分配给服务器会话的最大消息数
return 持久连接使用方
ThrowsJMSException: 如果 TopicConnection 对象由于某个内部错误或 sessionPoolmessageSelector 的无效参数无法创建连接使用方。
ThrowsInvalidDestinationException: 如果指定了无效的主题。
ThrowsInvalidSelectorException: 如果消息选择器无效。
See also javax.jms.ConnectionConsumer
英文文档:

createDurableConnectionConsumer

ConnectionConsumer createDurableConnectionConsumer(Topic topic,
                                                   String subscriptionName,
                                                   String messageSelector,
                                                   ServerSessionPool sessionPool,
                                                   int maxMessages)
                                                   throws JMSException
Create a durable connection consumer for this connection (optional operation). This is an expert facility not used by regular JMS clients.

Specified by:
createDurableConnectionConsumer in interface Connection
Parameters:
topic - the topic to access
subscriptionName - durable subscription name
messageSelector - only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
sessionPool - the server session pool to associate with this durable connection consumer
maxMessages - the maximum number of messages that can be assigned to a server session at one time
Returns:
the durable connection consumer
Throws:
JMSException - if the TopicConnection object fails to create a connection consumer due to some internal error or invalid arguments for sessionPool and messageSelector.
InvalidDestinationException - if an invalid topic is specified.
InvalidSelectorException - if the message selector is invalid.
See Also:
ConnectionConsumer


Submit a bug or feature

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

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

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