本文整理了Java中javax.jms.Message.getJMSExpiration()
方法的一些代码示例,展示了Message.getJMSExpiration()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getJMSExpiration()
方法的具体详情如下:
包路径:javax.jms.Message
类名称:Message
方法名:getJMSExpiration
[英]Gets the message's expiration time.
When a message is sent, the JMSExpiration header field is left unassigned. After completion of the send or publish method, it holds the expiration time of the message. This is the the difference, measured in milliseconds, between the expiration time and midnight, January 1, 1970 UTC.
If the time-to-live is specified as zero, JMSExpiration is set to zero to indicate that the message does not expire.
When a message's expiration time is reached, a provider should discard it. The JMS API does not define any form of notification of message expiration.
Clients should not receive messages that have expired; however, the JMS API does not guarantee that this will not happen.
[中]获取消息的过期时间。
发送消息时,JMSExpiration标头字段将保持未分配状态。发送或发布方法完成后,它保存消息的过期时间。这是过期时间与UTC 1970年1月1日午夜之间的差值,以毫秒为单位。
如果生存时间指定为零,JMSExpiration将设置为零,以指示消息未过期。
当到达消息的过期时间时,提供程序应放弃该消息。JMS API没有定义任何形式的消息过期通知。
客户端不应接收已过期的消息;然而,JMS API并不保证不会发生这种情况。
代码示例来源:origin: log4j/log4j
sbuf.append(m.getJMSExpiration());
代码示例来源:origin: spring-projects/spring-framework
long expiration = jmsMessage.getJMSExpiration();
headers.put(JmsHeaders.EXPIRATION, expiration);
代码示例来源:origin: apache/nifi
private Map<String, String> extractMessageHeaders(final Message message) throws JMSException {
final Map<String, String> messageHeaders = new HashMap<>();
messageHeaders.put(JmsHeaders.DELIVERY_MODE, String.valueOf(message.getJMSDeliveryMode()));
messageHeaders.put(JmsHeaders.EXPIRATION, String.valueOf(message.getJMSExpiration()));
messageHeaders.put(JmsHeaders.PRIORITY, String.valueOf(message.getJMSPriority()));
messageHeaders.put(JmsHeaders.REDELIVERED, String.valueOf(message.getJMSRedelivered()));
messageHeaders.put(JmsHeaders.TIMESTAMP, String.valueOf(message.getJMSTimestamp()));
messageHeaders.put(JmsHeaders.CORRELATION_ID, message.getJMSCorrelationID());
messageHeaders.put(JmsHeaders.MESSAGE_ID, message.getJMSMessageID());
messageHeaders.put(JmsHeaders.TYPE, message.getJMSType());
String replyToDestinationName = this.retrieveDestinationName(message.getJMSReplyTo(), JmsHeaders.REPLY_TO);
if (replyToDestinationName != null) {
messageHeaders.put(JmsHeaders.REPLY_TO, replyToDestinationName);
}
String destinationName = this.retrieveDestinationName(message.getJMSDestination(), JmsHeaders.DESTINATION);
if (destinationName != null) {
messageHeaders.put(JmsHeaders.DESTINATION, destinationName);
}
return messageHeaders;
}
代码示例来源:origin: apache/nifi
attributes.put(ATTRIBUTE_PREFIX + JMS_EXPIRATION, String.valueOf(message.getJMSExpiration()));
attributes.put(ATTRIBUTE_PREFIX + JMS_PRIORITY, String.valueOf(message.getJMSPriority()));
attributes.put(ATTRIBUTE_PREFIX + JMS_REDELIVERED, String.valueOf(message.getJMSRedelivered()));
代码示例来源:origin: wildfly/wildfly
setJMSDestination(foreign.getJMSDestination());
setJMSDeliveryMode(foreign.getJMSDeliveryMode());
setJMSExpiration(foreign.getJMSExpiration());
setJMSPriority(foreign.getJMSPriority());
setJMSType(foreign.getJMSType());
代码示例来源:origin: apache/activemq
/**
* Copies the standard JMS and user defined properties from the givem
* message to the specified message
*
* @param fromMessage the message to take the properties from
* @param toMessage the message to add the properties to
* @throws JMSException
*/
public static void copyProperties(Message fromMessage, Message toMessage) throws JMSException {
toMessage.setJMSMessageID(fromMessage.getJMSMessageID());
toMessage.setJMSCorrelationID(fromMessage.getJMSCorrelationID());
toMessage.setJMSReplyTo(transformDestination(fromMessage.getJMSReplyTo()));
toMessage.setJMSDestination(transformDestination(fromMessage.getJMSDestination()));
toMessage.setJMSDeliveryMode(fromMessage.getJMSDeliveryMode());
toMessage.setJMSRedelivered(fromMessage.getJMSRedelivered());
toMessage.setJMSType(fromMessage.getJMSType());
toMessage.setJMSExpiration(fromMessage.getJMSExpiration());
toMessage.setJMSPriority(fromMessage.getJMSPriority());
toMessage.setJMSTimestamp(fromMessage.getJMSTimestamp());
Enumeration propertyNames = fromMessage.getPropertyNames();
while (propertyNames.hasMoreElements()) {
String name = propertyNames.nextElement().toString();
Object obj = fromMessage.getObjectProperty(name);
toMessage.setObjectProperty(name, obj);
}
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void jmsReadOnlyPropertiesNotMapped() throws JMSException {
Message<String> message = initBuilder()
.setHeader(JmsHeaders.DESTINATION, new Destination() {})
.setHeader(JmsHeaders.DELIVERY_MODE, DeliveryMode.NON_PERSISTENT)
.setHeader(JmsHeaders.EXPIRATION, 1000L)
.setHeader(JmsHeaders.MESSAGE_ID, "abc-123")
.setHeader(JmsHeaders.PRIORITY, 9)
.setHeader(JmsHeaders.REDELIVERED, true)
.setHeader(JmsHeaders.TIMESTAMP, System.currentTimeMillis())
.build();
javax.jms.Message jmsMessage = new StubTextMessage();
mapper.fromHeaders(message.getHeaders(), jmsMessage);
assertNull(jmsMessage.getJMSDestination());
assertEquals(DeliveryMode.PERSISTENT, jmsMessage.getJMSDeliveryMode());
assertEquals(0, jmsMessage.getJMSExpiration());
assertNull(jmsMessage.getJMSMessageID());
assertEquals(javax.jms.Message.DEFAULT_PRIORITY, jmsMessage.getJMSPriority());
assertFalse(jmsMessage.getJMSRedelivered());
assertEquals(0, jmsMessage.getJMSTimestamp());
}
代码示例来源:origin: apache/log4j
sbuf.append(m.getJMSExpiration());
代码示例来源:origin: spring-projects/spring-integration
headers.put(JmsHeaders.EXPIRATION, jmsMessage.getJMSExpiration());
代码示例来源:origin: org.apache.tomee/openejb-core
@Override
public long getJMSExpiration() throws JMSException {
return message.getJMSExpiration();
}
代码示例来源:origin: org.jboss.jbossas/jboss-as-connector
public long getJMSExpiration() throws JMSException
{
return message.getJMSExpiration();
}
代码示例来源:origin: spring-projects/spring-integration
assertNotNull(message.get());
assertEquals(5, message.get().getJMSPriority());
assertTrue(message.get().getJMSExpiration() <= System.currentTimeMillis() + ttl);
assertTrue(message.get().toString().contains("persistent = false"));
message.set(null);
assertNotNull(message.get());
assertEquals(6, message.get().getJMSPriority());
assertTrue(message.get().getJMSExpiration() <= System.currentTimeMillis() + ttl);
assertTrue(message.get().toString().contains("persistent = false"));
exec.shutdownNow();
代码示例来源:origin: apache/cxf
private boolean isTimedOut(final javax.jms.Message request) throws JMSException {
if (request.getJMSExpiration() > 0) {
ZonedDateTime dateTime = ZonedDateTime.now(ZoneOffset.UTC);
long timeToLive = request.getJMSExpiration() - dateTime.toInstant().toEpochMilli();
if (timeToLive < 0) {
getLogger()
.log(Level.INFO, "Message time to live is already expired skipping response.");
return true;
}
}
return false;
}
代码示例来源:origin: org.apache.jmeter/ApacheJMeter_jms
public static StringBuilder requestHeaders(StringBuilder sb, Message msg){
try {
sb.append("JMSCorrelationId ").append(msg.getJMSCorrelationID()).append('\n');
sb.append("JMSMessageId ").append(msg.getJMSMessageID()).append('\n');
sb.append("JMSTimestamp ").append(msg.getJMSTimestamp()).append('\n');
sb.append("JMSType ").append(msg.getJMSType()).append('\n');
sb.append("JMSExpiration ").append(msg.getJMSExpiration()).append('\n');
sb.append("JMSPriority ").append(msg.getJMSPriority()).append('\n');
sb.append("JMSDestination ").append(msg.getJMSDestination()).append('\n');
} catch (JMSException e) {
sb.append("\nError: "+e.toString());
}
return sb;
}
代码示例来源:origin: org.seasar.jms/s2jms-core
public long getExpiration() {
if (message == null) {
throw new EmptyRuntimeException("message");
}
try {
return message.getJMSExpiration();
} catch (final JMSException e) {
throw new SJMSRuntimeException("EJMS0001", new Object[] { e }, e);
}
}
代码示例来源:origin: org.apache.activemq/artemis-ra
/**
* Get expiration
*
* @return The value
* @throws JMSException Thrown if an error occurs
*/
@Override
public long getJMSExpiration() throws JMSException {
if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("getJMSExpiration()");
}
return message.getJMSExpiration();
}
代码示例来源:origin: org.seasar.jms/s2jms-core
public long getExpiration() {
if (message == null) {
throw new EmptyRuntimeException("message");
}
try {
return message.getJMSExpiration();
} catch (final JMSException e) {
throw new SJMSRuntimeException("EJMS0001", new Object[] { e }, e);
}
}
代码示例来源:origin: apache/activemq-artemis
/**
* Get expiration
*
* @return The value
* @throws JMSException Thrown if an error occurs
*/
@Override
public long getJMSExpiration() throws JMSException {
if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("getJMSExpiration()");
}
return message.getJMSExpiration();
}
代码示例来源:origin: apache/activemq-artemis
@Test
public void testZeroExpiration() throws Exception {
Message m = queueProducerSession.createMessage();
queueProducer.send(m);
ProxyAssertSupport.assertEquals(0, queueConsumer.receive().getJMSExpiration());
}
代码示例来源:origin: rabbitmq/rabbitmq-jms-client
@Override
public void send(Destination destination, Message message) throws JMSException {
internalSend((RMQDestination) destination, message,
message.propertyExists(JMS_MESSAGE_DELIVERY_MODE) ? message.getJMSDeliveryMode() : getDeliveryMode(),
message.propertyExists(JMS_MESSAGE_PRIORITY) ? message.getJMSPriority() : getPriority(),
message.propertyExists(JMS_MESSAGE_EXPIRATION) ? message.getJMSExpiration() : getTimeToLive(),
message.propertyExists(JMS_MESSAGE_EXPIRATION) ? MessageExpirationType.EXPIRATION : MessageExpirationType.TTL);
}
内容来源于网络,如有侵权,请联系作者删除!