本文整理匯總了Java中javax.jms.Message.setJMSDeliveryMode方法的典型用法代碼示例。如果您正苦於以下問題:Java Message.setJMSDeliveryMode方法的具體用法?Java Message.setJMSDeliveryMode怎麽用?Java Message.setJMSDeliveryMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.jms.Message
的用法示例。
在下文中一共展示了Message.setJMSDeliveryMode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: send
import javax.jms.Message; //導入方法依賴的package包/類
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();
}
}