TextMessage (Java EE 5)

Java EE API


javax.jms Interface TextMessage

All Superinterfaces:
Message

public interface TextMessage
extends Message

Implements: Message

TextMessage 对象用于发送包含 java.lang.String 的消息。它继承自 Message 接口并添加了文本消息正文。

此消息类型可用于传输基于文本的消息,包括那些含有 XML 内容的消息。

当客户端接收 TextMessage 时,它是只读模式。如果客户端尝试在此时写入消息,则抛出 MessageNotWriteableException。如果调用了 clearBody,现在便可以读取和写入消息。

英文文档:

A TextMessage object is used to send a message containing a java.lang.String. It inherits from the Message interface and adds a text message body.

This message type can be used to transport text-based messages, including those with XML content.

When a client receives a TextMessage, it is in read-only mode. If a client attempts to write to the message at this point, a MessageNotWriteableException is thrown. If clearBody is called, the message can now be both read from and written to.

Version:
1.1 - February 2, 2002
Author:
Mark Hapner, Rich Burridge, Kate Stout
See Also:
Session.createTextMessage(), Session.createTextMessage(String), BytesMessage, MapMessage, Message, ObjectMessage, StreamMessage, String

Field Summary
 
Fields inherited from interface javax.jms.Message
 
Method Summary
 String
 void
 
Methods inherited from interface javax.jms.Message
 

Method Detail

public void setText(String string) throws JMSException
设置包含此消息数据的字符串。
string 包含消息数据的 String
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置文本。
ThrowsMessageNotWriteableException: 如果消息是只读模式。
英文文档:

setText

void setText(String string)
             throws JMSException
Sets the string containing this message's data.

Parameters:
string - the String containing the message's data
Throws:
JMSException - if the JMS provider fails to set the text due to some internal error.
MessageNotWriteableException - if the message is in read-only mode.

public String getText() throws JMSException
获取包含此消息数据的字符串。默认值为 null。
return 包含消息数据的 String
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取文本。
英文文档:

getText

String getText()
               throws JMSException
Gets the string containing this message's data. The default value is null.

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