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

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

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

Message.getJMSDestination介绍

[英]Gets the Destination object for this message.

The JMSDestination header field contains the destination to which the message is being sent.

When a message is sent, this field is ignored. After completion of the send or publish method, the field holds the destination specified by the method.

When a message is received, its JMSDestination value must be equivalent to the value assigned when it was sent.
[中]获取此消息的目标对象。
JMSDestination标头字段包含消息要发送到的目的地。
发送消息时,忽略此字段。发送或发布方法完成后,该字段保存该方法指定的目的地。
接收到消息时,其JMSDestination值必须等于发送消息时分配的值。

代码示例

代码示例来源:origin: openzipkin/brave

@Override Destination destination(Message message) {
 try {
  return message.getJMSDestination();
 } catch (JMSException ignored) {
  // don't crash on wonky exceptions!
 }
 return null;
}

代码示例来源:origin: openzipkin/brave

@Override Destination destination(Message message) {
 try {
  Destination result = message.getJMSDestination();
  if (result != null) return result;
  return delegate.getDestination();
 } catch (JMSException ignored) {
  // don't crash on wonky exceptions!
 }
 return null;
}

代码示例来源:origin: openzipkin/brave

void tagQueueOrTopic(Message message, SpanCustomizer span) {
 try {
  Destination destination = message.getJMSDestination();
  if (destination != null) tagQueueOrTopic(destination, span);
 } catch (JMSException e) {
  // don't crash on wonky exceptions!
 }
}

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

public void updateState(List<TridentTuple> tuples, TridentCollector collector) throws JMSException {
  try {
    for (TridentTuple tuple : tuples) {
      Message msg = this.options.msgProducer.toMessage(this.session, tuple);
      if (msg != null) {
        if (msg.getJMSDestination() != null) {
          this.messageProducer.send(msg.getJMSDestination(), msg);
        } else {
          this.messageProducer.send(msg);
        }
      }
    }
  } catch (JMSException e) {
    LOG.warn("Failed to send jmd message for a trident batch ", e);
    if (this.options.jmsTransactional) {
      session.rollback();
    }
    throw new FailedException("Failed to write tuples", e);
  }
}

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

throw new MessageConversionException(
    "Could not find type id property [" + this.typeIdPropertyName + "] on message [" +
    message.getJMSMessageID() + "] from destination [" + message.getJMSDestination() + "]");

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

Message msg = this.producer.toMessage(this.session, input);
if (msg != null) {
  if (msg.getJMSDestination() != null) {
    this.messageProducer.send(msg.getJMSDestination(), msg);
  } else {
    this.messageProducer.send(msg);

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

sbuf.append(m.getJMSDestination());

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

Destination destination = jmsMessage.getJMSDestination();
if (destination != null) {
  headers.put(JmsHeaders.DESTINATION, destination);

代码示例来源: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_CORRELATION_ID, message.getJMSCorrelationID());
if (message.getJMSDestination() != null) {
  String destinationName;
  if (message.getJMSDestination() instanceof Queue) {
    destinationName = ((Queue) message.getJMSDestination()).getQueueName();
  } else {
    destinationName = ((Topic) message.getJMSDestination()).getTopicName();

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

setJMSDestination(foreign.getJMSDestination());
setJMSDeliveryMode(foreign.getJMSDeliveryMode());
setJMSExpiration(foreign.getJMSExpiration());

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

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

Destination destination = jmsMessage.getJMSDestination();
if (destination != null) {
  headers.put(JmsHeaders.DESTINATION, destination);

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 */
protected String logDebugJMSTopic(Message message) throws JMSException {
  String topic = ((Topic)message.getJMSDestination()).getTopicName();
  Object[] args = { topic };
  // call logDebugWithoutLevelCheck to avoid the second rcm.shouldLogDebugMessage() check
  rcm.logDebugWithoutLevelCheck("retreived_remote_message_from_JMS_topic", args);
  return topic;
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * INTERNAL:
 */
protected String logDebugJMSTopic(Message message) throws JMSException {
  String topic = ((Topic)message.getJMSDestination()).getTopicName();
  Object[] args = { topic };
  // call logDebugWithoutLevelCheck to avoid the second rcm.shouldLogDebugMessage() check
  rcm.logDebugWithoutLevelCheck("retreived_remote_message_from_JMS_topic", args);
  return topic;
}

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

@Test
public void testJMSDestination() throws Exception {
 queueProducer.send(queueProducerSession.createMessage());
 Message m = queueConsumer.receive();
 ProxyAssertSupport.assertEquals(queue1, m.getJMSDestination());
}

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

@Test
public void testClearMessage() throws Exception {
 queueProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
 Message message = queueProducerSession.createTextMessage("some message");
 queueProducer.send(message);
 message = queueConsumer.receive(1000);
 ProxyAssertSupport.assertNotNull(message);
 message.clearProperties();
 ProxyAssertSupport.assertNotNull(message.getJMSDestination());
}

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

@Test
public void testForeignJMSDestination() throws JMSException {
 Message message = queueProducerSession.createMessage();
 Destination foreignDestination = new ForeignDestination();
 message.setJMSDestination(foreignDestination);
 ProxyAssertSupport.assertSame(foreignDestination, message.getJMSDestination());
 queueProducer.send(message);
 ProxyAssertSupport.assertSame(queue1, message.getJMSDestination());
 Message receivedMessage = queueConsumer.receive(2000);
 MessageHeaderTestBase.ensureEquivalent(receivedMessage, (ActiveMQMessage) message);
}

相关文章