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

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

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

Message.getSubject介绍

暂无

代码示例

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

/**
 * Creates a new (request) message from an AMQP 1.0 message.
 * <p>
 * The operation will be determined from the message's
 * <em>subject</em>.
 * 
 * @param message The AMQP message.
 * @return The request message.
 * @throws NullPointerException if message is {@code null}.
 * @throws IllegalArgumentException if the message has no subject set.
 */
public static EventBusMessage forOperation(final Message message) {
  if (message.getSubject() == null) {
    throw new IllegalArgumentException("message has no subject");
  } else {
    return new EventBusMessage(message.getSubject());
  }
}

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

/**
 * Creates a new (request) message from an AMQP 1.0 message.
 * <p>
 * The operation will be determined from the message's
 * <em>subject</em>.
 * 
 * @param message The AMQP message.
 * @return The request message.
 * @throws NullPointerException if message is {@code null}.
 * @throws IllegalArgumentException if the message has no subject set.
 */
public static EventBusMessage forOperation(final Message message) {
  if (message.getSubject() == null) {
    throw new IllegalArgumentException("message has no subject");
  } else {
    return new EventBusMessage(message.getSubject());
  }
}

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

/**
 * Gets the name of this command.
 *
 * @return The name.
 * @throws IllegalStateException if this command is invalid.
 */
public String getName() {
  if (isValid()) {
    return message.getSubject();
  } else {
    throw new IllegalStateException("command is invalid");
  }
}

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

/**
 * Return an AMQP_PUBREL message from the raw AMQP one
 *
 * @param message   raw AMQP message
 * @return  AMQP_PUBREL message
 */
public static AmqpPubrelMessage from(Message message) {
  if (!message.getSubject().equals(AMQP_SUBJECT)) {
    throw new IllegalArgumentException(String.format("AMQP message subject is no %s", AMQP_SUBJECT));
  }
  return new AmqpPubrelMessage(message.getMessageId());
}

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

/**
 * Return an AMQP_CLOSE message from the raw AMQP one
 *
 * @param message   raw AMQP message
 * @return  AMQP_CLOSE message
 */
public static AmqpCloseMessage from(Message message) {
  if (!message.getSubject().equals(AMQP_SUBJECT)) {
    throw new IllegalArgumentException(String.format("AMQP message subject is no %s", AMQP_SUBJECT));
  }
  return new AmqpCloseMessage(AmqpHelper.getClientIdFromPublishAddress((String) message.getCorrelationId()));
}

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

/**
 * Return an AMQP_LIST message from the raw AMQP one
 *
 * @param message   raw AMQP message
 * @return  AMQP_LIST message
 */
public static AmqpListMessage from(Message message) {
  if (!message.getSubject().equals(AMQP_SUBJECT)) {
    throw new IllegalArgumentException(String.format("AMQP message subject is no %s", AMQP_SUBJECT));
  }
  return new AmqpListMessage(AmqpHelper.getClientIdFromPublishAddress((String) message.getCorrelationId()));
}

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

/**
 * Checks if the client is authorized to execute a given operation.
 * 
 * This method is invoked for every request message received from a client.
 * <p>
 * This default implementation simply delegates to {@link AuthorizationService#isAuthorized(HonoUser, ResourceIdentifier, String)}.
 * <p>
 * Subclasses may override this method in order to do more sophisticated checks.
 * 
 * @param clientPrincipal The client.
 * @param resource The resource the message belongs to.
 * @param message The message for which the authorization shall be checked.
 * @return A future indicating the outcome of the check.
 *         The future will be succeeded if the client is authorized to execute the operation.
 *         Otherwise the future will be failed with a {@link ServiceInvocationException}.
 * @throws NullPointerException if any of the parameters is {@code null}.
 */
protected Future<Boolean> isAuthorized(final HonoUser clientPrincipal, final ResourceIdentifier resource, final Message message) {
  Objects.requireNonNull(message);
  return getAuthorizationService().isAuthorized(clientPrincipal, resource, message.getSubject());
}

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

/**
 * Checks if the client is authorized to execute a given operation.
 * 
 * This method is invoked for every request message received from a client.
 * <p>
 * This default implementation simply delegates to {@link AuthorizationService#isAuthorized(HonoUser, ResourceIdentifier, String)}.
 * <p>
 * Subclasses may override this method in order to do more sophisticated checks.
 * 
 * @param clientPrincipal The client.
 * @param resource The resource the message belongs to.
 * @param message The message for which the authorization shall be checked.
 * @return A future indicating the outcome of the check.
 *         The future will be succeeded if the client is authorized to execute the operation.
 *         Otherwise the future will be failed with a {@link ServiceInvocationException}.
 * @throws NullPointerException if any of the parameters is {@code null}.
 */
protected Future<Boolean> isAuthorized(final HonoUser clientPrincipal, final ResourceIdentifier resource, final Message message) {
  Objects.requireNonNull(message);
  return getAuthorizationService().isAuthorized(clientPrincipal, resource, message.getSubject());
}

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

/**
 * Return an AMQP_SUBSCRIPTIONS message from the raw AMQP one
 *
 * @param message   raw AMQP message
 * @return  AMQP_SUBSCRIPTIONS message
 */
@SuppressWarnings("unchecked")
public static AmqpSubscriptionsMessage from(Message message) {
  if (!message.getSubject().equals(AMQP_SUBJECT)) {
    throw new IllegalArgumentException(String.format("AMQP message subject is no %s", AMQP_SUBJECT));
  }
  Section section = message.getBody();
  if ((section != null) && (section instanceof AmqpValue)) {
    Map<String, String> map = (Map<String, String>) ((AmqpValue) section).getValue();
    // build the unique topic subscriptions list
    List<AmqpTopicSubscription> topicSubscriptions = new ArrayList<>();
    for (Map.Entry<String, String> entry: map.entrySet()) {
      topicSubscriptions.add(new AmqpTopicSubscription(entry.getKey(), MqttQoS.valueOf(Integer.valueOf(entry.getValue()))));
    }
    return new AmqpSubscriptionsMessage(topicSubscriptions);
  } else {
    throw new IllegalArgumentException("AMQP message wrong body type");
  }
}

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

/**
 * Return an AMQP_UNSUBSCRIBE message from the raw AMQP one
 *
 * @param message   raw AMQP message
 * @return  AMQP_UNSUBSCRIBE message
 */
@SuppressWarnings("unchecked")
public static AmqpUnsubscribeMessage from(Message message) {
  if (!message.getSubject().equals(AMQP_SUBJECT)) {
    throw new IllegalArgumentException(String.format("AMQP message subject is no %s", AMQP_SUBJECT));
  }
  Section section = message.getBody();
  if ((section != null) && (section instanceof AmqpValue)) {
    List<String> topics = (List<String>) ((AmqpValue) section).getValue();
    return new AmqpUnsubscribeMessage(AmqpHelper.getClientIdFromPublishAddress((String) message.getCorrelationId()),
                     topics);
  } else {
    throw new IllegalArgumentException("AMQP message wrong body type");
  }
}

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

/**
 * Return an AMQP_SUBSCRIBE message from the raw AMQP one
 *
 * @param message   raw AMQP message
 * @return  AMQP_SUBSCRIBE message
 */
@SuppressWarnings("unchecked")
public static AmqpSubscribeMessage from(Message message) {
  if (!message.getSubject().equals(AMQP_SUBJECT)) {
    throw new IllegalArgumentException(String.format("AMQP message subject is no %s", AMQP_SUBJECT));
  }
  Section section = message.getBody();
  if ((section != null) && (section instanceof AmqpValue)) {
    Map<String, String> map = (Map<String, String>) ((AmqpValue) section).getValue();
    // build the unique topic subscriptions list
    List<AmqpTopicSubscription> topicSubscriptions = new ArrayList<>();
    for (Map.Entry<String, String> entry: map.entrySet()) {
      topicSubscriptions.add(new AmqpTopicSubscription(entry.getKey(), MqttQoS.valueOf(Integer.valueOf(entry.getValue()))));
    }
    return new AmqpSubscribeMessage(AmqpHelper.getClientIdFromPublishAddress((String) message.getCorrelationId()),
                    topicSubscriptions);
  } else {
    throw new IllegalArgumentException("AMQP message wrong body type");
  }
}

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

ResourceIdentifier.fromPath(new String[] { resource.getEndpoint(), tenantId });
return getAuthorizationService().isAuthorized(clientPrincipal, specificTenantAddress, request.getSubject());

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

/**
   * Checks whether a given tenant message contains all required properties.
   * 
   * @param linkTarget The resource path to check the message's properties against for consistency.
   * @param msg The AMQP 1.0 message to perform the checks on.
   * @return {@code true} if the message passes all checks.
   */
  public static boolean verify(final ResourceIdentifier linkTarget, final Message msg) {

    if (msg.getMessageId() == null && msg.getCorrelationId() == null) {
      LOG.trace("message has neither a message-id nor correlation-id");
      return false;
    } else if (msg.getSubject() == null) {
      LOG.trace("message [{}] does not contain subject", msg.getMessageId());
      return false;
    } else if (msg.getReplyTo() == null) {
      LOG.trace("message [{}] contains no reply-to address", msg.getMessageId());
      return false;
    } else if (msg.getBody() != null && !MessageHelper.hasDataBody(msg)) {
      LOG.trace("message [{}] contains no Data section payload", msg.getMessageId());
      return false;
    } else {
      return true;
    }
  }
}

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

/**
 * Checks whether a given credentials message contains all required properties.
 *
 * @param linkTarget The resource path to check the message's properties against for consistency.
 * @param msg The AMQP 1.0 message to perform the checks on.
 * @return {@code true} if the message passes all checks.
 */
public static boolean verify(final ResourceIdentifier linkTarget, final Message msg) {
  if (msg.getMessageId() == null && msg.getCorrelationId() == null) {
    LOG.trace("message has neither a message-id nor correlation-id");
    return false;
  } else if (!CredentialsConstants.CredentialsAction.isValid(msg.getSubject())) {
    LOG.trace("message [{}] does not contain valid subject property", msg.getMessageId());
    return false;
  } else if (msg.getReplyTo() == null) {
    LOG.trace("message [{}] has no reply-to address set", msg.getMessageId());
    return false;
  } else if (!MessageHelper.hasDataBody(msg)) {
    LOG.trace("message [{}] contains no Data section payload", msg.getMessageId());
    return false;
  } else {
    return true;
  }
}

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

/**
 * Checks whether a given credentials message contains all required properties.
 *
 * @param linkTarget The resource path to check the message's properties against for consistency.
 * @param msg The AMQP 1.0 message to perform the checks on.
 * @return {@code true} if the message passes all checks.
 */
public static boolean verify(final ResourceIdentifier linkTarget, final Message msg) {
  if (msg.getMessageId() == null && msg.getCorrelationId() == null) {
    LOG.trace("message has neither a message-id nor correlation-id");
    return false;
  } else if (!CredentialsConstants.CredentialsAction.isValid(msg.getSubject())) {
    LOG.trace("message [{}] does not contain valid subject property", msg.getMessageId());
    return false;
  } else if (msg.getReplyTo() == null) {
    LOG.trace("message [{}] has no reply-to address set", msg.getMessageId());
    return false;
  } else if (!MessageHelper.hasDataBody(msg, true)) {
    LOG.trace("message [{}] contains no AmqpValue or Data section payload", msg.getMessageId());
    return false;
  } else {
    return true;
  }
}

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

/**
   * Checks whether a given tenant message contains all required properties.
   * 
   * @param linkTarget The resource path to check the message's properties against for consistency.
   * @param msg The AMQP 1.0 message to perform the checks on.
   * @return {@code true} if the message passes all checks.
   */
  public static boolean verify(final ResourceIdentifier linkTarget, final Message msg) {

    if (msg.getMessageId() == null && msg.getCorrelationId() == null) {
      LOG.trace("message has neither a message-id nor correlation-id");
      return false;
    } else if (msg.getSubject() == null) {
      LOG.trace("message [{}] does not contain subject", msg.getMessageId());
      return false;
    } else if (msg.getReplyTo() == null) {
      LOG.trace("message [{}] contains no reply-to address", msg.getMessageId());
      return false;
    } else if (msg.getBody() != null && !MessageHelper.hasDataBody(msg, true)) {
      LOG.trace("message [{}] contains no AmqpValue or Data section payload", msg.getMessageId());
      return false;
    } else {
      return true;
    }
  }
}

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

/**
   * Checks whether a given registration message contains all required properties.
   * 
   * @param linkTarget The resource path to check the message's properties against for consistency.
   * @param msg The AMQP 1.0 message to perform the checks on.
   * @return {@code true} if the message passes all checks.
   */
   public static boolean verify(final ResourceIdentifier linkTarget, final Message msg) {

     if (!hasValidDeviceId(linkTarget, msg)) {
       return false;
     } else if (!hasCorrelationId(msg)) {
       return false;
     } else if (!RegistrationConstants.isValidAction(msg.getSubject())) {
       LOG.trace("message [{}] does not contain valid action property", msg.getMessageId());
       return false;
     } else if (msg.getReplyTo() == null) {
       LOG.trace("message [{}] contains no reply-to address", msg.getMessageId());
       return false;
    } else if (msg.getBody() != null && !MessageHelper.hasDataBody(msg)) {
      LOG.trace("message [{}] contains no Data section payload", msg.getMessageId());
      return false;
     } else {
       return true;
     }
  }
}

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

/**
   * Checks whether a given registration message contains all required properties.
   * 
   * @param linkTarget The resource path to check the message's properties against for consistency.
   * @param msg The AMQP 1.0 message to perform the checks on.
   * @return {@code true} if the message passes all checks.
   */
   public static boolean verify(final ResourceIdentifier linkTarget, final Message msg) {

     if (!hasValidDeviceId(linkTarget, msg)) {
       return false;
     } else if (!hasCorrelationId(msg)) {
       return false;
     } else if (!RegistrationConstants.isValidAction(msg.getSubject())) {
       LOG.trace("message [{}] does not contain valid action property", msg.getMessageId());
       return false;
     } else if (msg.getReplyTo() == null) {
       LOG.trace("message [{}] contains no reply-to address", msg.getMessageId());
       return false;
    } else if (msg.getBody() != null && !MessageHelper.hasDataBody(msg, true)) {
      LOG.trace("message [{}] contains no AmqpValue or Data section payload", msg.getMessageId());
      return false;
     } else {
       return true;
     }
  }
}

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

if (message.getSubject() == null) {
  switch (message.getSubject()) {

代码示例来源:origin: org.apache.beam/beam-sdks-java-io-amqp

@Test
public void encodeDecode() throws Exception {
 Message message = Message.Factory.create();
 message.setBody(new AmqpValue("body"));
 message.setAddress("address");
 message.setSubject("test");
 AmqpMessageCoder coder = AmqpMessageCoder.of();
 Message clone = CoderUtils.clone(coder, message);
 assertEquals("AmqpValue{body}", clone.getBody().toString());
 assertEquals("address", clone.getAddress());
 assertEquals("test", clone.getSubject());
}

相关文章

微信公众号

最新文章

更多