org.apache.qpid.proton.message.Message.getApplicationProperties()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(169)

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

Message.getApplicationProperties介绍

暂无

代码示例

代码示例来源:origin: eclipse/hono

/**
 * Gets the value of a message's {@link #APP_PROPERTY_DEVICE_ID} application property.
 *
 * @param msg The message.
 * @return The property value or {@code null} if not set.
 */
public static String getDeviceId(final Message msg) {
  Objects.requireNonNull(msg);
  return getApplicationProperty(msg.getApplicationProperties(), APP_PROPERTY_DEVICE_ID, String.class);
}

代码示例来源:origin: org.eclipse.hono/hono-core

/**
 * Gets the value of a message's {@link #APP_PROPERTY_TENANT_ID} application property.
 *
 * @param msg The message.
 * @return The property value or {@code null} if not set.
 */
public static String getTenantId(final Message msg) {
  Objects.requireNonNull(msg);
  return getApplicationProperty(msg.getApplicationProperties(), APP_PROPERTY_TENANT_ID, String.class);
}

代码示例来源:origin: eclipse/hono

private Long getSenderTimeFromMessageProperties(final Message message) {
  final Long senderTime = MessageHelper.getApplicationProperty(message.getApplicationProperties(), TIME_STAMP_VARIABLE,
      Long.class);
  if (senderTime == null) {
    LOGGER.warn("could not get sender time from '" + TIME_STAMP_VARIABLE + "' message application property");
  }
  return senderTime;
}

代码示例来源:origin: org.eclipse.hono/hono-core

/**
 * Gets the value of a message's {@link #APP_PROPERTY_CACHE_CONTROL} application property.
 *
 * @param msg The message to get the property from.
 * @return The property value or {@code null} if not set.
 */
public static String getCacheDirective(final Message msg) {
  return getApplicationProperty(msg.getApplicationProperties(), APP_PROPERTY_CACHE_CONTROL, String.class);
}

代码示例来源:origin: org.eclipse.hono/hono-core

/**
 * Gets the value of a message's {@link #APP_PROPERTY_DEVICE_TTD} application property.
 *
 * @param msg The message to get the property from.
 * @return The property value or {@code null} if not set.
 */
public static Integer getTimeUntilDisconnect(final Message msg) {
  return getApplicationProperty(msg.getApplicationProperties(), APP_PROPERTY_DEVICE_TTD, Integer.class);
}

代码示例来源:origin: eclipse/hono

/**
 * Gets the value of a message's {@link #APP_PROPERTY_TENANT_ID} application property.
 *
 * @param msg The message.
 * @return The property value or {@code null} if not set.
 */
public static String getTenantId(final Message msg) {
  Objects.requireNonNull(msg);
  return getApplicationProperty(msg.getApplicationProperties(), APP_PROPERTY_TENANT_ID, String.class);
}

代码示例来源:origin: eclipse/hono

/**
 * Gets the value of a message's {@link #APP_PROPERTY_DEVICE_TTD} application property.
 *
 * @param msg The message to get the property from.
 * @return The property value or {@code null} if not set.
 */
public static Integer getTimeUntilDisconnect(final Message msg) {
  return getApplicationProperty(msg.getApplicationProperties(), APP_PROPERTY_DEVICE_TTD, Integer.class);
}

代码示例来源:origin: org.eclipse.hono/hono-core

/**
 * Gets the value of a message's {@link #APP_PROPERTY_DEVICE_ID} application property.
 *
 * @param msg The message.
 * @return The property value or {@code null} if not set.
 */
public static String getDeviceId(final Message msg) {
  Objects.requireNonNull(msg);
  return getApplicationProperty(msg.getApplicationProperties(), APP_PROPERTY_DEVICE_ID, String.class);
}

代码示例来源:origin: eclipse/hono

/**
 * Gets the value of a message's {@link #APP_PROPERTY_CACHE_CONTROL} application property.
 *
 * @param msg The message to get the property from.
 * @return The property value or {@code null} if not set.
 */
public static String getCacheDirective(final Message msg) {
  return getApplicationProperty(msg.getApplicationProperties(), APP_PROPERTY_CACHE_CONTROL, String.class);
}

代码示例来源:origin: Azure/azure-service-bus-java

public static Symbol getResponseErrorCondition(Message responseMessage)
{
  Symbol errorCondition = (Symbol)responseMessage.getApplicationProperties().getValue().get(ClientConstants.REQUEST_RESPONSE_ERROR_CONDITION);
  if(errorCondition == null)
  {
    errorCondition = (Symbol)responseMessage.getApplicationProperties().getValue().get(ClientConstants.REQUEST_RESPONSE_LEGACY_ERROR_CONDITION);
  }
  return errorCondition;
}

代码示例来源:origin: Azure/azure-service-bus-java

public static String getResponseStatusDescription(Message responseMessage)
{
  String statusDescription = (String)responseMessage.getApplicationProperties().getValue().get(ClientConstants.REQUEST_RESPONSE_STATUS_DESCRIPTION);
  if(statusDescription == null)
  {
    statusDescription = (String)responseMessage.getApplicationProperties().getValue().get(ClientConstants.REQUEST_RESPONSE_LEGACY_STATUS_DESCRIPTION);
  }
  return statusDescription;
}

代码示例来源:origin: Azure/azure-service-bus-java

public static int getResponseStatusCode(Message responseMessage)
{
  int statusCode = ClientConstants.REQUEST_RESPONSE_UNDEFINED_STATUS_CODE;
  Object codeObject = responseMessage.getApplicationProperties().getValue().get(ClientConstants.REQUEST_RESPONSE_STATUS_CODE);
  if(codeObject == null)
  {
    codeObject = responseMessage.getApplicationProperties().getValue().get(ClientConstants.REQUEST_RESPONSE_LEGACY_STATUS_CODE);
  }
  if(codeObject != null)
  {
    statusCode = (int)codeObject;
  }
  
  return statusCode;
}

代码示例来源:origin: eclipse/hono

private void handleMessage(final String endpoint, final Message msg) {
  final String deviceId = MessageHelper.getDeviceId(msg);
  final Buffer payload = MessageHelper.getPayload(msg);
  LOG.info("received {} message [device: {}, content-type: {}]: {}", endpoint, deviceId, msg.getContentType(),
      payload);
  if (msg.getApplicationProperties() != null) {
    LOG.info("... with application properties: {}", msg.getApplicationProperties().getValue());
  }
}

代码示例来源:origin: org.eclipse.hono/hono-core

private static String getRegistrationAssertion(final Message msg, final boolean removeAssertion) {
  Objects.requireNonNull(msg);
  String assertion = null;
  final ApplicationProperties properties = msg.getApplicationProperties();
  if (properties != null) {
    Object obj = null;
    if (removeAssertion) {
      obj = properties.getValue().remove(APP_PROPERTY_REGISTRATION_ASSERTION);
    } else {
      obj = properties.getValue().get(APP_PROPERTY_REGISTRATION_ASSERTION);
    }
    if (obj instanceof String) {
      assertion = (String) obj;
    }
  }
  return assertion;
}

代码示例来源:origin: org.eclipse.hono/hono-server

private static boolean hasValidAction(final Message msg) {
  String action = MessageHelper.getApplicationProperty(
      msg.getApplicationProperties(),
      RegistrationConstants.APP_PROPERTY_ACTION,
      String.class);
  return RegistrationConstants.isValidAction(action);
}

代码示例来源:origin: eclipse/hono

/**
 * Adds a property with a value from an AMQP message.
 * <p>
 * The property will only be added if the AMQP message contains
 * a non-{@code null} <em>application property</em> of the given name.
 * 
 * @param name The name of the property.
 * @param msg The AMQP message to retrieve the value from.
 * @return This message for chaining.
 */
public EventBusMessage setStringProperty(final String name, final Message msg) {
  setProperty(name, MessageHelper.getApplicationProperty(
      msg.getApplicationProperties(),
      name,
      String.class));
  return this;
}

代码示例来源:origin: EnMasseProject/enmasse

public Message request(Message message, long timeout, TimeUnit timeUnit) {
  Map<String, Object> properties = new HashMap<>();
  if (message.getApplicationProperties() != null) {
    properties.putAll(message.getApplicationProperties().getValue());
  }
  message.setApplicationProperties(new ApplicationProperties(properties));
  if (message.getReplyTo() == null) {
    message.setReplyTo(replyTo);
  }
  context.runOnContext(h -> sender.send(message));
  try {
    return replies.poll(timeout, timeUnit);
  } catch (InterruptedException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: org.eclipse.hono/hono-client

private R getRequestResponseResult(final Message message) {
  final Integer status = MessageHelper.getApplicationProperty(
      message.getApplicationProperties(),
      MessageHelper.APP_PROPERTY_STATUS,
      Integer.class);
  if (status == null) {
    return null;
  } else {
    final CacheDirective cacheDirective = CacheDirective.from(MessageHelper.getCacheDirective(message));
    return getResult(status, message.getContentType(), MessageHelper.getPayload(message), cacheDirective);
  }
}

代码示例来源:origin: io.vertx/vertx-amqp-bridge

@Test
public void testJSON_to_AMQP_WithNoApplicationPropertiesSection() {
 JsonObject jsonObject = new JsonObject();
 Message protonMsg = translator.convertToAmqpMessage(jsonObject);
 assertNotNull("Expected converted msg", protonMsg);
 assertNull("expected converted msg to have no application properties section",
   protonMsg.getApplicationProperties());
}

代码示例来源:origin: eclipse/hono

/**
 * Verifies that the adapter's name is set on a downstream message.
 */
@Test
public void testAddPropertiesAddsAdapterName() {
  final Message message = ProtonHelper.message();
  adapter.addProperties(message, newRegistrationAssertionResult("token"));
  assertThat(
      MessageHelper.getApplicationProperty(
          message.getApplicationProperties(),
          MessageHelper.APP_PROPERTY_ORIG_ADAPTER,
          String.class),
      is(ADAPTER_NAME));
}

相关文章