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

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

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

Message.setJMSMessageID介绍

[英]Sets the message ID.

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 ID. This method is public to allow a JMS provider to set this field when sending a message whose implementation is not its own.
[中]设置消息ID。
此方法仅供JMS提供程序在发送消息时用于设置此字段。客户端无法使用此消息来配置消息ID。此方法是公共的,允许JMS提供程序在发送非自己实现的消息时设置此字段。

代码示例

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

@Test
public void jmsMessageIdMappedToHeader() throws JMSException {
  String messageId = "ID:ABC-123";
  javax.jms.Message jmsMessage = new StubTextMessage();
  jmsMessage.setJMSMessageID(messageId);
  assertInboundHeader(jmsMessage, JmsHeaders.MESSAGE_ID, messageId);
}

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

message.setJMSMessageID(msg.getMessageId().toString());

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

jmsMessage.setJMSMessageID(activeMQJmsMessage.getJMSMessageID());

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

@Test
public void testJmsMessageIdMappedToHeader() throws JMSException {
  String messageId = "ID:ABC-123";
  javax.jms.Message jmsMessage = new StubTextMessage();
  jmsMessage.setJMSMessageID(messageId);
  DefaultJmsHeaderMapper mapper = new DefaultJmsHeaderMapper();
  Map<String, Object> headers = mapper.toHeaders(jmsMessage);
  Object attrib = headers.get(JmsHeaders.MESSAGE_ID);
  assertNotNull(attrib);
  assertSame(messageId, attrib);
}

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

@Override
public void setJMSMessageID(final String id) throws JMSException {
  message.setJMSMessageID(id);
}

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

public void setJMSMessageID(String id) throws JMSException
{
 message.setJMSMessageID(id);
}

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

public void setJMSMessageID(String id) throws JMSException {
  message.setJMSMessageID(id);
}

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

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

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

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

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

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

代码示例来源:origin: de.mhus.lib/mhu-lib-jms

protected void prepareMessage(Message msg) throws JMSException {
  
  msg.setJMSMessageID(createMessageId());
  
  String config = MLogUtil.getTrailConfig();
  if (config != null)
    msg.setStringProperty(MConstants.LOG_MAPPER, config);
}

代码示例来源: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: de.mhus.lib/mhu-lib-jms

protected void sendAnswer(Message msg, Message answer) throws JMSException {
  openAnswer();
  if (answer == null) answer = createErrorAnswer(null); // other side is waiting for an answer - send a null text
  if (interceptorOut != null)
    interceptorOut.prepare(answer);
  answer.setJMSMessageID(createMessageId());
  answer.setJMSCorrelationID(msg.getJMSCorrelationID());
  replyProducer.send(msg.getJMSReplyTo(), answer, deliveryMode, getPriority(), getTimeToLive());
}

代码示例来源:origin: objectweb-joramtests/joramtests

/**
* Test that the <code>JMSMessageID</code> header field value is 
* ignored when the message is sent.
*/
public void testJMSMessageID_1()
{
 try
 {
   Message message = senderSession.createMessage();
   message.setJMSMessageID("ID:foo");
   sender.send(message);
   assertTrue("3.4.3 When a message is sent this value is ignored.\n", message.getJMSMessageID() != "ID:foo");
   receiver.receive(TestConfig.TIMEOUT);
 }
 catch (JMSException e)
 {
   fail(e);
 }
}

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

@Test
public void testJMSMessageIDChangedAfterSendingMessage() throws Exception {
 try {
   Message m = queueProducerSession.createMessage();
   m.setJMSMessageID("ID:something");
   queueProducer.send(m);
   ProxyAssertSupport.assertFalse("ID:something".equals(m.getJMSMessageID()));
 } finally {
   removeAllMessages(queue1.getQueueName(), true);
 }
}

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

/**
* Test that the <code>JMSMessageID</code> header field value is
* ignored when the message is sent.
*/
@Test
public void testJMSMessageID_1() {
 try {
   Message message = senderSession.createMessage();
   message.setJMSMessageID("ID:foo");
   sender.send(message);
   Assert.assertTrue("sec. 3.4.3 When a message is sent this value is ignored.\n", !message.getJMSMessageID().equals("ID:foo"));
   receiver.receive(TestConfig.TIMEOUT);
 } catch (JMSException e) {
   fail(e);
 }
}

代码示例来源: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);
    }
  }
}

相关文章