org.apache.activemq.artemis.api.core.Message.setExpiration()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(262)

本文整理了Java中org.apache.activemq.artemis.api.core.Message.setExpiration()方法的一些代码示例,展示了Message.setExpiration()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setExpiration()方法的具体详情如下:
包路径:org.apache.activemq.artemis.api.core.Message
类名称:Message
方法名:setExpiration

Message.setExpiration介绍

[英]Sets the expiration of this message.
[中]

代码示例

代码示例来源:origin: wildfly/wildfly

default void referenceOriginalMessage(final Message original, String originalQueue) {
 String queueOnMessage = original.getAnnotationString(Message.HDR_ORIGINAL_QUEUE);
 if (queueOnMessage != null) {
   setAnnotation(Message.HDR_ORIGINAL_QUEUE, queueOnMessage);
 } else if (originalQueue != null) {
   setAnnotation(Message.HDR_ORIGINAL_QUEUE, originalQueue);
 }
 Object originalID = original.getAnnotation(Message.HDR_ORIG_MESSAGE_ID);
 if (originalID != null) {
   setAnnotation(Message.HDR_ORIGINAL_ADDRESS, original.getAnnotationString(Message.HDR_ORIGINAL_ADDRESS));
   setAnnotation(Message.HDR_ORIG_MESSAGE_ID, originalID);
 } else {
   setAnnotation(Message.HDR_ORIGINAL_ADDRESS, original.getAddress());
   setAnnotation(Message.HDR_ORIG_MESSAGE_ID, original.getMessageID());
 }
 // reset expiry
 setExpiration(0);
}

代码示例来源:origin: apache/activemq-artemis

private void applyExpiryDelay(Message message, SimpleString address) {
 long expirationOverride = addressSettingsRepository.getMatch(address.toString()).getExpiryDelay();
 // A -1 <expiry-delay> means don't do anything
 if (expirationOverride >= 0) {
   // only override the exiration on messages where the expiration hasn't been set by the user
   if (message.getExpiration() == 0) {
    message.setExpiration(System.currentTimeMillis() + expirationOverride);
   }
 }
}

代码示例来源:origin: apache/activemq-artemis

msg.setExpiration(Long.parseLong(expiration));

代码示例来源:origin: org.apache.activemq/artemis-stomp-protocol

msg.setExpiration(Long.parseLong(expiration));

代码示例来源:origin: apache/activemq-artemis

@Test
public void testExpired() {
 Message message = new ClientMessageImpl();
 Assert.assertEquals(0, message.getExpiration());
 Assert.assertFalse(message.isExpired());
 message.setExpiration(System.currentTimeMillis() + 1000);
 Assert.assertFalse(message.isExpired());
 message.setExpiration(System.currentTimeMillis() - 1);
 Assert.assertTrue(message.isExpired());
 message.setExpiration(System.currentTimeMillis() - 1000);
 Assert.assertTrue(message.isExpired());
 message.setExpiration(0);
 Assert.assertFalse(message.isExpired());
}

代码示例来源:origin: apache/activemq-artemis

private Message makeCopy(final MessageReference ref,
            final boolean expiry,
            final boolean copyOriginalHeaders) throws Exception {
 if (ref == null) {
   ActiveMQServerLogger.LOGGER.nullRefMessage();
   throw new ActiveMQNullRefException("Reference to message is null");
 }
 Message message = ref.getMessage();
 /*
  We copy the message and send that to the dla/expiry queue - this is
  because otherwise we may end up with a ref with the same message id in the
  queue more than once which would barf - this might happen if the same message had been
  expire from multiple subscriptions of a topic for example
  We set headers that hold the original message address, expiry time
  and original message id
 */
 long newID = storageManager.generateID();
 Message copy = message.copy(newID);
 if (copyOriginalHeaders) {
   copy.referenceOriginalMessage(message, ref.getQueue().getName().toString());
 }
 copy.setExpiration(0);
 if (expiry) {
   copy.setAnnotation(Message.HDR_ACTUAL_EXPIRY_TIME, System.currentTimeMillis());
 }
 copy.reencode();
 return copy;
}

代码示例来源:origin: apache/activemq-artemis

default void referenceOriginalMessage(final Message original, String originalQueue) {
 String queueOnMessage = original.getAnnotationString(Message.HDR_ORIGINAL_QUEUE);
 if (queueOnMessage != null) {
   setAnnotation(Message.HDR_ORIGINAL_QUEUE, queueOnMessage);
 } else if (originalQueue != null) {
   setAnnotation(Message.HDR_ORIGINAL_QUEUE, originalQueue);
 }
 Object originalID = original.getAnnotation(Message.HDR_ORIG_MESSAGE_ID);
 if (originalID != null) {
   setAnnotation(Message.HDR_ORIGINAL_ADDRESS, original.getAnnotationString(Message.HDR_ORIGINAL_ADDRESS));
   setAnnotation(Message.HDR_ORIG_MESSAGE_ID, originalID);
 } else {
   setAnnotation(Message.HDR_ORIGINAL_ADDRESS, original.getAddress());
   setAnnotation(Message.HDR_ORIG_MESSAGE_ID, original.getMessageID());
 }
 // reset expiry
 setExpiration(0);
}

代码示例来源:origin: org.apache.activemq/artemis-core-client

default void referenceOriginalMessage(final Message original, String originalQueue) {
 String queueOnMessage = original.getAnnotationString(Message.HDR_ORIGINAL_QUEUE);
 if (queueOnMessage != null) {
   setAnnotation(Message.HDR_ORIGINAL_QUEUE, queueOnMessage);
 } else if (originalQueue != null) {
   setAnnotation(Message.HDR_ORIGINAL_QUEUE, originalQueue);
 }
 Object originalID = original.getAnnotation(Message.HDR_ORIG_MESSAGE_ID);
 if (originalID != null) {
   setAnnotation(Message.HDR_ORIGINAL_ADDRESS, original.getAnnotationString(Message.HDR_ORIGINAL_ADDRESS));
   setAnnotation(Message.HDR_ORIG_MESSAGE_ID, originalID);
 } else {
   setAnnotation(Message.HDR_ORIGINAL_ADDRESS, original.getAddress());
   setAnnotation(Message.HDR_ORIG_MESSAGE_ID, original.getMessageID());
 }
 // reset expiry
 setExpiration(0);
}

代码示例来源:origin: apache/activemq-artemis

default void referenceOriginalMessage(final Message original, String originalQueue) {
 String queueOnMessage = original.getAnnotationString(Message.HDR_ORIGINAL_QUEUE);
 if (queueOnMessage != null) {
   setAnnotation(Message.HDR_ORIGINAL_QUEUE, queueOnMessage);
 } else if (originalQueue != null) {
   setAnnotation(Message.HDR_ORIGINAL_QUEUE, originalQueue);
 }
 Object originalID = original.getAnnotation(Message.HDR_ORIG_MESSAGE_ID);
 if (originalID != null) {
   setAnnotation(Message.HDR_ORIGINAL_ADDRESS, original.getAnnotationString(Message.HDR_ORIGINAL_ADDRESS));
   setAnnotation(Message.HDR_ORIG_MESSAGE_ID, originalID);
 } else {
   setAnnotation(Message.HDR_ORIGINAL_ADDRESS, original.getAddress());
   setAnnotation(Message.HDR_ORIG_MESSAGE_ID, original.getMessageID());
 }
 // reset expiry
 setExpiration(0);
}

代码示例来源:origin: apache/activemq-artemis

default void referenceOriginalMessage(final Message original, String originalQueue) {
 String queueOnMessage = original.getAnnotationString(Message.HDR_ORIGINAL_QUEUE);
 if (queueOnMessage != null) {
   setAnnotation(Message.HDR_ORIGINAL_QUEUE, queueOnMessage);
 } else if (originalQueue != null) {
   setAnnotation(Message.HDR_ORIGINAL_QUEUE, originalQueue);
 }
 Object originalID = original.getAnnotation(Message.HDR_ORIG_MESSAGE_ID);
 if (originalID != null) {
   setAnnotation(Message.HDR_ORIGINAL_ADDRESS, original.getAnnotationString(Message.HDR_ORIGINAL_ADDRESS));
   setAnnotation(Message.HDR_ORIG_MESSAGE_ID, originalID);
 } else {
   setAnnotation(Message.HDR_ORIGINAL_ADDRESS, original.getAddress());
   setAnnotation(Message.HDR_ORIG_MESSAGE_ID, original.getMessageID());
 }
 // reset expiry
 setExpiration(0);
}

代码示例来源:origin: org.apache.activemq/artemis-jms-client-all

default void referenceOriginalMessage(final Message original, String originalQueue) {
 String queueOnMessage = original.getAnnotationString(Message.HDR_ORIGINAL_QUEUE);
 if (queueOnMessage != null) {
   setAnnotation(Message.HDR_ORIGINAL_QUEUE, queueOnMessage);
 } else if (originalQueue != null) {
   setAnnotation(Message.HDR_ORIGINAL_QUEUE, originalQueue);
 }
 Object originalID = original.getAnnotation(Message.HDR_ORIG_MESSAGE_ID);
 if (originalID != null) {
   setAnnotation(Message.HDR_ORIGINAL_ADDRESS, original.getAnnotationString(Message.HDR_ORIGINAL_ADDRESS));
   setAnnotation(Message.HDR_ORIG_MESSAGE_ID, originalID);
 } else {
   setAnnotation(Message.HDR_ORIGINAL_ADDRESS, original.getAddress());
   setAnnotation(Message.HDR_ORIG_MESSAGE_ID, original.getMessageID());
 }
 // reset expiry
 setExpiration(0);
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

default void referenceOriginalMessage(final Message original, String originalQueue) {
 String queueOnMessage = original.getAnnotationString(Message.HDR_ORIGINAL_QUEUE);
 if (queueOnMessage != null) {
   setAnnotation(Message.HDR_ORIGINAL_QUEUE, queueOnMessage);
 } else if (originalQueue != null) {
   setAnnotation(Message.HDR_ORIGINAL_QUEUE, originalQueue);
 }
 Object originalID = original.getAnnotation(Message.HDR_ORIG_MESSAGE_ID);
 if (originalID != null) {
   setAnnotation(Message.HDR_ORIGINAL_ADDRESS, original.getAnnotationString(Message.HDR_ORIGINAL_ADDRESS));
   setAnnotation(Message.HDR_ORIG_MESSAGE_ID, originalID);
 } else {
   setAnnotation(Message.HDR_ORIGINAL_ADDRESS, original.getAddress());
   setAnnotation(Message.HDR_ORIG_MESSAGE_ID, original.getMessageID());
 }
 // reset expiry
 setExpiration(0);
}

代码示例来源:origin: apache/activemq-artemis

copy.setExpiration(message.getExpiration());

代码示例来源:origin: apache/activemq-artemis

clientFile.setExpiration(System.currentTimeMillis());

代码示例来源:origin: apache/activemq-artemis

clientFile.setExpiration(System.currentTimeMillis());

代码示例来源:origin: apache/activemq-artemis

clientFile.setExpiration(System.currentTimeMillis());

代码示例来源:origin: apache/activemq-artemis

clientFile.setExpiration(System.currentTimeMillis());

相关文章