你的QQ是多少..有好多JMS不明白.还要向你请教

解决方案 »

  1.   

    JMSMessageID——类型为 string 
    惟一标识提供者发送的每一条消息。这个字段是在发送过程中由提供者设置的,客户机只能在消息发送后才能确定消息的 JMSMessageID。
    public void setJMSMessageID(java.lang.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.
    以上解释,说明messageID是由JMS provider来调用和设置的。我们自己在发送消息时调用是不起任何作用的。但是在接受到消息后,确实可以设置id的。
    getJMSMessageID
    public java.lang.String getJMSMessageID()
                                     throws JMSExceptionGets 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.