QueueRequestor (Java EE 5)

Java EE API


javax.jms Class QueueRequestor

java.lang.Object
  extended by javax.jms.QueueRequestor

public class QueueRequestor
extends Object


QueueRequestor 帮助类简化了服务请求的建立。

QueueRequestor 构造方法提供有非事务性 QueueSession 和目的地 Queue。它创建用于响应的 TemporaryQueue,并提供发送请求消息和等待其回复的 request 方法。

这是基本的请求/回复抽象,应该足以满足大部分使用情况。JMS 提供者和客户端可以随意创建更复杂的版本。

英文文档:

The QueueRequestor helper class simplifies making service requests.

The QueueRequestor constructor is given a non-transacted QueueSession and a destination Queue. It creates a TemporaryQueue for the responses and provides a request method that sends the request message and waits for its reply.

This is a basic request/reply abstraction that should be sufficient for most uses. JMS providers and clients are free to create more sophisticated versions.

Version:
1.0 - 8 July 1998
Author:
Mark Hapner, Rich Burridge
See Also:
TopicRequestor

Constructor Summary
 
Method Summary
 void
 Message
 
Methods inherited from class java.lang.Object
 

Constructor Detail

public QueueRequestor(QueueSession session, Queue queue) throws JMSException
QueueRequestor 类的构造方法。

此实现假定没有处理 session 参数,提交模式为 AUTO_ACKNOWLEDGEDUPS_OK_ACKNOWLEDGE

session 队列所属的 QueueSession
queue 要执行请求/回复调用的队列
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法创建 QueueRequestor
ThrowsInvalidDestinationException: 如果指定了无效的队列。

英文文档:

QueueRequestor

public QueueRequestor(QueueSession session,
                      Queue queue)
               throws JMSException
Constructor for the QueueRequestor class.

This implementation assumes the session parameter to be non-transacted, with a delivery mode of either AUTO_ACKNOWLEDGE or DUPS_OK_ACKNOWLEDGE.

Parameters:
session - the QueueSession the queue belongs to
queue - the queue to perform the request/reply call on
Throws:
JMSException - if the JMS provider fails to create the QueueRequestor due to some internal error.
InvalidDestinationException - if an invalid queue is specified.

Method Detail

public Message request(Message message) throws JMSException
发送请求并等待回复。临时队列用于 JMSReplyTo 目的地,而且要求每个请求只有一个回复。
message 要发送的消息
return 回复消息
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法完成请求。
英文文档:

request

public Message request(Message message)
                throws JMSException
Sends a request and waits for a reply. The temporary queue is used for the JMSReplyTo destination, and only one reply per request is expected.

Parameters:
message - the message to send
Returns:
the reply message
Throws:
JMSException - if the JMS provider fails to complete the request due to some internal error.

public void close() throws JMSException
关闭 QueueRequestor 及其会话。

由于提供者可能会代表 QueueRequestor 分配 Java 虚拟机之外的某些资源,因此不需要这些资源时客户端应该关闭它们。依赖于垃圾收集最终回收这些资源可能不够及时。

注意,此方法关闭传递给 QueueRequestor 构造方法的 QueueSession 对象。

ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法关闭 QueueRequestor

英文文档:

close

public void close()
           throws JMSException
Closes the QueueRequestor and its session.

Since a provider may allocate some resources on behalf of a QueueRequestor outside the Java virtual machine, clients should close them when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough.

Note that this method closes the QueueSession object passed to the QueueRequestor constructor.

Throws:
JMSException - if the JMS provider fails to close the QueueRequestor 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 : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!