本文整理匯總了Java中javax.jms.Message.getJMSTimestamp方法的典型用法代碼示例。如果您正苦於以下問題:Java Message.getJMSTimestamp方法的具體用法?Java Message.getJMSTimestamp怎麽用?Java Message.getJMSTimestamp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.jms.Message
的用法示例。
在下文中一共展示了Message.getJMSTimestamp方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTtl
import javax.jms.Message; //導入方法依賴的package包/類
/**
* Calculate TTL of given message from message
* expiration time and message timestamp.
* <p/>
* 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
* EXP_TIME = CLIENT_SEND+TTL (CLIENT_SEND??)
* CLIENT_SEND time is approximately getJMSTimestamp() (time value between send()/publish() and return)
* TODO - check for correctness
*
* @param message calculate TTL for this message
* @return positive long number if TTL was calculated. Long.MIN_VALUE if error.
*/
public static long getTtl(Message message) {
long ttl = 0;
try {
long expiration = message.getJMSExpiration();
long timestamp = message.getJMSTimestamp();
if (expiration != 0 && timestamp != 0) {
ttl = expiration - timestamp;
}
} catch (JMSException jmse) {
LOG.error("Error while calculating TTL value.\n" + jmse.getMessage());
jmse.printStackTrace();
System.exit(1);
}
return ttl;
}