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

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

本文整理了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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. public static Symbol getResponseErrorCondition(Message responseMessage)
  2. {
  3. Symbol errorCondition = (Symbol)responseMessage.getApplicationProperties().getValue().get(ClientConstants.REQUEST_RESPONSE_ERROR_CONDITION);
  4. if(errorCondition == null)
  5. {
  6. errorCondition = (Symbol)responseMessage.getApplicationProperties().getValue().get(ClientConstants.REQUEST_RESPONSE_LEGACY_ERROR_CONDITION);
  7. }
  8. return errorCondition;
  9. }

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

  1. public static String getResponseStatusDescription(Message responseMessage)
  2. {
  3. String statusDescription = (String)responseMessage.getApplicationProperties().getValue().get(ClientConstants.REQUEST_RESPONSE_STATUS_DESCRIPTION);
  4. if(statusDescription == null)
  5. {
  6. statusDescription = (String)responseMessage.getApplicationProperties().getValue().get(ClientConstants.REQUEST_RESPONSE_LEGACY_STATUS_DESCRIPTION);
  7. }
  8. return statusDescription;
  9. }

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

  1. public static int getResponseStatusCode(Message responseMessage)
  2. {
  3. int statusCode = ClientConstants.REQUEST_RESPONSE_UNDEFINED_STATUS_CODE;
  4. Object codeObject = responseMessage.getApplicationProperties().getValue().get(ClientConstants.REQUEST_RESPONSE_STATUS_CODE);
  5. if(codeObject == null)
  6. {
  7. codeObject = responseMessage.getApplicationProperties().getValue().get(ClientConstants.REQUEST_RESPONSE_LEGACY_STATUS_CODE);
  8. }
  9. if(codeObject != null)
  10. {
  11. statusCode = (int)codeObject;
  12. }
  13. return statusCode;
  14. }

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

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

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

  1. private static String getRegistrationAssertion(final Message msg, final boolean removeAssertion) {
  2. Objects.requireNonNull(msg);
  3. String assertion = null;
  4. final ApplicationProperties properties = msg.getApplicationProperties();
  5. if (properties != null) {
  6. Object obj = null;
  7. if (removeAssertion) {
  8. obj = properties.getValue().remove(APP_PROPERTY_REGISTRATION_ASSERTION);
  9. } else {
  10. obj = properties.getValue().get(APP_PROPERTY_REGISTRATION_ASSERTION);
  11. }
  12. if (obj instanceof String) {
  13. assertion = (String) obj;
  14. }
  15. }
  16. return assertion;
  17. }

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

  1. private static boolean hasValidAction(final Message msg) {
  2. String action = MessageHelper.getApplicationProperty(
  3. msg.getApplicationProperties(),
  4. RegistrationConstants.APP_PROPERTY_ACTION,
  5. String.class);
  6. return RegistrationConstants.isValidAction(action);
  7. }

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

  1. /**
  2. * Adds a property with a value from an AMQP message.
  3. * <p>
  4. * The property will only be added if the AMQP message contains
  5. * a non-{@code null} <em>application property</em> of the given name.
  6. *
  7. * @param name The name of the property.
  8. * @param msg The AMQP message to retrieve the value from.
  9. * @return This message for chaining.
  10. */
  11. public EventBusMessage setStringProperty(final String name, final Message msg) {
  12. setProperty(name, MessageHelper.getApplicationProperty(
  13. msg.getApplicationProperties(),
  14. name,
  15. String.class));
  16. return this;
  17. }

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

  1. public Message request(Message message, long timeout, TimeUnit timeUnit) {
  2. Map<String, Object> properties = new HashMap<>();
  3. if (message.getApplicationProperties() != null) {
  4. properties.putAll(message.getApplicationProperties().getValue());
  5. }
  6. message.setApplicationProperties(new ApplicationProperties(properties));
  7. if (message.getReplyTo() == null) {
  8. message.setReplyTo(replyTo);
  9. }
  10. context.runOnContext(h -> sender.send(message));
  11. try {
  12. return replies.poll(timeout, timeUnit);
  13. } catch (InterruptedException e) {
  14. throw new RuntimeException(e);
  15. }
  16. }

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

  1. private R getRequestResponseResult(final Message message) {
  2. final Integer status = MessageHelper.getApplicationProperty(
  3. message.getApplicationProperties(),
  4. MessageHelper.APP_PROPERTY_STATUS,
  5. Integer.class);
  6. if (status == null) {
  7. return null;
  8. } else {
  9. final CacheDirective cacheDirective = CacheDirective.from(MessageHelper.getCacheDirective(message));
  10. return getResult(status, message.getContentType(), MessageHelper.getPayload(message), cacheDirective);
  11. }
  12. }

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

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

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

  1. /**
  2. * Verifies that the adapter's name is set on a downstream message.
  3. */
  4. @Test
  5. public void testAddPropertiesAddsAdapterName() {
  6. final Message message = ProtonHelper.message();
  7. adapter.addProperties(message, newRegistrationAssertionResult("token"));
  8. assertThat(
  9. MessageHelper.getApplicationProperty(
  10. message.getApplicationProperties(),
  11. MessageHelper.APP_PROPERTY_ORIG_ADAPTER,
  12. String.class),
  13. is(ADAPTER_NAME));
  14. }

相关文章