當前位置: 首頁>>代碼示例>>Java>>正文


Java TextMessage.getPropertyNames方法代碼示例

本文整理匯總了Java中javax.jms.TextMessage.getPropertyNames方法的典型用法代碼示例。如果您正苦於以下問題:Java TextMessage.getPropertyNames方法的具體用法?Java TextMessage.getPropertyNames怎麽用?Java TextMessage.getPropertyNames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.jms.TextMessage的用法示例。


在下文中一共展示了TextMessage.getPropertyNames方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getMessageHeaders

import javax.jms.TextMessage; //導入方法依賴的package包/類
private Map<String, String> getMessageHeaders(TextMessage message) throws JMSException {
     Map<String, String> map = new HashMap<>();
     Enumeration<String> names = message.getPropertyNames();
     while (names.hasMoreElements()) {
         String key = names.nextElement();
         map.put(key, message.getStringProperty(key));
     }
     return map;
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:10,代碼來源:DlqListener.java

示例2: readJmsMessage

import javax.jms.TextMessage; //導入方法依賴的package包/類
@Override
public Optional<EventMessage<?>> readJmsMessage(Message msg) throws JMSException {
  if (!(msg instanceof TextMessage)) {
    return Optional.empty();
  }

  final TextMessage textMsg = (TextMessage) msg;

  if (textMsg.getObjectProperty("axon-message-id") == null
          || textMsg.getObjectProperty("axon-message-type") == null) {
    return Optional.empty();
  }
  Map<String, Object> metaData = new HashMap<>();
  Enumeration<String> propertyNames = textMsg.getPropertyNames();
  while (propertyNames.hasMoreElements()) {
    String propertyName = propertyNames.nextElement();
    if (propertyName.startsWith("axon-metadata-")) {
      metaData.put(propertyName.substring("axon-metadata-".length()),
              textMsg.getObjectProperty(propertyName));
    }
  }
  SimpleSerializedObject<String> serializedObject = new SimpleSerializedObject<>(
          textMsg.getText(), String.class,
          textMsg.getStringProperty("axon-message-type"),
          textMsg.getStringProperty("axon-message-revision"));
  SerializedMessage<EventMessage<?>> serializedMessage = new SerializedMessage<>(
          textMsg.getStringProperty("axon-message-id"),
          new LazyDeserializingObject<>(serializedObject, serializer),
          new LazyDeserializingObject<>(MetaData.from(metaData)));
  String timestamp = textMsg.getStringProperty("axon-message-timestamp");
  if (textMsg.propertyExists("axon-message-aggregate-id")) {
    return Optional.of(new GenericDomainEventMessage<>(
            textMsg.getStringProperty("axon-message-aggregate-type"),
            textMsg.getStringProperty("axon-message-aggregate-id"),
            textMsg.getLongProperty("axon-message-aggregate-seq"),
            serializedMessage,
        () -> Instant.parse(timestamp)));
  } else {
    return Optional.of(new GenericEventMessage<>(
            serializedMessage, () -> Instant.parse(timestamp)));
  }
}
 
開發者ID:sventorben,項目名稱:axon-jms,代碼行數:43,代碼來源:DefaultJmsMessageConverter.java


注:本文中的javax.jms.TextMessage.getPropertyNames方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。