QueueSession (Java EE 5)

Java EE API


javax.jms Interface QueueSession

All Superinterfaces:
Runnable, Session

public interface QueueSession
extends Session

Implements: Session

QueueSession 对象提供了创建 QueueReceiverQueueSenderQueueBrowserTemporaryQueue 对象的方法。

如果有些消息已被接收但在 QueueSession 终止时尚未得到确认,则这些消息将会保留,并在使用方下次访问该队列时重新传送。

QueueSession 用于创建特定于点对点的对象。一般情况下,使用 Session 对象。QueueSession 用于支持现有代码。使用 Session 对象可简化编程模型,并允许跨两个消息传送域使用事务。

不能使用 QueueSession 创建特定于发布/订阅域的对象。下列方法继承自 Session,但如果在 QueueSession 中使用它们,则必定抛出 IllegalStateException

  • createDurableSubscriber
  • createTemporaryTopic
  • createTopic
  • unsubscribe
英文文档:

A QueueSession object provides methods for creating QueueReceiver, QueueSender, QueueBrowser, and TemporaryQueue objects.

If there are messages that have been received but not acknowledged when a QueueSession terminates, these messages will be retained and redelivered when a consumer next accesses the queue.

A QueueSession is used for creating Point-to-Point specific objects. In general, use the Session object. The QueueSession is used to support existing code. Using the Session object simplifies the programming model, and allows transactions to be used across the two messaging domains.

A QueueSession cannot be used to create objects specific to the publish/subscribe domain. The following methods inherit from Session, but must throw an IllegalStateException if they are used from QueueSession:

  • createDurableSubscriber
  • createTemporaryTopic
  • createTopic
  • unsubscribe

Version:
1.1 - April 2, 2002
Author:
Mark Hapner, Rich Burridge, Kate Stout
See Also:
Session, QueueConnection.createQueueSession(boolean, int), XAQueueSession.getQueueSession()

Field Summary
 
Fields inherited from interface javax.jms.Session
 
Method Summary
 QueueBrowser
 QueueBrowser
 Queue
 QueueReceiver
 QueueReceiver
 QueueSender
 TemporaryQueue
 
Methods inherited from interface javax.jms.Session
 

Method Detail

public Queue createQueue(String queueName) throws JMSException
创建给定 Queue 名称的队列身份。

此工具供某些特殊情况使用,这些情况下客户端需要动态操作队列身份。它允许创建具有特定于提供者的名称的队列身份。依赖于此能力的客户端是不可移植的。

注意,此方法不用于创建物理队列。物理创建队列是一项管理任务,不应由 JMS API 发起。有一个例外是创建临时队列,它可以使用 createTemporaryQueue 方法实现。

queueNameQueue 的名称
return 具有给定名称的 Queue
ThrowsJMSException: 如果会话由于某个内部错误无法创建队列。

英文文档:

createQueue

Queue createQueue(String queueName)
                  throws JMSException
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.

Specified by:
createQueue in interface Session
Parameters:
queueName - the name of this Queue
Returns:
a Queue with the given name
Throws:
JMSException - if the session fails to create a queue due to some internal error.

public QueueReceiver createReceiver(Queue queue) throws JMSException
创建 QueueReceiver 对象从指定队列接收消息。
queue 要访问的 Queue
ThrowsJMSException: 如果会话由于某个内部错误无法创建接收者。
ThrowsInvalidDestinationException: 如果指定了无效的队列。
英文文档:

createReceiver

QueueReceiver createReceiver(Queue queue)
                             throws JMSException
Creates a QueueReceiver object to receive messages from the specified queue.

Parameters:
queue - the Queue to access
Throws:
JMSException - if the session fails to create a receiver due to some internal error.
InvalidDestinationException - if an invalid queue is specified.

public QueueReceiver createReceiver(Queue queue, String messageSelector) throws JMSException
创建 QueueReceiver 对象从指定队列使用消息选择器接收消息。
queue 要访问的 Queue
messageSelector 仅传送属性与消息选择器表达式相匹配的消息。值为 null 或空字符串表示该消息使用方没有消息选择器。
ThrowsJMSException: 如果会话由于某个内部错误无法创建接收者。
ThrowsInvalidDestinationException: 如果指定了无效的队列。
ThrowsInvalidSelectorException: 如果消息选择器无效。
英文文档:

createReceiver

QueueReceiver createReceiver(Queue queue,
                             String messageSelector)
                             throws JMSException
Creates a QueueReceiver object to receive messages from the specified queue using a message selector.

Parameters:
queue - the Queue 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.
Throws:
JMSException - if the session fails to create a receiver due to some internal error.
InvalidDestinationException - if an invalid queue is specified.
InvalidSelectorException - if the message selector is invalid.

public QueueSender createSender(Queue queue) throws JMSException
创建 QueueSender 对象以将消息发送到指定队列。
queue 要访问的 Queue;如果这是未标识的生成方,则为 null
ThrowsJMSException: 如果会话由于某个内部错误无法创建发送者。
ThrowsInvalidDestinationException: 如果指定了无效的队列。
英文文档:

createSender

QueueSender createSender(Queue queue)
                         throws JMSException
Creates a QueueSender object to send messages to the specified queue.

Parameters:
queue - the Queue to access, or null if this is an unidentified producer
Throws:
JMSException - if the session fails to create a sender due to some internal error.
InvalidDestinationException - if an invalid queue is specified.

public QueueBrowser createBrowser(Queue queue) throws JMSException
创建 QueueBrowser 对象以查看指定队列上的消息。
queue 要访问的 Queue
ThrowsJMSException: 如果会话由于某个内部错误无法创建浏览器。
ThrowsInvalidDestinationException: 如果指定了无效的队列。
英文文档:

createBrowser

QueueBrowser createBrowser(Queue queue)
                           throws JMSException
Creates a QueueBrowser object to peek at the messages on the specified queue.

Specified by:
createBrowser in interface Session
Parameters:
queue - the Queue to access
Throws:
JMSException - if the session fails to create a browser due to some internal error.
InvalidDestinationException - if an invalid queue is specified.

public QueueBrowser createBrowser(Queue queue, String messageSelector) throws JMSException
创建 QueueBrowser 对象以使用消息选择器查看指定队列上的消息。
queue 要访问的 Queue
messageSelector 仅传送属性与消息选择器表达式相匹配的消息。值为 null 或空字符串表示该消息使用方没有消息选择器。
ThrowsJMSException: 如果会话由于某个内部错误无法创建浏览器。
ThrowsInvalidDestinationException: 如果指定了无效的队列。
ThrowsInvalidSelectorException: 如果消息选择器无效。
英文文档:

createBrowser

QueueBrowser createBrowser(Queue queue,
                           String messageSelector)
                           throws JMSException
Creates a QueueBrowser object to peek at the messages on the specified queue using a message selector.

Specified by:
createBrowser in interface Session
Parameters:
queue - the Queue 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.
Throws:
JMSException - if the session fails to create a browser due to some internal error.
InvalidDestinationException - if an invalid queue is specified.
InvalidSelectorException - if the message selector is invalid.

public TemporaryQueue createTemporaryQueue() throws JMSException
创建 TemporaryQueue 对象。其生命周期将是 QueueConnection 的生命周期,除非提前删除该对象。
return 临时队列身份
ThrowsJMSException: 如果会话由于某个内部错误无法创建临时队列。
英文文档:

createTemporaryQueue

TemporaryQueue createTemporaryQueue()
                                    throws JMSException
Creates a TemporaryQueue object. Its lifetime will be that of the QueueConnection unless it is deleted earlier.

Specified by:
createTemporaryQueue in interface Session
Returns:
a temporary queue identity
Throws:
JMSException - if the session fails to create a temporary queue due to some internal error.


Submit a bug or feature

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

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

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