|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
javax.jms Interface QueueSender
- All Superinterfaces:
- MessageProducer
public interface QueueSender
- extends MessageProducer
客户端使用
QueueSender 对象将消息发送给队列。
通常,Queue 是在创建 QueueSender 时指定的。在这种情况下,尝试使用未标识的 QueueSender 的 send 方法将抛出 java.lang.UnsupportedOperationException。
如果使用未标识的 Queue 创建 QueueSender,则尝试使用假定 Queue 已标识的 send 方法将抛出 java.lang.UnsupportedOperationException。
在执行其 send 方法期间,客户端内的其他线程不得更改消息。如果修改了消息,则 send 的结果是不确定的。
消息发送后,客户端可以保留并修该它,而不会影响已经发送的消息。同一个消息对象可以被发送多次。
以下消息头作为发送消息的一部分设置:JMSDestination、JMSDeliveryMode、JMSExpiration、JMSPriority、JMSMessageID 和 JMSTimeStamp。发送消息时,忽略这些消息头的值。send 完成后,这些消息头保持发送该消息的方法指定的值。如果通过 MessageProducer.setDisableMessageID 或 MessageProducer.setDisableMessageTimestamp 方法显式禁用了这些消息头的该设置,则 send 方法可以不设置 JMSMessageID 和 JMSTimeStamp。
创建 MessageProducer 所提供的功能与创建 QueueSender 所提供的功能相同。创建新代码时建议使用 MessageProducer 对象。提供 QueueSender 的目的是支持现有代码。
| version |
| |
| See also | javax.jms.MessageProducer, createProducer(Destination), createSender(Queue) |
A client uses a QueueSender object to send messages to a queue.
Normally, the Queue is specified when a
QueueSender is created. In this case, an attempt to use
the send methods for an unidentified
QueueSender will throw a
java.lang.UnsupportedOperationException.
If the QueueSender is created with an unidentified
Queue, an attempt to use the send methods that
assume that the Queue has been identified will throw a
java.lang.UnsupportedOperationException.
During the execution of its send method, a message
must not be changed by other threads within the client.
If the message is modified, the result of the send is
undefined.
After sending a message, a client may retain and modify it without affecting the message that has been sent. The same message object may be sent multiple times.
The following message headers are set as part of sending a
message: JMSDestination, JMSDeliveryMode,
JMSExpiration, JMSPriority,
JMSMessageID and JMSTimeStamp.
When the message is sent, the values of these headers are ignored.
After the completion of the send, the headers hold the values
specified by the method sending the message. It is possible for the
send method not to set JMSMessageID and
JMSTimeStamp if the
setting of these headers is explicitly disabled by the
MessageProducer.setDisableMessageID or
MessageProducer.setDisableMessageTimestamp method.
Creating a MessageProducer provides the same features as
creating a QueueSender. A MessageProducer object is
recommended when creating new code. The QueueSender is
provided to support existing code.
- Version:
- 1.1 - February 2, 2002
- Author:
- Mark Hapner, Rich Burridge, Kate Stout
- See Also:
MessageProducer,Session.createProducer(Destination),QueueSession.createSender(Queue)
| Method Summary | |
|---|---|
Queue |
getQueue()
Gets the queue associated with this QueueSender. |
void |
send(Message message)
Sends a message to the queue. |
void |
send(Message message,
int deliveryMode,
int priority,
long timeToLive)
Sends a message to the queue, specifying delivery mode, priority, and time to live. |
void |
send(Queue queue,
Message message)
Sends a message to a queue for an unidentified message producer. |
void |
send(Queue queue,
Message message,
int deliveryMode,
int priority,
long timeToLive)
Sends a message to a queue for an unidentified message producer, specifying delivery mode, priority and time to live. |
| Methods inherited from interface javax.jms.MessageProducer |
|---|
close, getDeliveryMode, getDestination, getDisableMessageID, getDisableMessageTimestamp, getPriority, getTimeToLive, send, send, setDeliveryMode, setDisableMessageID, setDisableMessageTimestamp, setPriority, setTimeToLive |
| Method Detail |
|---|
public Queue
getQueue() throws JMSException
获取与此 QueueSender 关联的队列。
| return | 此发送者的队列 |
| Throws | JMSException:
如果 JMS 提供者由于某个内部错误无法获取此 QueueSender 的队列。 |
getQueue
Queue getQueue() throws JMSException
- Gets the queue associated with this
QueueSender. - Returns:
- this sender's queue
- Throws:
JMSException- if the JMS provider fails to get the queue for thisQueueSenderdue to some internal error.
public void
send(Message message) throws JMSException
将消息发送到队列。使用 QueueSender 的默认传送模式、优先级和生存时间。
| message | 要发送的消息 |
| Throws | JMSException: 如果 JMS 提供者由于某个内部错误无法发送消息。 |
| Throws | MessageFormatException: 如果指定了无效的消息。 |
| Throws | InvalidDestinationException:
如果客户端将此方法与带有无效队列的 QueueSender 一起使用。 |
| Throws | UnsupportedOperationException:
如果客户端将此方法与在创建时未指定队列的 QueueSender 一起使用。 |
| See also | getDeliveryMode(), getTimeToLive(), getPriority() |
send
void send(Message message) throws JMSException
- Sends a message to the queue. Uses the
QueueSender's default delivery mode, priority, and time to live. - Specified by:
sendin interfaceMessageProducer
- Parameters:
message- the message to send- Throws:
JMSException- if the JMS provider fails to send the message due to some internal error.MessageFormatException- if an invalid message is specified.InvalidDestinationException- if a client uses this method with aQueueSenderwith an invalid queue.UnsupportedOperationException- if a client uses this method with aQueueSenderthat did not specify a queue at creation time.- See Also:
MessageProducer.getDeliveryMode(),MessageProducer.getTimeToLive(),MessageProducer.getPriority()
public void
send(Message message, int deliveryMode, int priority, long timeToLive) throws JMSException
将消息发送到队列,指定传送模式、优先级和生存时间。
| message | 要发送的消息 |
| deliveryMode | 要使用的传送模式 |
| priority | 此消息的优先级 |
| timeToLive | 消息的生命周期(以毫秒为单位) |
| Throws | JMSException: 如果 JMS 提供者由于某个内部错误无法发送消息。 |
| Throws | MessageFormatException: 如果指定了无效的消息。 |
| Throws | InvalidDestinationException:
如果客户端将此方法与带有无效队列的 QueueSender 一起使用。 |
| Throws | UnsupportedOperationException:
如果客户端将此方法与在创建时未指定队列的 QueueSender 一起使用。 |
send
void send(Message message, int deliveryMode, int priority, long timeToLive) throws JMSException
- Sends a message to the queue, specifying delivery mode, priority, and
time to live.
- Specified by:
sendin interfaceMessageProducer
- Parameters:
message- the message to senddeliveryMode- the delivery mode to usepriority- the priority for this messagetimeToLive- the message's lifetime (in milliseconds)- Throws:
JMSException- if the JMS provider fails to send the message due to some internal error.MessageFormatException- if an invalid message is specified.InvalidDestinationException- if a client uses this method with aQueueSenderwith an invalid queue.UnsupportedOperationException- if a client uses this method with aQueueSenderthat did not specify a queue at creation time.- See Also:
Session.createProducer(javax.jms.Destination)
public void
send(Queue queue, Message message) throws JMSException
将消息发送到未标识的消息生成方的队列。使用 QueueSender 的默认传送模式、优先级和生存时间。
通常,在创建时为消息生成方分配一个队列;但是,JMS API 也支持未标识的消息生成方,这需要在每次发送消息时提供队列。
| queue | 要将此消息发送到的队列 |
| message | 要发送的消息 |
| Throws | JMSException: 如果 JMS 提供者由于某个内部错误无法发送消息。 |
| Throws | MessageFormatException: 如果指定了无效的消息。 |
| Throws | InvalidDestinationException: 如果客户端将此方法与无效队列一起使用。 |
| See also | getDeliveryMode(), getTimeToLive(), getPriority() |
send
void send(Queue queue, Message message) throws JMSException
- Sends a message to a queue for an unidentified message producer.
Uses the
QueueSender's default delivery mode, priority, and time to live.Typically, a message producer is assigned a queue at creation time; however, the JMS API also supports unidentified message producers, which require that the queue be supplied every time a message is sent.
- Parameters:
queue- the queue to send this message tomessage- the message to send- Throws:
JMSException- if the JMS provider fails to send the message due to some internal error.MessageFormatException- if an invalid message is specified.InvalidDestinationException- if a client uses this method with an invalid queue.- See Also:
MessageProducer.getDeliveryMode(),MessageProducer.getTimeToLive(),MessageProducer.getPriority()
public void
send(Queue queue, Message message, int deliveryMode, int priority, long timeToLive) throws JMSException
将消息发送到未标识的消息生成方的队列,指定传送模式、优先级和生存时间。
通常,在创建时为消息生成方分配一个队列;但是,JMS API 也支持未标识的消息生成方,这需要在每次发送消息时提供队列。
| queue | 要将此消息发送到的队列 |
| message | 要发送的消息 |
| deliveryMode | 要使用的传送模式 |
| priority | 此消息的优先级 |
| timeToLive | 消息的生命周期(以毫秒为单位) |
| Throws | JMSException: 如果 JMS 提供者由于某个内部错误无法发送消息。 |
| Throws | MessageFormatException: 如果指定了无效的消息。 |
| Throws | InvalidDestinationException: 如果客户端将此方法与无效队列一起使用。 |
send
void send(Queue queue, Message message, int deliveryMode, int priority, long timeToLive) throws JMSException
- Sends a message to a queue for an unidentified message producer,
specifying delivery mode, priority and time to live.
Typically, a message producer is assigned a queue at creation time; however, the JMS API also supports unidentified message producers, which require that the queue be supplied every time a message is sent.
- Parameters:
queue- the queue to send this message tomessage- the message to senddeliveryMode- the delivery mode to usepriority- the priority for this messagetimeToLive- the message's lifetime (in milliseconds)- Throws:
JMSException- if the JMS provider fails to send the message due to some internal error.MessageFormatException- if an invalid message is specified.InvalidDestinationException- if a client uses this method with an invalid queue.
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!