Message (Java EE 5)

Java EE API


javax.jms Interface Message

All Known Subinterfaces:
BytesMessage, MapMessage, ObjectMessage, StreamMessage, TextMessage

public interface Message


Message 接口是所有 JMS 消息的根接口。它定义用于所有消息的消息头和 acknowledge 方法。

大多数面向消息中间件 (MOM) 产品将消息视为由头和负载组成的轻量级实体。头包含了用于消息路由和标识的字段;负载包含了要发送的应用程序数据。

在这种一般形式下,消息的定义在不同的产品之间变化很大。JMS API 将很难支持所有这些消息模型。

考虑到这一点,JMS 消息模型具有以下目的:

  • 提供单一、统一的消息 API
  • 提供的 API 应适合于创建匹配提供者-本机消息传递应用程序所用格式的消息
  • 支持开发跨操作系统、机器架构和计算机语言的异构应用程序
  • 支持包含 Java 编程语言对象(“Java 对象”)的消息
  • 支持包含可扩展标记语言 (Extensible Markup Language, XML) 页面的消息

JMS 消息由以下部分组成:

  • Header(头)- 所有消息都支持相同的头字段集合。头字段包含客户端和提供者用于标识和路由消息的值。
  • Property(属性)- 每个消息都包含一个内置工具,用于支持应用程序定义的属性值。属性为支持应用程序定义的消息过滤提供了一种有效的机制。
  • Body(正文)- JMS API 定义了几种消息正文类型,涵盖了当前使用的大多数消息传递样式。

消息正文

JMS API 定义了五种消息正文类型:

  • Stream(流)- StreamMessage 对象的消息正文包含 Java 编程语言原始值流(“Java 基本类型”)。按顺序填充和读取。
  • Map(映射)- MapMessage 对象的消息正文包含一组名称-值对,其中名称是 String 对象,值是 Java 基本类型。可以根据名称按顺序或随机访问这些条目。条目的顺序是不确定的。
  • Text(文本)- TextMessage 对象的消息正文包含 java.lang.String 对象。此消息类型可用于传输纯文本消息和 XML 消息。
  • Object(对象)- ObjectMessage 对象的消息正文包含 Serializable Java 对象。
  • Byte(字节)- BytesMessage 对象的消息正文包含未解释的字节流。此消息类型可以按字面意义编码正文,以匹配现有的消息格式。在大多数情况下,可以使用更易用的其他正文类型。尽管 JMS API 允许将消息属性用于字节消息,但一般不使用它们,因为包含属性可能会影响格式。

消息头

JMSCorrelationID 头字段用于连接一个消息与另一个消息。它通常连接应答消息与请求消息。

JMSCorrelationID 可以保存特定于提供者的消息 ID、特定于应用程序的 String 对象,或者提供者-本机 byte[] 值。

消息属性

Message 对象包含一个内置工具,用于支持应用程序定义的属性值。实际上,这提供了一种将特定于应用程序的头字段添加到消息的机制。

属性允许应用程序通过消息选择器让 JMS 提供者使用特定于应用程序的标准为自己选择或过滤消息。

属性名称必须遵守消息选择器标识符的规则。属性名称不得为 null 或空字符串。如果设置了属性名称,并且它为 null 或空字符串,则必定抛出 IllegalArgumentException

属性值可以为 booleanbyteshortintlongfloatdoubleString

属性值在发送消息前设置。客户端收到消息时,其属性值是只读模式。如果客户端尝试在此时设置属性,则抛出 MessageNotWriteableException。调用了 clearProperties 后便可以读取和写入属性。注意,头字段与属性不同。头字段永远不会是只读模式。

属性值可以复制消息正文中的值,也可以不复制。尽管 JMS 没有定义属性行为策略,但应用程序开发人员应该注意,JMS 提供者处理消息正文中的数据可能比处理消息属性中的数据更高效。要获得最佳性能,应用程序应该仅在需要自定义消息头时才使用消息属性。这样做的主要原因是为了支持自定义消息选择。

消息属性支持以下转换表格。必须支持做了记号的那些情况。没有做记号的那些情况必须抛出 JMSException。如果基本类型的 valueOf 方法不接受 String 作为基本类型的有效表示形式,则 String 向基本类型的转换可能抛出运行时异常。

作为行类型写入的值可以作为列类型读取。

|        | boolean byte short int long float double String 
 |----------------------------------------------------------
|boolean |    X                                       X
|byte    |          X     X    X   X                  X 
|short   |                X    X   X                  X 
|int     |                     X   X                  X 
|long    |                         X                  X 
|float   |                               X     X      X 
|double  |                                     X      X 
|String  |    X     X     X    X   X     X     X      X 
 |----------------------------------------------------------
 

除了特定于类型的属性设置/获取方法外,JMS 还提供了 setObjectPropertygetObjectProperty 方法。这些方法都支持使用对象化原始值的同一属性类型集。这是为了能够在执行时(而不是编译时)确定属性类型。它们支持相同的属性值转换。

setObjectProperty 方法接受类 BooleanByteShortIntegerLongFloatDoubleString 的值。尝试使用任何其他类都会抛出 JMSException

getObjectProperty 方法仅返回类 BooleanByteShortIntegerLongFloatDoubleString 的值。

属性值的顺序是不确定的。若要迭代消息的属性值,请使用 getPropertyNames 获取属性名称枚举,然后使用各种属性获取方法获取它们的值。

可使用 clearProperties 方法删除消息的属性。此方法将使消息的属性集为空。

获取未设置名称的属性值将返回 null 值。只有 getStringPropertygetObjectProperty 方法才会返回 null 值。尝试将 null 值作为基本类型读取将视同于调用基本类型相应的 valueOf(String) 转换方法,并以 null 值作为参数。

JMS API 为 JMS 定义的属性保留 JMSX 属性名称前缀。Java 消息服务规范中定义了完整的属性集合。新的 JMS 定义属性可能会添加到以后的 JMS API 版本中。对这些属性的支持是可选的。String[] ConnectionMetaData.getJMSXPropertyNames 方法返回连接支持的 JMSX 属性名称。

无论这些 JMSX 属性是否受连接支持,都可以在消息选择器中引用它们。如果消息中不存在这些属性,则处理它们的方式与任何其他不存在的属性相同。

在规范中定义为“在发送过程中由提供者设置”的 JMSX 属性对于消息生成方和使用方都适用。规范中定义为“在接收过程中由提供者设置”的 JMSX 属性只适用于使用方。

JMSXGroupIDJMSXGroupSeq 是客户端分组消息时应该使用的标准属性。所有提供者都必须支持它们。除非特别说明,否则 JMSX 属性的值和语义是未定义的。

JMS API 为特定于提供者的属性保留 JMS_vendor_name 属性名称前缀。每个提供者都定义其自己的 vendor_name 值。这是 JMS 提供者使每个JMS 客户端能够使用其特殊的消息服务 (per-message services) 所采用的机制。

特定于提供者的属性的用途是,提供在单个 JMS 应用程序中集成 JMS 客户端与提供者-本机客户端时所需的特殊功能。它们不能用于 JMS 客户端之间的消息传递。

JMS Message 接口的提供者实现

JMS API 提供定义 JMS 消息模型的消息接口集。它不提供这些接口的实现。

每个 JMS 提供者向消息工厂集提供其 Session 对象,用于创建消息实例。这允许提供者使用根据其特定需求定制的消息实现。

提供者必须准备好接受不属于自己的消息实现。可能无法像处理自己的实现一样有效处理它们,但是必须处理它们。

注意提供者在处理外部消息实现时出现的以下例外情况。如果外部消息实现包含设置为外部目的地实现的 JMSReplyTo 头字段,则提供者不需要处理或保留此头字段的值。

消息选择器

JMS 消息选择器允许客户端通过头字段引用和属性引用指定感兴趣的消息。只传送头和属性值匹配选择器的那些消息。这意味着消息是否被传送取决于使用的 MessageConsumer(请参阅 QueueReceiverTopicSubscriber)。

消息选择器不能引用消息正文值。

消息的头字段值和属性值替换了消息选择器中对应的标识符后,如果选择器求值为 true,则消息选择器匹配该消息。

消息选择器是一个 String,其语法是以 SQL92 条件表达式语法子集为基础的。如果消息选择器的值是一个空字符串,则该值视为 null,表示没有任何消息选择器可供消息使用方使用。

消息选择器的求值顺序是按优先级从左到右计算。可以使用括号来更改此顺序。

预定义选择器的字面值和操作符名称在这里用大写表示;实际上它们是不区分大小写的。

选择器可以包含:

  • 字面值:
    • 字符串字面值使用单引号括起,单引号则用两个单引号表示;例如,'literal''literal''s'。这些字面值与 Java 编程语言中的字符串字面值一样,都使用 Unicode 字符编码。
    • 一个精确的数字字面值是一个不带小数点的数值,如 57-957+62;支持 long 型的数值范围。精确的数字字面值使用 Java 编程语言中的整数字面值语法。
    • 一个近似的数字字面值是使用科学计数法表示的数值,如 7E3-57.9E2,或者是带小数点的数值,如 7.-95.7+6.2;支持 double 型的数值范围。近似的数字字面值使用 Java 编程语言中的浮点字面值语法。
    • 布尔字面值为 TRUEFALSE
  • 标识符:
    • 标识符是一个任意长度的字母数字序列,其首字符必须是字母。字母是对其调用 Character.isJavaLetter 方法可返回 true 的任何字符。这包括 '_''$'。字母或数字是对其调用 Character.isJavaLetterOrDigit 方法可返回 true 的任何字符。
    • 标识符不能使用名称 NULLTRUEFALSE
    • 标识符不能是 NOTANDORBETWEENLIKEINISESCAPE
    • 标识符是头字段引用或属性引用。消息选择器中属性值的类型对应于设置属性时使用的类型。如果引用了消息中不存在的属性,则其值为 NULL
    • 当属性用于消息选择器表达式时,不可应用适用于属性获取方法的转换。例如,假设将属性设置为一个字符串值,如下所示:
      myMessage.setStringProperty("NumberOfOrders", "2");
      以下消息选择器中的表达式将求值为 false,因为字符串不能用于算术表达式:
      "NumberOfOrders > 1"
    • 标识符是区分大小写的。
    • 消息头字段引用限于 JMSDeliveryModeJMSPriorityJMSMessageIDJMSTimestampJMSCorrelationIDJMSTypeJMSMessageIDJMSCorrelationIDJMSType 值可以为 null,如果为 null,则按 NULL 值处理它们。
    • 'JMSX' 开头的任何名称是一个 JMS 定义的属性名称。
    • 'JMS_' 开头的任何名称是一个特定于提供者的属性名称。
    • 不以 'JMS' 开头的任何名称是一个特定于应用程序的属性名称。
  • 空白字符与 Java 编程语言中的定义相同:空格、水平制表符、换页符和行结束符。
  • 表达式:
    • 选择器是一个条件表达式;求值为 true,则选择器匹配;求值为 false 或“未知”,则选择器不匹配。
    • 算术表达式由其他算术表达式、算术运算、标识符(其值视为数字字面值处理)和数字字面值构成。
    • 条件表达式由其他条件表达式、比较运算和逻辑运算构成。
  • 支持使用标准括号 () 对表达式的求值顺序进行排序。
  • 按优先级从高到低排序的逻辑运算符:NOTANDOR
  • 比较运算符:=>>=<<=(不等于)
    • 只能比较相同类型的值。有一种例外情况,即比较精确数字字面值和近似数字字面值是有效的;所需的类型转换由 Java 编程语言中的数值提升 (numeric promotion) 规则定义。如果尝试比较不同类型的值,运算的值为 false。如果两个类型值求值都为 NULL,则表达式的值未知。
    • 字符串和布尔值的比较只能使用 =。当且仅当两个字符串具有相同字符序列时它们才相等。
  • 按优先级从高到低排序的算术运算符:
    • +-(一元)
    • */(乘和除)
    • +-(加和减)
    • 算术运算必须使用 Java 编程语言中的数值提升。
  • arithmetic-expr1 [NOT] BETWEEN arithmetic-expr2 AND arithmetic-expr3(比较运算符)
    • "age BETWEEN 15 AND 19" 等于 "age >= 15 AND age <= 19"
    • "age NOT BETWEEN 15 AND 19" 等于 "age < 15 OR age > 19"
  • identifier [NOT] IN (string-literal1, string-literal2,...)(比较运算符,其中 identifier 具有 StringNULL 值)
    • "Country IN (' UK', 'US', 'France')" 对于 'UK' 为 true,对于 'Peru' 为 false;它等效于表达式 "(Country = ' UK') OR (Country = ' US') OR (Country = ' France')"
    • "Country NOT IN (' UK', 'US', 'France')" 对于 'UK' 为 false,对于 'Peru' 为 true;它等效于表达式 "NOT ((Country = ' UK') OR (Country = ' US') OR (Country = ' France'))"
    • 如果 INNOT IN 运算的标识符为 NULL,则运算的值未知。
  • identifier [NOT] LIKE pattern-value [ESCAPE escape-character](比较运算符,其中 identifier 具有 String 值。pattern-value 是一个字符串字面值,其中 '_' 表示任何单个字符,'%' 表示任何字符序列,包括空序列,所有其他字符都表示自身。可选的 escape-character 是一个单字符字符串字面值,其字符用于转义 pattern-value'_''%' 的特殊含义。)
    • "phone LIKE '12%3'" 对于 '123''12993' 为 true,对于 '1234' 为 false。
    • "word LIKE 'l_se'" 对于 'lose' 为 true,对于 'loose' 为 false。
    • "underscored LIKE '\_%' ESCAPE '\'" 对于 '_foo' 为 true,对于 'bar' 为 false。
    • "phone NOT LIKE '12%3'" 对于 '123''12993' 为 false,对于 '1234' 为 true。
    • 如果 LIKENOT LIKE 运算的 identifierNULL,则运算的值未知。
  • identifier IS NULL(比较运算符,测试 null 头字段值或缺失的属性值)
    • "prop_name IS NULL"
  • identifier IS NOT NULL(比较运算符,测试非 null 头字段值或属性值是否存在)
    • "prop_name IS NOT NULL"

    JMS 提供者必须在出现消息选择器时验证其语法的正确性。提供语法不正确的选择器的方法必定导致抛出 JMSException。JMS 提供者还可以在出现选择器时有选择地提供一些语义检查。并非所有语义检查都可以在出现消息选择器时执行,因为属性类型是未知的。

    以下消息选择器选择消息类型为 car、颜色为 blue、重量超过 2500 磅的消息:

    "JMSType = 'car' AND color = 'blue' AND weight > 2500"

    Null 值

    如上所述,属性值可以为 NULL。包含 NULL 值的选择器求值表达式由 SQL92 NULL 语法定义。下面简要描述这些语法。

    SQL 将 NULL 值视为“未知”。比较或计算一个未知值总是得出一个未知值。

    IS NULLIS NOT NULL 运算符将一个未知值分别转换为 TRUEFALSE 值。

    布尔运算符使用下表定义的三值逻辑:

    AND 运算符的定义

    | AND  |   T   |   F   |   U
     +------+-------+-------+-------
    |  T   |   T   |   F   |   U
    |  F   |   F   |   F   |   F
    |  U   |   U   |   F   |   U
     +------+-------+-------+-------
     

    OR 运算符的定义

    | OR   |   T   |   F   |   U
     +------+-------+-------+--------
    |  T   |   T   |   T   |   T
    |  F   |   T   |   F   |   U
    |  U   |   T   |   U   |   U
     +------+-------+-------+------- 
     

    NOT 运算符的定义

    | NOT
     +------+------
    |  T   |   F
    |  F   |   T
    |  U   |   U
     +------+-------
     

    特别注意

    在消息选择器中使用时,JMSDeliveryMode 头字段被视为具有值 'PERSISTENT''NON_PERSISTENT'

    日期和时间值应使用标准 long 型毫秒值。消息选择器中包含日期和时间字面值时,它的毫秒值应该是整数字面值。生成毫秒值的标准方法是使用 java.util.Calendar

    尽管 SQL 支持定点十进制的比较和算术运算,但 JMS 消息选择器不支持。所以要将精确数字字面值限制为没有小数点的数字字面值(将带小数点的数字作为近似数值的可选表示形式)。

    不支持 SQL 注释。

    英文文档:

    The Message interface is the root interface of all JMS messages. It defines the message header and the acknowledge method used for all messages.

    Most message-oriented middleware (MOM) products treat messages as lightweight entities that consist of a header and a payload. The header contains fields used for message routing and identification; the payload contains the application data being sent.

    Within this general form, the definition of a message varies significantly across products. It would be quite difficult for the JMS API to support all of these message models.

    With this in mind, the JMS message model has the following goals:

    • Provide a single, unified message API
    • Provide an API suitable for creating messages that match the format used by provider-native messaging applications
    • Support the development of heterogeneous applications that span operating systems, machine architectures, and computer languages
    • Support messages containing objects in the Java programming language ("Java objects")
    • Support messages containing Extensible Markup Language (XML) pages

    JMS messages are composed of the following parts:

    • Header - All messages support the same set of header fields. Header fields contain values used by both clients and providers to identify and route messages.
    • Properties - Each message contains a built-in facility for supporting application-defined property values. Properties provide an efficient mechanism for supporting application-defined message filtering.
    • Body - The JMS API defines several types of message body, which cover the majority of messaging styles currently in use.

    Message Bodies

    The JMS API defines five types of message body:

    • Stream - A StreamMessage object's message body contains a stream of primitive values in the Java programming language ("Java primitives"). It is filled and read sequentially.
    • Map - A MapMessage object's message body contains a set of name-value pairs, where names are String objects, and values are Java primitives. The entries can be accessed sequentially or randomly by name. The order of the entries is undefined.
    • Text - A TextMessage object's message body contains a java.lang.String object. This message type can be used to transport plain-text messages, and XML messages.
    • Object - An ObjectMessage object's message body contains a Serializable Java object.
    • Bytes - A BytesMessage object's message body contains a stream of uninterpreted bytes. This message type is for literally encoding a body to match an existing message format. In many cases, it is possible to use one of the other body types, which are easier to use. Although the JMS API allows the use of message properties with byte messages, they are typically not used, since the inclusion of properties may affect the format.

    Message Headers

    The JMSCorrelationID header field is used for linking one message with another. It typically links a reply message with its requesting message.

    JMSCorrelationID can hold a provider-specific message ID, an application-specific String object, or a provider-native byte[] value.

    Message Properties

    A Message object contains a built-in facility for supporting application-defined property values. In effect, this provides a mechanism for adding application-specific header fields to a message.

    Properties allow an application, via message selectors, to have a JMS provider select, or filter, messages on its behalf using application-specific criteria.

    Property names must obey the rules for a message selector identifier. Property names must not be null, and must not be empty strings. If a property name is set and it is either null or an empty string, an IllegalArgumentException must be thrown.

    Property values can be boolean, byte, short, int, long, float, double, and String.

    Property values are set prior to sending a message. When a client receives a message, its properties are in read-only mode. If a client attempts to set properties at this point, a MessageNotWriteableException is thrown. If clearProperties is called, the properties can now be both read from and written to. Note that header fields are distinct from properties. Header fields are never in read-only mode.

    A property value may duplicate a value in a message's body, or it may not. Although JMS does not define a policy for what should or should not be made a property, application developers should note that JMS providers will likely handle data in a message's body more efficiently than data in a message's properties. For best performance, applications should use message properties only when they need to customize a message's header. The primary reason for doing this is to support customized message selection.

    Message properties support the following conversion table. The marked cases must be supported. The unmarked cases must throw a JMSException. The String-to-primitive conversions may throw a runtime exception if the primitive's valueOf method does not accept the String as a valid representation of the primitive.

    A value written as the row type can be read as the column type.

     |        | boolean byte short int long float double String 
     |----------------------------------------------------------
     |boolean |    X                                       X
     |byte    |          X     X    X   X                  X 
     |short   |                X    X   X                  X 
     |int     |                     X   X                  X 
     |long    |                         X                  X 
     |float   |                               X     X      X 
     |double  |                                     X      X 
     |String  |    X     X     X    X   X     X     X      X 
     |----------------------------------------------------------
     

    In addition to the type-specific set/get methods for properties, JMS provides the setObjectProperty and getObjectProperty methods. These support the same set of property types using the objectified primitive values. Their purpose is to allow the decision of property type to made at execution time rather than at compile time. They support the same property value conversions.

    The setObjectProperty method accepts values of class Boolean, Byte, Short, Integer, Long, Float, Double, and String. An attempt to use any other class must throw a JMSException.

    The getObjectProperty method only returns values of class Boolean, Byte, Short, Integer, Long, Float, Double, and String.

    The order of property values is not defined. To iterate through a message's property values, use getPropertyNames to retrieve a property name enumeration and then use the various property get methods to retrieve their values.

    A message's properties are deleted by the clearProperties method. This leaves the message with an empty set of properties.

    Getting a property value for a name which has not been set returns a null value. Only the getStringProperty and getObjectProperty methods can return a null value. Attempting to read a null value as a primitive type must be treated as calling the primitive's corresponding valueOf(String) conversion method with a null value.

    The JMS API reserves the JMSX property name prefix for JMS defined properties. The full set of these properties is defined in the Java Message Service specification. New JMS defined properties may be added in later versions of the JMS API. Support for these properties is optional. The String[] ConnectionMetaData.getJMSXPropertyNames method returns the names of the JMSX properties supported by a connection.

    JMSX properties may be referenced in message selectors whether or not they are supported by a connection. If they are not present in a message, they are treated like any other absent property.

    JMSX properties defined in the specification as "set by provider on send" are available to both the producer and the consumers of the message. JMSX properties defined in the specification as "set by provider on receive" are available only to the consumers.

    JMSXGroupID and JMSXGroupSeq are standard properties that clients should use if they want to group messages. All providers must support them. Unless specifically noted, the values and semantics of the JMSX properties are undefined.

    The JMS API reserves the JMS_vendor_name property name prefix for provider-specific properties. Each provider defines its own value for vendor_name. This is the mechanism a JMS provider uses to make its special per-message services available to a JMS client.

    The purpose of provider-specific properties is to provide special features needed to integrate JMS clients with provider-native clients in a single JMS application. They should not be used for messaging between JMS clients.

    Provider Implementations of JMS Message Interfaces

    The JMS API provides a set of message interfaces that define the JMS message model. It does not provide implementations of these interfaces.

    Each JMS provider supplies a set of message factories with its Session object for creating instances of messages. This allows a provider to use message implementations tailored to its specific needs.

    A provider must be prepared to accept message implementations that are not its own. They may not be handled as efficiently as its own implementation; however, they must be handled.

    Note the following exception case when a provider is handling a foreign message implementation. If the foreign message implementation contains a JMSReplyTo header field that is set to a foreign destination implementation, the provider is not required to handle or preserve the value of this header field.

    Message Selectors

    A JMS message selector allows a client to specify, by header field references and property references, the messages it is interested in. Only messages whose header and property values match the selector are delivered. What it means for a message not to be delivered depends on the MessageConsumer being used (see QueueReceiver and TopicSubscriber).

    Message selectors cannot reference message body values.

    A message selector matches a message if the selector evaluates to true when the message's header field values and property values are substituted for their corresponding identifiers in the selector.

    A message selector is a String whose syntax is based on a subset of the SQL92 conditional expression syntax. If the value of a message selector is an empty string, the value is treated as a null and indicates that there is no message selector for the message consumer.

    The order of evaluation of a message selector is from left to right within precedence level. Parentheses can be used to change this order.

    Predefined selector literals and operator names are shown here in uppercase; however, they are case insensitive.

    A selector can contain:

    • Literals:
      • A string literal is enclosed in single quotes, with a single quote represented by doubled single quote; for example, 'literal' and 'literal''s'. Like string literals in the Java programming language, these use the Unicode character encoding.
      • An exact numeric literal is a numeric value without a decimal point, such as 57, -957, and +62; numbers in the range of long are supported. Exact numeric literals use the integer literal syntax of the Java programming language.
      • An approximate numeric literal is a numeric value in scientific notation, such as 7E3 and -57.9E2, or a numeric value with a decimal, such as 7., -95.7, and +6.2; numbers in the range of double are supported. Approximate literals use the floating-point literal syntax of the Java programming language.
      • The boolean literals TRUE and FALSE.
    • Identifiers:
      • An identifier is an unlimited-length sequence of letters and digits, the first of which must be a letter. A letter is any character for which the method Character.isJavaLetter returns true. This includes '_' and '$'. A letter or digit is any character for which the method Character.isJavaLetterOrDigit returns true.
      • Identifiers cannot be the names NULL, TRUE, and FALSE.
      • Identifiers cannot be NOT, AND, OR, BETWEEN, LIKE, IN, IS, or ESCAPE.
      • Identifiers are either header field references or property references. The type of a property value in a message selector corresponds to the type used to set the property. If a property that does not exist in a message is referenced, its value is NULL.
      • The conversions that apply to the get methods for properties do not apply when a property is used in a message selector expression. For example, suppose you set a property as a string value, as in the following:
        myMessage.setStringProperty("NumberOfOrders", "2");
        The following expression in a message selector would evaluate to false, because a string cannot be used in an arithmetic expression:
        "NumberOfOrders > 1"
      • Identifiers are case-sensitive.
      • Message header field references are restricted to JMSDeliveryMode, JMSPriority, JMSMessageID, JMSTimestamp, JMSCorrelationID, and JMSType. JMSMessageID, JMSCorrelationID, and JMSType values may be null and if so are treated as a NULL value.
      • Any name beginning with 'JMSX' is a JMS defined property name.
      • Any name beginning with 'JMS_' is a provider-specific property name.
      • Any name that does not begin with 'JMS' is an application-specific property name.
    • White space is the same as that defined for the Java programming language: space, horizontal tab, form feed, and line terminator.
    • Expressions:
      • A selector is a conditional expression; a selector that evaluates to true matches; a selector that evaluates to false or unknown does not match.
      • Arithmetic expressions are composed of themselves, arithmetic operations, identifiers (whose value is treated as a numeric literal), and numeric literals.
      • Conditional expressions are composed of themselves, comparison operations, and logical operations.
    • Standard bracketing () for ordering expression evaluation is supported.
    • Logical operators in precedence order: NOT, AND, OR
    • Comparison operators: =, >, >=, <, <=, (not equal)
      • Only like type values can be compared. One exception is that it is valid to compare exact numeric values and approximate numeric values; the type conversion required is defined by the rules of numeric promotion in the Java programming language. If the comparison of non-like type values is attempted, the value of the operation is false. If either of the type values evaluates to NULL, the value of the expression is unknown.
      • String and boolean comparison is restricted to = and . Two strings are equal if and only if they contain the same sequence of characters.
    • Arithmetic operators in precedence order:
      • +, - (unary)
      • *, / (multiplication and division)
      • +, - (addition and subtraction)
      • Arithmetic operations must use numeric promotion in the Java programming language.
    • arithmetic-expr1 [NOT] BETWEEN arithmetic-expr2 AND arithmetic-expr3 (comparison operator)
      • "age BETWEEN 15 AND 19" is equivalent to "age >= 15 AND age <= 19"
      • "age NOT BETWEEN 15 AND 19" is equivalent to "age < 15 OR age > 19"
    • identifier [NOT] IN (string-literal1, string-literal2,...) (comparison operator where identifier has a String or NULL value)
      • "Country IN (' UK', 'US', 'France')" is true for 'UK' and false for 'Peru'; it is equivalent to the expression "(Country = ' UK') OR (Country = ' US') OR (Country = ' France')"
      • "Country NOT IN (' UK', 'US', 'France')" is false for 'UK' and true for 'Peru'; it is equivalent to the expression "NOT ((Country = ' UK') OR (Country = ' US') OR (Country = ' France'))"
      • If identifier of an IN or NOT IN operation is NULL, the value of the operation is unknown.
    • identifier [NOT] LIKE pattern-value [ESCAPE escape-character] (comparison operator, where identifier has a String value; pattern-value is a string literal where '_' stands for any single character; '%' stands for any sequence of characters, including the empty sequence; and all other characters stand for themselves. The optional escape-character is a single-character string literal whose character is used to escape the special meaning of the '_' and '%' in pattern-value.)
      • "phone LIKE '12%3'" is true for '123' or '12993' and false for '1234'
      • "word LIKE 'l_se'" is true for 'lose' and false for 'loose'
      • "underscored LIKE '\_%' ESCAPE '\'" is true for '_foo' and false for 'bar'
      • "phone NOT LIKE '12%3'" is false for '123' or '12993' and true for '1234'
      • If identifier of a LIKE or NOT LIKE operation is NULL, the value of the operation is unknown.
    • identifier IS NULL (comparison operator that tests for a null header field value or a missing property value)
      • "prop_name IS NULL"
    • identifier IS NOT NULL (comparison operator that tests for the existence of a non-null header field value or a property value)
      • "prop_name IS NOT NULL"

      JMS providers are required to verify the syntactic correctness of a message selector at the time it is presented. A method that provides a syntactically incorrect selector must result in a JMSException. JMS providers may also optionally provide some semantic checking at the time the selector is presented. Not all semantic checking can be performed at the time a message selector is presented, because property types are not known.

      The following message selector selects messages with a message type of car and color of blue and weight greater than 2500 pounds:

      "JMSType = 'car' AND color = 'blue' AND weight > 2500"

      Null Values

      As noted above, property values may be NULL. The evaluation of selector expressions containing NULL values is defined by SQL92 NULL semantics. A brief description of these semantics is provided here.

      SQL treats a NULL value as unknown. Comparison or arithmetic with an unknown value always yields an unknown value.

      The IS NULL and IS NOT NULL operators convert an unknown value into the respective TRUE and FALSE values.

      The boolean operators use three-valued logic as defined by the following tables:

      The definition of the AND operator

       | AND  |   T   |   F   |   U
       +------+-------+-------+-------
       |  T   |   T   |   F   |   U
       |  F   |   F   |   F   |   F
       |  U   |   U   |   F   |   U
       +------+-------+-------+-------
       

      The definition of the OR operator

       | OR   |   T   |   F   |   U
       +------+-------+-------+--------
       |  T   |   T   |   T   |   T
       |  F   |   T   |   F   |   U
       |  U   |   T   |   U   |   U
       +------+-------+-------+------- 
       

      The definition of the NOT operator

       | NOT
       +------+------
       |  T   |   F
       |  F   |   T
       |  U   |   U
       +------+-------
       

      Special Notes

      When used in a message selector, the JMSDeliveryMode header field is treated as having the values 'PERSISTENT' and 'NON_PERSISTENT'.

      Date and time values should use the standard long millisecond value. When a date or time literal is included in a message selector, it should be an integer literal for a millisecond value. The standard way to produce millisecond values is to use java.util.Calendar.

      Although SQL supports fixed decimal comparison and arithmetic, JMS message selectors do not. This is the reason for restricting exact numeric literals to those without a decimal (and the addition of numerics with a decimal as an alternate representation for approximate numeric values).

      SQL comments are not supported.

      Version:
      1.1 April 2, 2002
      Author:
      Mark Hapner, Rich Burridge, Kate Stout
      See Also:
      MessageConsumer.receive(), MessageConsumer.receive(long), MessageConsumer.receiveNoWait(), MessageListener.onMessage(Message), BytesMessage, MapMessage, ObjectMessage, StreamMessage, TextMessage

      Field Summary
      static int
      static int
      static long
       
      Method Summary
       void
       void
       void
       boolean
       byte
       double
       float
       int
       String
       byte[]
       int
       Destination
       long
       String
       int
       boolean
       Destination
       long
       String
       long
       Object
       Enumeration
       short
       String
       boolean
       void
       void
       void
       void
       void
       void
       void
       void
       void
       void
       void
       void
       void
       void
       void
       void
       void
       void
       void
       void
       

      Field Detail

      英文文档:

      DEFAULT_DELIVERY_MODE

      static final int DEFAULT_DELIVERY_MODE
      The message producer's default delivery mode is PERSISTENT.

      See Also:
      DeliveryMode.PERSISTENT, Constant Field Values


      英文文档:

      DEFAULT_PRIORITY

      static final int DEFAULT_PRIORITY
      The message producer's default priority is 4.

      See Also:
      Constant Field Values


      英文文档:

      DEFAULT_TIME_TO_LIVE

      static final long DEFAULT_TIME_TO_LIVE
      The message producer's default time to live is unlimited; the message never expires.

      See Also:
      Constant Field Values

      Method Detail

      public String getJMSMessageID() throws JMSException
      获取消息 ID。

      JMSMessageID 头字段包含唯一标识提供者所发送的每个消息的值。

      发送消息时,可以忽略 JMSMessageIDsendpublish 方法返回时,它包含一个提供者分配的值。

      JMSMessageID 是一个 String 值,应该用作历史存储库中标识消息的唯一键。唯一性的确切范围是提供者定义的。它至少应该涵盖用于提供者特定安装的所有消息,其中安装是一些连接的消息路由器集合。

      所有 JMSMessageID 值必须以前缀 'ID:' 开头。不同提供者之间不需要保证消息 ID 值的唯一性。

      由于消息 ID 会创建并增加消息的大小,因此,如果能获得应用程序无需使用消息 ID 的提示,那么一些 JMS 提供者可以优化消息开销。通过调用 MessageProducer.setDisableMessageID 方法,JMS 客户端对该消息生成方发送的所有消息实现了这一潜在的优化。如果 JMS 提供者接受此提示,则这些消息必须将消息 ID 设置为 null;如果提供者忽略该提示,则消息 ID 必须设置为唯一的普通值。

      return 消息 ID
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取消息 ID。
      See also setJMSMessageID(String), setDisableMessageID(boolean)

      英文文档:

      getJMSMessageID

      String getJMSMessageID()
                             throws JMSException
      Gets the message ID.

      The JMSMessageID header field contains a value that uniquely identifies each message sent by a provider.

      When a message is sent, JMSMessageID can be ignored. When the send or publish method returns, it contains a provider-assigned value.

      A JMSMessageID is a String value that should function as a unique key for identifying messages in a historical repository. The exact scope of uniqueness is provider-defined. It should at least cover all messages for a specific installation of a provider, where an installation is some connected set of message routers.

      All JMSMessageID values must start with the prefix 'ID:'. Uniqueness of message ID values across different providers is not required.

      Since message IDs take some effort to create and increase a message's size, some JMS providers may be able to optimize message overhead if they are given a hint that the message ID is not used by an application. By calling the MessageProducer.setDisableMessageID method, a JMS client enables this potential optimization for all messages sent by that message producer. If the JMS provider accepts this hint, these messages must have the message ID set to null; if the provider ignores the hint, the message ID must be set to its normal unique value.

      Returns:
      the message ID
      Throws:
      JMSException - if the JMS provider fails to get the message ID due to some internal error.
      See Also:
      setJMSMessageID(String), MessageProducer.setDisableMessageID(boolean)

      public void setJMSMessageID(String id) throws JMSException
      设置消息 ID。

      JMS 提供者在发送消息时设置此字段。此方法可以用来更改收到的消息的值。

      id 消息的 ID
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置消息 ID。
      See also getJMSMessageID()

      英文文档:

      setJMSMessageID

      void setJMSMessageID(String id)
                           throws JMSException
      Sets the message ID.

      JMS providers set this field when a message is sent. This method can be used to change the value for a message that has been received.

      Parameters:
      id - the ID of the message
      Throws:
      JMSException - if the JMS provider fails to set the message ID due to some internal error.
      See Also:
      getJMSMessageID()

      public long getJMSTimestamp() throws JMSException
      获取消息时间戳。

      JMSTimestamp 头字段包含消息交给提供者发送的时间。它不是实际传输消息的时间,因为由于事务或其他客户端消息排队等原因,实际发送可能延后。

      发送消息时,忽略 JMSTimestamp。当 sendpublish 方法返回时,它包含的时间值介于调用和返回的时间之间。该值采用 Java 编程语言中普通的毫秒时间值格式。

      由于时间戳会创建并增加消息的大小,因此,如果能获得应用程序无需使用时间戳的提示,那么一些 JMS 提供者可以优化消息开销。通过调用 MessageProducer.setDisableMessageTimestamp 方法,JMS 客户端对该消息生成方发送的所有消息实现了这一潜在的优化。如果 JMS 提供者接受此提示,这些消息必须将时间戳设置为 0;如果提供者忽略该提示,则时间戳必须设置为普通值。

      return 消息时间戳
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取时间戳。
      See also setJMSTimestamp(long), setDisableMessageTimestamp(boolean)

      英文文档:

      getJMSTimestamp

      long getJMSTimestamp()
                           throws JMSException
      Gets the message timestamp.

      The JMSTimestamp header field contains the time a message was handed off to a provider to be sent. It is not the time the message was actually transmitted, because the actual send may occur later due to transactions or other client-side queueing of messages.

      When a message is sent, JMSTimestamp is ignored. When the send or publish method returns, it contains a time value somewhere in the interval between the call and the return. The value is in the format of a normal millis time value in the Java programming language.

      Since timestamps take some effort to create and increase a message's size, some JMS providers may be able to optimize message overhead if they are given a hint that the timestamp is not used by an application. By calling the MessageProducer.setDisableMessageTimestamp method, a JMS client enables this potential optimization for all messages sent by that message producer. If the JMS provider accepts this hint, these messages must have the timestamp set to zero; if the provider ignores the hint, the timestamp must be set to its normal value.

      Returns:
      the message timestamp
      Throws:
      JMSException - if the JMS provider fails to get the timestamp due to some internal error.
      See Also:
      setJMSTimestamp(long), MessageProducer.setDisableMessageTimestamp(boolean)

      public void setJMSTimestamp(long timestamp) throws JMSException
      设置消息时间戳。

      JMS 提供者在发送消息时设置此字段。此方法可以用来更改收到的消息的值。

      timestamp 此消息的时间戳
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置时间戳。
      See also getJMSTimestamp()

      英文文档:

      setJMSTimestamp

      void setJMSTimestamp(long timestamp)
                           throws JMSException
      Sets the message timestamp.

      JMS providers set this field when a message is sent. This method can be used to change the value for a message that has been received.

      Parameters:
      timestamp - the timestamp for this message
      Throws:
      JMSException - if the JMS provider fails to set the timestamp due to some internal error.
      See Also:
      getJMSTimestamp()

      public byte[] getJMSCorrelationIDAsBytes() throws JMSException
      以 byte 数组的形式获取消息的关联 ID。

      JMSCorrelationID 使用 byte[] 值是不可移植的。

      return byte 数组形式的消息关联 ID
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取关联 ID。
      See also setJMSCorrelationID(String), getJMSCorrelationID(), setJMSCorrelationIDAsBytes(byte[])

      英文文档:

      getJMSCorrelationIDAsBytes

      byte[] getJMSCorrelationIDAsBytes()
                                        throws JMSException
      Gets the correlation ID as an array of bytes for the message.

      The use of a byte[] value for JMSCorrelationID is non-portable.

      Returns:
      the correlation ID of a message as an array of bytes
      Throws:
      JMSException - if the JMS provider fails to get the correlation ID due to some internal error.
      See Also:
      setJMSCorrelationID(String), getJMSCorrelationID(), setJMSCorrelationIDAsBytes(byte[])

      public void setJMSCorrelationIDAsBytes(byte[] correlationID) throws JMSException
      以 byte 数组的形式设置消息的关联 ID。

      在方法返回之前复制数组,因此以后修改数组将不会改变此消息头。

      如果提供者支持本机关联 ID,JMS 客户端可能需要分配特定的 JMSCorrelationID 值,以匹配本机消息传递客户端所期望的关联 ID。没有本机关联 ID 的 JMS 提供者不必支持此方法及其相应的获取方法;其实现可能抛出 java.lang.UnsupportedOperationException

      JMSCorrelationID 使用 byte[] 值是不可移植的。

      correlationID byte 数组形式的关联 ID
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置关联 ID。
      See also setJMSCorrelationID(String), getJMSCorrelationID(), getJMSCorrelationIDAsBytes()

      英文文档:

      setJMSCorrelationIDAsBytes

      void setJMSCorrelationIDAsBytes(byte[] correlationID)
                                      throws JMSException
      Sets the correlation ID as an array of bytes for the message.

      The array is copied before the method returns, so future modifications to the array will not alter this message header.

      If a provider supports the native concept of correlation ID, a JMS client may need to assign specific JMSCorrelationID values to match those expected by native messaging clients. JMS providers without native correlation ID values are not required to support this method and its corresponding get method; their implementation may throw a java.lang.UnsupportedOperationException.

      The use of a byte[] value for JMSCorrelationID is non-portable.

      Parameters:
      correlationID - the correlation ID value as an array of bytes
      Throws:
      JMSException - if the JMS provider fails to set the correlation ID due to some internal error.
      See Also:
      setJMSCorrelationID(String), getJMSCorrelationID(), getJMSCorrelationIDAsBytes()

      public void setJMSCorrelationID(String correlationID) throws JMSException
      设置消息的关联 ID。

      客户端可以使用 JMSCorrelationID 头字段连接一个消息与另一个消息。一种典型用法是连接响应消息与其请求消息。

      JMSCorrelationID 可以保存以下值之一:

      • 特定于提供者的消息 ID
      • 特定于应用程序的 String
      • 提供者-本机 byte[]

      由于 JMS 提供者发送的每个消息都分配了一个消息 ID 值,因此可以很方便地通过消息 ID 连接消息。所有消息 ID 值必须以 'ID:' 前缀开头。

      在某些情况下,应用程序(由几个客户端组成)需要使用特定于应用程序的值来连接消息。例如,应用程序可以使用 JMSCorrelationID 来保存引用某些外部信息的值。特定于应用程序的值不得以 'ID:' 前缀开头;这是为提供者生成的消息 ID 值而保留的。

      如果提供者支持本机关联 ID,JMS 客户端可能需要分配特定的 JMSCorrelationID 值,以匹配不使用 JMS API 的客户端所期望的关联 ID。byte[] 值可用于此目的。没有本机关联 ID 值的 JMS 提供者不必支持 byte[] 值。对 JMSCorrelationID 使用 byte[] 值是不可移植的。

      correlationID 所引用消息的消息 ID
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置关联 ID。
      See also getJMSCorrelationID(), getJMSCorrelationIDAsBytes(), setJMSCorrelationIDAsBytes(byte[])

      英文文档:

      setJMSCorrelationID

      void setJMSCorrelationID(String correlationID)
                               throws JMSException
      Sets the correlation ID for the message.

      A client can use the JMSCorrelationID header field to link one message with another. A typical use is to link a response message with its request message.

      JMSCorrelationID can hold one of the following:

      • A provider-specific message ID
      • An application-specific String
      • A provider-native byte[] value

      Since each message sent by a JMS provider is assigned a message ID value, it is convenient to link messages via message ID. All message ID values must start with the 'ID:' prefix.

      In some cases, an application (made up of several clients) needs to use an application-specific value for linking messages. For instance, an application may use JMSCorrelationID to hold a value referencing some external information. Application-specified values must not start with the 'ID:' prefix; this is reserved for provider-generated message ID values.

      If a provider supports the native concept of correlation ID, a JMS client may need to assign specific JMSCorrelationID values to match those expected by clients that do not use the JMS API. A byte[] value is used for this purpose. JMS providers without native correlation ID values are not required to support byte[] values. The use of a byte[] value for JMSCorrelationID is non-portable.

      Parameters:
      correlationID - the message ID of a message being referred to
      Throws:
      JMSException - if the JMS provider fails to set the correlation ID due to some internal error.
      See Also:
      getJMSCorrelationID(), getJMSCorrelationIDAsBytes(), setJMSCorrelationIDAsBytes(byte[])

      public String getJMSCorrelationID() throws JMSException
      获取消息的关联 ID。

      此方法用于返回属于特定于提供者的消息 ID 或特定于应用程序的 String 值的关联 ID 值。

      return String 形式的消息关联 ID
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取关联 ID。
      See also setJMSCorrelationID(String), getJMSCorrelationIDAsBytes(), setJMSCorrelationIDAsBytes(byte[])

      英文文档:

      getJMSCorrelationID

      String getJMSCorrelationID()
                                 throws JMSException
      Gets the correlation ID for the message.

      This method is used to return correlation ID values that are either provider-specific message IDs or application-specific String values.

      Returns:
      the correlation ID of a message as a String
      Throws:
      JMSException - if the JMS provider fails to get the correlation ID due to some internal error.
      See Also:
      setJMSCorrelationID(String), getJMSCorrelationIDAsBytes(), setJMSCorrelationIDAsBytes(byte[])

      public Destination getJMSReplyTo() throws JMSException
      获取 Destination 对象,应向该对象发送对此消息的应答。
      return Destination,将向其发送对此消息的响应
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取 JMSReplyTo 目的地。
      See also setJMSReplyTo(Destination)
      英文文档:

      getJMSReplyTo

      Destination getJMSReplyTo()
                                throws JMSException
      Gets the Destination object to which a reply to this message should be sent.

      Returns:
      Destination to which to send a response to this message
      Throws:
      JMSException - if the JMS provider fails to get the JMSReplyTo destination due to some internal error.
      See Also:
      setJMSReplyTo(Destination)

      public void setJMSReplyTo(Destination replyTo) throws JMSException
      设置 Destination 对象,应向该对象发送对此消息的应答。

      JMSReplyTo 头字段包含对当前消息的应答应发送到的目的地。如果它为 null,则不希望应答。目的地可以是 Queue 对象或 Topic 对象。

      发送时附带 null JMSReplyTo 值的消息可能是某些事件的通知,也可能只是一些发送方认为有意义的数据。

      JMSReplyTo 值的消息通常希望获得响应。如果响应是可选的,则由客户端决定是否响应。这些消息称为请求。响应请求的消息称为应答。

      在某些情况下,客户端可能希望刚刚收到的应答与之前发送的请求匹配。为此,客户端可以使用 JMSCorrelationID 头字段。

      replyTo Destination,将向其发送对此消息的响应
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置 JMSReplyTo 目的地。
      See also getJMSReplyTo()

      英文文档:

      setJMSReplyTo

      void setJMSReplyTo(Destination replyTo)
                         throws JMSException
      Sets the Destination object to which a reply to this message should be sent.

      The JMSReplyTo header field contains the destination where a reply to the current message should be sent. If it is null, no reply is expected. The destination may be either a Queue object or a Topic object.

      Messages sent with a null JMSReplyTo value may be a notification of some event, or they may just be some data the sender thinks is of interest.

      Messages with a JMSReplyTo value typically expect a response. A response is optional; it is up to the client to decide. These messages are called requests. A message sent in response to a request is called a reply.

      In some cases a client may wish to match a request it sent earlier with a reply it has just received. The client can use the JMSCorrelationID header field for this purpose.

      Parameters:
      replyTo - Destination to which to send a response to this message
      Throws:
      JMSException - if the JMS provider fails to set the JMSReplyTo destination due to some internal error.
      See Also:
      getJMSReplyTo()

      public Destination getJMSDestination() throws JMSException
      获取此消息的 Destination 对象。

      JMSDestination 头字段包含消息将要发送到的目的地。

      发送消息时,忽略此字段。在完成 sendpublish 方法后,该字段将保存方法指定的目的地。

      接收消息时,其 JMSDestination 值必须与发送消息时分配的值相等。

      return 此消息的目的地
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取目的地。
      See also setJMSDestination(Destination)

      英文文档:

      getJMSDestination

      Destination getJMSDestination()
                                    throws JMSException
      Gets the Destination object for this message.

      The JMSDestination header field contains the destination to which the message is being sent.

      When a message is sent, this field is ignored. After completion of the send or publish method, the field holds the destination specified by the method.

      When a message is received, its JMSDestination value must be equivalent to the value assigned when it was sent.

      Returns:
      the destination of this message
      Throws:
      JMSException - if the JMS provider fails to get the destination due to some internal error.
      See Also:
      setJMSDestination(Destination)

      public void setJMSDestination(Destination destination) throws JMSException
      设置此消息的 Destination 对象。

      JMS 提供者在发送消息时设置此字段。此方法可以用来更改收到的消息的值。

      destination 此消息的目的地
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置目的地。
      See also getJMSDestination()

      英文文档:

      setJMSDestination

      void setJMSDestination(Destination destination)
                             throws JMSException
      Sets the Destination object for this message.

      JMS providers set this field when a message is sent. This method can be used to change the value for a message that has been received.

      Parameters:
      destination - the destination for this message
      Throws:
      JMSException - if the JMS provider fails to set the destination due to some internal error.
      See Also:
      getJMSDestination()

      public int getJMSDeliveryMode() throws JMSException
      获取为此消息指定的 DeliveryMode 值。
      return 此消息的传送模式
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取传送模式。
      See also setJMSDeliveryMode(int), javax.jms.DeliveryMode
      英文文档:

      getJMSDeliveryMode

      int getJMSDeliveryMode()
                             throws JMSException
      Gets the DeliveryMode value specified for this message.

      Returns:
      the delivery mode for this message
      Throws:
      JMSException - if the JMS provider fails to get the delivery mode due to some internal error.
      See Also:
      setJMSDeliveryMode(int), DeliveryMode

      public void setJMSDeliveryMode(int deliveryMode) throws JMSException
      设置此消息的 DeliveryMode 值。

      JMS 提供者在发送消息时设置此字段。此方法可以用来更改收到的消息的值。

      deliveryMode 此消息的传送模式
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置传送模式。
      See also getJMSDeliveryMode(), javax.jms.DeliveryMode

      英文文档:

      setJMSDeliveryMode

      void setJMSDeliveryMode(int deliveryMode)
                              throws JMSException
      Sets the DeliveryMode value for this message.

      JMS providers set this field when a message is sent. This method can be used to change the value for a message that has been received.

      Parameters:
      deliveryMode - the delivery mode for this message
      Throws:
      JMSException - if the JMS provider fails to set the delivery mode due to some internal error.
      See Also:
      getJMSDeliveryMode(), DeliveryMode

      public boolean getJMSRedelivered() throws JMSException
      获取是否重新传送此消息的指示。

      如果客户端收到设置了 JMSRedelivered 字段的消息,则有可能(但不保证)之前发送此消息时没有得到接收方的确认。

      return 如果要重新传送此消息,则返回 true
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取重新传送状态。
      See also setJMSRedelivered(boolean)

      英文文档:

      getJMSRedelivered

      boolean getJMSRedelivered()
                                throws JMSException
      Gets an indication of whether this message is being redelivered.

      If a client receives a message with the JMSRedelivered field set, it is likely, but not guaranteed, that this message was delivered earlier but that its receipt was not acknowledged at that time.

      Returns:
      true if this message is being redelivered
      Throws:
      JMSException - if the JMS provider fails to get the redelivered state due to some internal error.
      See Also:
      setJMSRedelivered(boolean)

      public void setJMSRedelivered(boolean redelivered) throws JMSException
      指定是否重新传送此消息。

      此字段在传送消息时设置。此方法可以用来更改收到的消息的值。

      redelivered 是否重新传送此消息的指示
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置重新传送状态。
      See also getJMSRedelivered()

      英文文档:

      setJMSRedelivered

      void setJMSRedelivered(boolean redelivered)
                             throws JMSException
      Specifies whether this message is being redelivered.

      This field is set at the time the message is delivered. This method can be used to change the value for a message that has been received.

      Parameters:
      redelivered - an indication of whether this message is being redelivered
      Throws:
      JMSException - if the JMS provider fails to set the redelivered state due to some internal error.
      See Also:
      getJMSRedelivered()

      public String getJMSType() throws JMSException
      获取发送消息时客户端提供的消息类型标识符。
      return 消息类型
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取消息类型。
      See also setJMSType(String)
      英文文档:

      getJMSType

      String getJMSType()
                        throws JMSException
      Gets the message type identifier supplied by the client when the message was sent.

      Returns:
      the message type
      Throws:
      JMSException - if the JMS provider fails to get the message type due to some internal error.
      See Also:
      setJMSType(String)

      public void setJMSType(String type) throws JMSException
      设置消息类型。

      某些 JMS 提供者使用包含应用程序所发送消息的定义的消息存储库。JMSType 头字段可以引用提供者存储库中的消息定义。

      JMS API 不定义标准消息定义存储库,也不定义所含定义的命名策略。

      某些消息传递系统要求创建每个应用程序消息的消息类型定义,并要求每个消息指定其类型。为了使用此类 JMS 提供者,JMS 客户端应给 JMSType 分配一个值,无论应用程序是否使用它。这确保为需要它的那些提供者正确地设置了字段。

      为确保可移植性,JMS 客户端应使用 JMSType 的符号值,该值在安装期间可以配置为当前提供者消息存储库中定义的值。如果使用字符串字面值,则它们对于某些 JMS 提供者可能不是有效的类型名。

      type 消息类型
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置消息类型。
      See also getJMSType()

      英文文档:

      setJMSType

      void setJMSType(String type)
                      throws JMSException
      Sets the message type.

      Some JMS providers use a message repository that contains the definitions of messages sent by applications. The JMSType header field may reference a message's definition in the provider's repository.

      The JMS API does not define a standard message definition repository, nor does it define a naming policy for the definitions it contains.

      Some messaging systems require that a message type definition for each application message be created and that each message specify its type. In order to work with such JMS providers, JMS clients should assign a value to JMSType, whether the application makes use of it or not. This ensures that the field is properly set for those providers that require it.

      To ensure portability, JMS clients should use symbolic values for JMSType that can be configured at installation time to the values defined in the current provider's message repository. If string literals are used, they may not be valid type names for some JMS providers.

      Parameters:
      type - the message type
      Throws:
      JMSException - if the JMS provider fails to set the message type due to some internal error.
      See Also:
      getJMSType()

      public long getJMSExpiration() throws JMSException
      获取消息的到期时间。

      发送消息时,不分配 JMSExpiration 头字段。在完成 sendpublish 方法后,它保存消息的到期时间。这是客户端指定的生存时间值和调用 sendpublish 时的 GMT 之和。

      如果生存时间指定为 0,则将 JMSExpiration 设置为 0 以指示消息不过期。

      到达消息的到期时间时,提供者应丢弃该消息。JMS API 不定义任何形式的消息到期通知。

      客户端不应接收已到期的消息;但是,JMS API 不保证一定不会发生这种情况。

      return 消息到期的时间,它是客户端指定的生存时间值和发送时的 GMT 之和
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取消息到期时间。
      See also setJMSExpiration(long)

      英文文档:

      getJMSExpiration

      long getJMSExpiration()
                            throws JMSException
      Gets the message's expiration value.

      When a message is sent, the JMSExpiration header field is left unassigned. After completion of the send or publish method, it holds the expiration time of the message. This is the sum of the time-to-live value specified by the client and the GMT at the time of the send or publish.

      If the time-to-live is specified as zero, JMSExpiration is set to zero to indicate that the message does not expire.

      When a message's expiration time is reached, a provider should discard it. The JMS API does not define any form of notification of message expiration.

      Clients should not receive messages that have expired; however, the JMS API does not guarantee that this will not happen.

      Returns:
      the time the message expires, which is the sum of the time-to-live value specified by the client and the GMT at the time of the send
      Throws:
      JMSException - if the JMS provider fails to get the message expiration due to some internal error.
      See Also:
      setJMSExpiration(long)

      public void setJMSExpiration(long expiration) throws JMSException
      设置消息的到期时间。

      JMS 提供者在发送消息时设置此字段。此方法可以用来更改收到的消息的值。

      expiration 消息的到期时间
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置消息到期时间。
      See also getJMSExpiration()

      英文文档:

      setJMSExpiration

      void setJMSExpiration(long expiration)
                            throws JMSException
      Sets the message's expiration value.

      JMS providers set this field when a message is sent. This method can be used to change the value for a message that has been received.

      Parameters:
      expiration - the message's expiration time
      Throws:
      JMSException - if the JMS provider fails to set the message expiration due to some internal error.
      See Also:
      getJMSExpiration()

      public int getJMSPriority() throws JMSException
      获取消息优先级别。

      JMS API 定义 10 个优先级值,0 表示最低优先级,9 表示最高优先级。此外,客户端应考虑将优先级 0-4 作为正常优先级等级,将优先级 5-9 作为加速优先级等级。

      JMS API 不要求提供者严格实现消息的优先级顺序;但是,提供者应尽可能在正常消息之前传送加速消息。

      return 默认消息优先级
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取消息优先级。
      See also setJMSPriority(int)

      英文文档:

      getJMSPriority

      int getJMSPriority()
                         throws JMSException
      Gets the message priority level.

      The JMS API defines ten levels of priority value, with 0 as the lowest priority and 9 as the highest. In addition, clients should consider priorities 0-4 as gradations of normal priority and priorities 5-9 as gradations of expedited priority.

      The JMS API does not require that a provider strictly implement priority ordering of messages; however, it should do its best to deliver expedited messages ahead of normal messages.

      Returns:
      the default message priority
      Throws:
      JMSException - if the JMS provider fails to get the message priority due to some internal error.
      See Also:
      setJMSPriority(int)

      public void setJMSPriority(int priority) throws JMSException
      设置此消息的优先级别。

      JMS 提供者在发送消息时设置此字段。此方法可以用来更改收到的消息的值。

      priority 此消息的优先级
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置消息优先级。
      See also getJMSPriority()

      英文文档:

      setJMSPriority

      void setJMSPriority(int priority)
                          throws JMSException
      Sets the priority level for this message.

      JMS providers set this field when a message is sent. This method can be used to change the value for a message that has been received.

      Parameters:
      priority - the priority of this message
      Throws:
      JMSException - if the JMS provider fails to set the message priority due to some internal error.
      See Also:
      getJMSPriority()

      public void clearProperties() throws JMSException
      清除消息的属性。

      不清除消息的头字段和正文。

      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法清除消息属性。

      英文文档:

      clearProperties

      void clearProperties()
                           throws JMSException
      Clears a message's properties.

      The message's header fields and body are not cleared.

      Throws:
      JMSException - if the JMS provider fails to clear the message properties due to some internal error.

      public boolean propertyExists(String name) throws JMSException
      指示是否存在属性值。
      name 要测试的属性的名称。
      return 如果属性存在,则返回 true
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法确定是否存在该属性。
      英文文档:

      propertyExists

      boolean propertyExists(String name)
                             throws JMSException
      Indicates whether a property value exists.

      Parameters:
      name - the name of the property to test
      Returns:
      true if the property exists
      Throws:
      JMSException - if the JMS provider fails to determine if the property exists due to some internal error.

      public boolean getBooleanProperty(String name) throws JMSException
      返回带指定名称的 boolean 属性的值。
      name boolean 属性的名称。
      return 指定名称的 boolean 属性值。
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取属性值。
      ThrowsMessageFormatException: 如果此类型转换无效。
      英文文档:

      getBooleanProperty

      boolean getBooleanProperty(String name)
                                 throws JMSException
      Returns the value of the boolean property with the specified name.

      Parameters:
      name - the name of the boolean property
      Returns:
      the boolean property value for the specified name
      Throws:
      JMSException - if the JMS provider fails to get the property value due to some internal error.
      MessageFormatException - if this type conversion is invalid.

      public byte getByteProperty(String name) throws JMSException
      返回带指定名称的 byte 属性的值。
      name byte 属性的名称
      return 指定名称的 byte 属性值
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取属性值。
      ThrowsMessageFormatException: 如果此类型转换无效。
      英文文档:

      getByteProperty

      byte getByteProperty(String name)
                           throws JMSException
      Returns the value of the byte property with the specified name.

      Parameters:
      name - the name of the byte property
      Returns:
      the byte property value for the specified name
      Throws:
      JMSException - if the JMS provider fails to get the property value due to some internal error.
      MessageFormatException - if this type conversion is invalid.

      public short getShortProperty(String name) throws JMSException
      返回带指定名称的 short 属性的值。
      name short 属性的名称
      return 指定名称的 short 属性值
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取属性值。
      ThrowsMessageFormatException: 如果此类型转换无效。
      英文文档:

      getShortProperty

      short getShortProperty(String name)
                             throws JMSException
      Returns the value of the short property with the specified name.

      Parameters:
      name - the name of the short property
      Returns:
      the short property value for the specified name
      Throws:
      JMSException - if the JMS provider fails to get the property value due to some internal error.
      MessageFormatException - if this type conversion is invalid.

      public int getIntProperty(String name) throws JMSException
      返回带指定名称的 int 属性的值。
      name int 属性的名称
      return 指定名称的 int 属性值
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取属性值。
      ThrowsMessageFormatException: 如果此类型转换无效。
      英文文档:

      getIntProperty

      int getIntProperty(String name)
                         throws JMSException
      Returns the value of the int property with the specified name.

      Parameters:
      name - the name of the int property
      Returns:
      the int property value for the specified name
      Throws:
      JMSException - if the JMS provider fails to get the property value due to some internal error.
      MessageFormatException - if this type conversion is invalid.

      public long getLongProperty(String name) throws JMSException
      返回带指定名称的 long 属性的值。
      name long 属性的名称。
      return 指定名称的 long 属性值
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取属性值。
      ThrowsMessageFormatException: 如果此类型转换无效。
      英文文档:

      getLongProperty

      long getLongProperty(String name)
                           throws JMSException
      Returns the value of the long property with the specified name.

      Parameters:
      name - the name of the long property
      Returns:
      the long property value for the specified name
      Throws:
      JMSException - if the JMS provider fails to get the property value due to some internal error.
      MessageFormatException - if this type conversion is invalid.

      public float getFloatProperty(String name) throws JMSException
      返回带指定名称的 float 属性的值。
      name float 属性的名称
      return 指定名称的 float 属性值
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取属性值。
      ThrowsMessageFormatException: 如果此类型转换无效。
      英文文档:

      getFloatProperty

      float getFloatProperty(String name)
                             throws JMSException
      Returns the value of the float property with the specified name.

      Parameters:
      name - the name of the float property
      Returns:
      the float property value for the specified name
      Throws:
      JMSException - if the JMS provider fails to get the property value due to some internal error.
      MessageFormatException - if this type conversion is invalid.

      public double getDoubleProperty(String name) throws JMSException
      返回带指定名称的 double 属性的值。
      name double 属性的名称
      return 指定名称的 double 属性值
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取属性值。
      ThrowsMessageFormatException: 如果此类型转换无效。
      英文文档:

      getDoubleProperty

      double getDoubleProperty(String name)
                               throws JMSException
      Returns the value of the double property with the specified name.

      Parameters:
      name - the name of the double property
      Returns:
      the double property value for the specified name
      Throws:
      JMSException - if the JMS provider fails to get the property value due to some internal error.
      MessageFormatException - if this type conversion is invalid.

      public String getStringProperty(String name) throws JMSException
      返回带指定名称的 String 属性的值。
      name String 属性的名称
      return 指定名称的 String 属性值;如果不存在此名称的属性,则返回 null 值
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取属性值。
      ThrowsMessageFormatException: 如果此类型转换无效。
      英文文档:

      getStringProperty

      String getStringProperty(String name)
                               throws JMSException
      Returns the value of the String property with the specified name.

      Parameters:
      name - the name of the String property
      Returns:
      the String property value for the specified name; if there is no property by this name, a null value is returned
      Throws:
      JMSException - if the JMS provider fails to get the property value due to some internal error.
      MessageFormatException - if this type conversion is invalid.

      public Object getObjectProperty(String name) throws JMSException
      返回带指定名称的 Java 对象属性的值。

      此方法可以用于以对象化格式返回作为属性存储在消息中(通过调用等效的 setObjectProperty 方法或等效的基本方法 settypeProperty)的对象。

      name Java 对象属性的名称
      return 以对象化格式返回带指定名称的 Java 对象属性值(例如,如果属性设置为 int,则返回 Integer);如果不存在此名称的属性,则返回 null 值
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取属性值。

      英文文档:

      getObjectProperty

      Object getObjectProperty(String name)
                               throws JMSException
      Returns the value of the Java object property with the specified name.

      This method can be used to return, in objectified format, an object that has been stored as a property in the message with the equivalent setObjectProperty method call, or its equivalent primitive settypeProperty method.

      Parameters:
      name - the name of the Java object property
      Returns:
      the Java object property value with the specified name, in objectified format (for example, if the property was set as an int, an Integer is returned); if there is no property by this name, a null value is returned
      Throws:
      JMSException - if the JMS provider fails to get the property value due to some internal error.

      public java.util.Enumeration<E> getPropertyNames() throws JMSException
      返回所有属性名称的 Enumeration

      注意,JMS 标准头字段不视为属性,不在此枚举中返回。

      return 所有属性值名称的枚举
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法获取属性名称。

      英文文档:

      getPropertyNames

      Enumeration getPropertyNames()
                                   throws JMSException
      Returns an Enumeration of all the property names.

      Note that JMS standard header fields are not considered properties and are not returned in this enumeration.

      Returns:
      an enumeration of all the names of property values
      Throws:
      JMSException - if the JMS provider fails to get the property names due to some internal error.

      public void setBooleanProperty(String name, boolean value) throws JMSException
      将带指定名称的 boolean 属性值设置到消息中。
      name boolean 属性的名称。
      value 要设置的 boolean 属性值
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置属性值。
      ThrowsIllegalArgumentException: 如果名称为 null,或者名称为空字符串。
      ThrowsMessageNotWriteableException: 如果属性是只读的
      英文文档:

      setBooleanProperty

      void setBooleanProperty(String name,
                              boolean value)
                              throws JMSException
      Sets a boolean property value with the specified name into the message.

      Parameters:
      name - the name of the boolean property
      value - the boolean property value to set
      Throws:
      JMSException - if the JMS provider fails to set the property due to some internal error.
      IllegalArgumentException - if the name is null or if the name is an empty string.
      MessageNotWriteableException - if properties are read-only

      public void setByteProperty(String name, byte value) throws JMSException
      将带指定名称的 byte 属性值设置到消息中。
      name byte 属性的名称
      value 要设置的 byte 属性值
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置属性值。
      ThrowsIllegalArgumentException: 如果名称为 null,或者名称为空字符串。
      ThrowsMessageNotWriteableException: 如果属性是只读的
      英文文档:

      setByteProperty

      void setByteProperty(String name,
                           byte value)
                           throws JMSException
      Sets a byte property value with the specified name into the message.

      Parameters:
      name - the name of the byte property
      value - the byte property value to set
      Throws:
      JMSException - if the JMS provider fails to set the property due to some internal error.
      IllegalArgumentException - if the name is null or if the name is an empty string.
      MessageNotWriteableException - if properties are read-only

      public void setShortProperty(String name, short value) throws JMSException
      将带指定名称的 short 属性值设置到消息中。
      name short 属性的名称
      value 要设置的 short 属性值
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置属性值。
      ThrowsIllegalArgumentException: 如果名称为 null,或者名称为空字符串。
      ThrowsMessageNotWriteableException: 如果属性是只读的
      英文文档:

      setShortProperty

      void setShortProperty(String name,
                            short value)
                            throws JMSException
      Sets a short property value with the specified name into the message.

      Parameters:
      name - the name of the short property
      value - the short property value to set
      Throws:
      JMSException - if the JMS provider fails to set the property due to some internal error.
      IllegalArgumentException - if the name is null or if the name is an empty string.
      MessageNotWriteableException - if properties are read-only

      public void setIntProperty(String name, int value) throws JMSException
      将带指定名称的 int 属性值设置到消息中。
      name int 属性的名称
      value 要设置的 int 属性值
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置属性值。
      ThrowsIllegalArgumentException: 如果名称为 null,或者名称为空字符串。
      ThrowsMessageNotWriteableException: 如果属性是只读的
      英文文档:

      setIntProperty

      void setIntProperty(String name,
                          int value)
                          throws JMSException
      Sets an int property value with the specified name into the message.

      Parameters:
      name - the name of the int property
      value - the int property value to set
      Throws:
      JMSException - if the JMS provider fails to set the property due to some internal error.
      IllegalArgumentException - if the name is null or if the name is an empty string.
      MessageNotWriteableException - if properties are read-only

      public void setLongProperty(String name, long value) throws JMSException
      将带指定名称的 long 属性值设置到消息中。
      name long 属性的名称。
      value 要设置的 long 属性值
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置属性值。
      ThrowsIllegalArgumentException: 如果名称为 null,或者名称为空字符串。
      ThrowsMessageNotWriteableException: 如果属性是只读的
      英文文档:

      setLongProperty

      void setLongProperty(String name,
                           long value)
                           throws JMSException
      Sets a long property value with the specified name into the message.

      Parameters:
      name - the name of the long property
      value - the long property value to set
      Throws:
      JMSException - if the JMS provider fails to set the property due to some internal error.
      IllegalArgumentException - if the name is null or if the name is an empty string.
      MessageNotWriteableException - if properties are read-only

      public void setFloatProperty(String name, float value) throws JMSException
      将带指定名称的 float 属性值设置到消息中。
      name float 属性的名称
      value 要设置的 float 属性值
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置属性值。
      ThrowsIllegalArgumentException: 如果名称为 null,或者名称为空字符串。
      ThrowsMessageNotWriteableException: 如果属性是只读的
      英文文档:

      setFloatProperty

      void setFloatProperty(String name,
                            float value)
                            throws JMSException
      Sets a float property value with the specified name into the message.

      Parameters:
      name - the name of the float property
      value - the float property value to set
      Throws:
      JMSException - if the JMS provider fails to set the property due to some internal error.
      IllegalArgumentException - if the name is null or if the name is an empty string.
      MessageNotWriteableException - if properties are read-only

      public void setDoubleProperty(String name, double value) throws JMSException
      将带指定名称的 double 属性值设置到消息中。
      name double 属性的名称
      value 要设置的 double 属性值
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置属性值。
      ThrowsIllegalArgumentException: 如果名称为 null,或者名称为空字符串。
      ThrowsMessageNotWriteableException: 如果属性是只读的
      英文文档:

      setDoubleProperty

      void setDoubleProperty(String name,
                             double value)
                             throws JMSException
      Sets a double property value with the specified name into the message.

      Parameters:
      name - the name of the double property
      value - the double property value to set
      Throws:
      JMSException - if the JMS provider fails to set the property due to some internal error.
      IllegalArgumentException - if the name is null or if the name is an empty string.
      MessageNotWriteableException - if properties are read-only

      public void setStringProperty(String name, String value) throws JMSException
      将带指定名称的 String 属性值设置到消息中。
      name String 属性的名称
      value 要设置的 String 属性值
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置属性值。
      ThrowsIllegalArgumentException: 如果名称为 null,或者名称为空字符串。
      ThrowsMessageNotWriteableException: 如果属性是只读的
      英文文档:

      setStringProperty

      void setStringProperty(String name,
                             String value)
                             throws JMSException
      Sets a String property value with the specified name into the message.

      Parameters:
      name - the name of the String property
      value - the String property value to set
      Throws:
      JMSException - if the JMS provider fails to set the property due to some internal error.
      IllegalArgumentException - if the name is null or if the name is an empty string.
      MessageNotWriteableException - if properties are read-only

      public void setObjectProperty(String name, Object value) throws JMSException
      将带指定名称的 Java 对象属性值设置到消息中。

      注意,此方法仅用于对象化的基本对象类型(IntegerDoubleLong 等)和 String 对象。

      name Java 对象属性的名称
      value 要设置的 Java 对象属性值
      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法设置属性值。
      ThrowsIllegalArgumentException: 如果名称为 null,或者名称为空字符串。
      ThrowsMessageFormatException: 如果对象无效
      ThrowsMessageNotWriteableException: 如果属性是只读的

      英文文档:

      setObjectProperty

      void setObjectProperty(String name,
                             Object value)
                             throws JMSException
      Sets a Java object property value with the specified name into the message.

      Note that this method works only for the objectified primitive object types (Integer, Double, Long ...) and String objects.

      Parameters:
      name - the name of the Java object property
      value - the Java object property value to set
      Throws:
      JMSException - if the JMS provider fails to set the property due to some internal error.
      IllegalArgumentException - if the name is null or if the name is an empty string.
      MessageFormatException - if the object is invalid
      MessageNotWriteableException - if properties are read-only

      public void acknowledge() throws JMSException
      确认此使用消息会话的所有使用消息。

      在客户端指定其 JMS 会话的使用消息要显式确认时,使用的所有 JMS 消息都支持使用 acknowledge 方法。通过对使用消息调用 acknowledge,客户端确认传送消息的会话所使用的所有消息。

      对于事务性会话和指定使用隐式确认模式的会话,对 acknowledge 的调用将被忽略。

      客户端可以在使用消息时分别确认每个消息,也可以选择以应用程序定义的分组形式确认消息(对每组收到的最后一个消息调用 acknowledge 即可完成,从而确认会话使用的所有消息。)

      可能会重新传送已经接收但没有得到确认的消息。

      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法确认消息。
      ThrowsIllegalStateException: 如果在关闭的会话上调用此方法。
      See also CLIENT_ACKNOWLEDGE

      英文文档:

      acknowledge

      void acknowledge()
                       throws JMSException
      Acknowledges all consumed messages of the session of this consumed message.

      All consumed JMS messages support the acknowledge method for use when a client has specified that its JMS session's consumed messages are to be explicitly acknowledged. By invoking acknowledge on a consumed message, a client acknowledges all messages consumed by the session that the message was delivered to.

      Calls to acknowledge are ignored for both transacted sessions and sessions specified to use implicit acknowledgement modes.

      A client may individually acknowledge each message as it is consumed, or it may choose to acknowledge messages as an application-defined group (which is done by calling acknowledge on the last received message of the group, thereby acknowledging all messages consumed by the session.)

      Messages that have been received but not acknowledged may be redelivered.

      Throws:
      JMSException - if the JMS provider fails to acknowledge the messages due to some internal error.
      IllegalStateException - if this method is called on a closed session.
      See Also:
      Session.CLIENT_ACKNOWLEDGE

      public void clearBody() throws JMSException
      清除消息正文。清除消息的正文不会清除其头值或属性条目。

      如果此消息正文为只读,则调用此方法将使消息正文的状态与新建消息的空正文状态相同。

      ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法清除消息正文。

      英文文档:

      clearBody

      void clearBody()
                     throws JMSException
      Clears out the message body. Clearing a message's body does not clear its header values or property entries.

      If this message body was read-only, calling this method leaves the message body in the same state as an empty body in a newly created message.

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