javax.jms.Message.setJMSTimestamp()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(200)

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

Message.setJMSTimestamp介绍

[英]Sets the message timestamp.

This method is for use by JMS providers only to set this field when a message is sent. This message cannot be used by clients to configure the message timestamp. This method is public to allow a JMS provider to set this field when sending a message whose implementation is not its own.
[中]设置消息时间戳。
此方法仅供JMS提供程序在发送消息时用于设置此字段。客户端无法使用此消息来配置消息时间戳。此方法是公共的,允许JMS提供程序在发送非其自身实现的消息时设置此字段。

代码示例

代码示例来源:origin: apache/nifi

message.setJMSRedelivered(Boolean.parseBoolean(entry.getValue()));
} else if (entry.getKey().equals(JmsHeaders.TIMESTAMP)) {
  message.setJMSTimestamp(Long.parseLong(entry.getValue()));
} else if (entry.getKey().equals(JmsHeaders.CORRELATION_ID)) {
  message.setJMSCorrelationID(entry.getValue());

代码示例来源:origin: spring-projects/spring-framework

@Test
public void jmsTimestampMappedToHeader() throws JMSException {
  long timestamp = 123L;
  javax.jms.Message jmsMessage = new StubTextMessage();
  jmsMessage.setJMSTimestamp(timestamp);
  assertInboundHeader(jmsMessage, JmsHeaders.TIMESTAMP, timestamp);
}

代码示例来源:origin: apache/nifi

message.setJMSTimestamp(System.currentTimeMillis());

代码示例来源: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: wildfly/wildfly

jmsMessage.setJMSTimestamp(System.currentTimeMillis());
} else {
  jmsMessage.setJMSTimestamp(0);

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

if (!producer.getDisableMessageTimestamp()) {
  long timeStamp = System.currentTimeMillis();
  message.setJMSTimestamp(timeStamp);
  if (timeToLive > 0) {
    expiration = timeToLive + timeStamp;

代码示例来源:origin: spring-projects/spring-integration

@Test
public void testJmsTimestampMappedToHeader() throws JMSException {
  long timestamp = 123L;
  javax.jms.Message jmsMessage = new StubTextMessage();
  jmsMessage.setJMSTimestamp(timestamp);
  DefaultJmsHeaderMapper mapper = new DefaultJmsHeaderMapper();
  Map<String, Object> headers = mapper.toHeaders(jmsMessage);
  Object attrib = headers.get(JmsHeaders.TIMESTAMP);
  assertNotNull(attrib);
  assertEquals(timestamp, attrib);
}

代码示例来源:origin: org.jboss.jbossas/jboss-as-connector

public void setJMSTimestamp(long timestamp) throws JMSException
{
 message.setJMSTimestamp(timestamp);
}

代码示例来源:origin: org.apache.tomee/openejb-core

@Override
public void setJMSTimestamp(final long timestamp) throws JMSException {
  message.setJMSTimestamp(timestamp);
}

代码示例来源:origin: org.jboss.genericjms/generic-jms-ra-jar

public void setJMSTimestamp(long timestamp) throws JMSException {
  message.setJMSTimestamp(timestamp);
}

代码示例来源:origin: org.apache.qpid/qpid-jca

/**
* Set timestamp
* @param timestamp The value
* @exception JMSException Thrown if an error occurs
*/
public void setJMSTimestamp(final long timestamp) throws JMSException
{
 if (_log.isTraceEnabled())
 {
   _log.trace("setJMSTimestamp(" + timestamp + ")");
 }
 _message.setJMSTimestamp(timestamp);
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

private void createMessageAndSend(final LogEvent event, final Serializable serializable) throws JMSException {
  final Message message = createMessage(serializable);
  message.setJMSTimestamp(event.getTimeMillis());
  messageProducer.send(message);
}

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

/**
* Set timestamp
*
* @param timestamp The value
* @throws JMSException Thrown if an error occurs
*/
@Override
public void setJMSTimestamp(final long timestamp) throws JMSException {
 if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
   ActiveMQRALogger.LOGGER.trace("setJMSTimestamp(" + timestamp + ")");
 }
 message.setJMSTimestamp(timestamp);
}

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

/**
* Set timestamp
*
* @param timestamp The value
* @throws JMSException Thrown if an error occurs
*/
@Override
public void setJMSTimestamp(final long timestamp) throws JMSException {
 if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
   ActiveMQRALogger.LOGGER.trace("setJMSTimestamp(" + timestamp + ")");
 }
 message.setJMSTimestamp(timestamp);
}

代码示例来源:origin: org.directwebremoting/dwr

public void send(Destination realDestination, Message message, int realDeliveryMode, int realPriority, long realTimeToLive) throws JMSException
{
  if (state == State.CLOSED)
  {
    throw new IllegalStateException("DwrMessageProducer has been closed");
  }
  if (!disableMessageID)
  {
    message.setJMSMessageID(UUID.randomUUID().toString());
  }
  if (!disableMessageTimestamp)
  {
    message.setJMSTimestamp(new Date().getTime());
  }
  if (realDestination instanceof DwrTopic)
  {
    DwrTopic dwrtopic = (DwrTopic) realDestination;
    String topicName = dwrtopic.getTopicName();
    hub.publish(topicName, message);
  }
  else
  {
    throw new IllegalStateException("Unsuported Destination type (" + realDestination.getClass().getCanonicalName() + "). Only Topics are currently supported.");
  }
}

代码示例来源:origin: timewalker74/ffmq

protected final void setupMessage( Destination destinationRef , Message message , int deliveryMode , int priority , long timeToLive) throws JMSException
{
  long now = System.currentTimeMillis();
  
  // Setup headers
  message.setJMSMessageID(uuidProvider.getUUID());
  message.setJMSTimestamp(disableMessageTimestamp ? 0 : now);
  message.setJMSDeliveryMode(deliveryMode);
  message.setJMSPriority(priority);
  message.setJMSExpiration(timeToLive > 0 ? timeToLive+now : 0);
  message.setJMSDestination(destinationRef);
}

代码示例来源:origin: com.github.fridujo/spring-automocker

public Message toMessage(Session session) throws JMSException {
  Message message = toMessageInternal(session);
  if (messageId != null)
    message.setJMSMessageID(messageId);
  if (timestamp != null)
    message.setJMSTimestamp(timestamp);
  if (correlationId != null)
    message.setJMSCorrelationID(correlationId);
  if (replyTo != null)
    message.setJMSReplyTo(session.createQueue(replyTo));
  if (deliveryMode != null)
    message.setJMSDeliveryMode(deliveryMode);
  if (redelivered != null)
    message.setJMSRedelivered(redelivered);
  if (type != null)
    message.setJMSType(type);
  if (expiration != null)
    message.setJMSExpiration(expiration);
  if (priority != null)
    message.setJMSPriority(priority);
  properties.entrySet()
    .forEach(ThrowingConsumer.silent(e -> message.setObjectProperty(e.getKey(), e.getValue())));
  return message;
}

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

/**
   * 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: org.fusesource.stompjms/stompjms-client

/**
   * 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(StompJmsConnection connection, Message fromMessage, Message toMessage) throws JMSException {
    toMessage.setJMSMessageID(fromMessage.getJMSMessageID());
    toMessage.setJMSCorrelationID(fromMessage.getJMSCorrelationID());
    toMessage.setJMSReplyTo(transformDestination(connection, fromMessage.getJMSReplyTo()));
    toMessage.setJMSDestination(transformDestination(connection, 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: org.apache.activemq/activemq-all

/**
   * 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);
    }
  }
}

相关文章