本文整理汇总了Java中javax.jms.Message.DEFAULT_DELIVERY_DELAY属性的典型用法代码示例。如果您正苦于以下问题:Java Message.DEFAULT_DELIVERY_DELAY属性的具体用法?Java Message.DEFAULT_DELIVERY_DELAY怎么用?Java Message.DEFAULT_DELIVERY_DELAY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.jms.Message
的用法示例。
在下文中一共展示了Message.DEFAULT_DELIVERY_DELAY属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: send
void send(MockJMSMessageProducer producer, Destination destination, Message message, int deliveryMode, int priority, long timeToLive, boolean disableMessageId, boolean disableTimestamp, long deliveryDelay, CompletionListener completionListener) throws JMSException {
sendLock.lock();
try {
message.setJMSDeliveryMode(deliveryMode);
message.setJMSPriority(priority);
message.setJMSRedelivered(false);
message.setJMSDestination(destination);
long timeStamp = System.currentTimeMillis();
boolean hasTTL = timeToLive > Message.DEFAULT_TIME_TO_LIVE;
boolean hasDelay = deliveryDelay > Message.DEFAULT_DELIVERY_DELAY;
if (!(message instanceof MockJMSMessage)) {
throw new IllegalStateException("Mock JMS client cannot handle foreign messages");
}
if (!disableTimestamp) {
message.setJMSTimestamp(timeStamp);
} else {
message.setJMSTimestamp(0);
}
if (hasTTL) {
message.setJMSExpiration(timeStamp + timeToLive);
} else {
message.setJMSExpiration(0);
}
long messageSequence = producer.getNextMessageSequence();
String messageId = null;
if (!disableMessageId) {
messageId = producer.getProducerId() + ":"+ messageSequence;
}
// Set the delivery time. Purposefully avoided doing this earlier so
// that we use the 'outbound' JmsMessage object reference when
// updating our own message instances, avoids using the interface
// in case the JMS 1.1 Message API is actually being used due to
// being on the classpath too.
long deliveryTime = timeStamp;
if (hasDelay) {
deliveryTime = timeStamp + deliveryDelay;
}
message.setJMSDeliveryTime(deliveryTime);
// Set the message ID
message.setJMSMessageID(messageId);
try {
connection.onMessageSend(this, message);
} catch (JMSException jmsEx) {
// If the synchronous portion of the send fails the completion be
// notified but might depending on the circumstances of the failures,
// remove it from the queue and check if is is already completed
// once we decide to add completion support to the mock
throw jmsEx;
}
} finally {
sendLock.unlock();
}
}