コード例 #1
0
  private void notifyMessage0(String topicArn, String originalSubject, String message) {
    String subject =
        String.format(
            Locale.ENGLISH,
            "[%s:%s] %s (%s)",
            appCodeName,
            stackName,
            originalSubject,
            env.getActiveProfilesAsString());
    if (subject.length() > 100) {
      logger.warn("Topic message subject is truncated.  Full subject is: {}", subject);
      subject = subject.substring(0, 100);
    }

    logger.debug("notify message to topic[{}] - {} : {}", topicArn, subject, message);
    if (topicArn == null || topicArn.isEmpty() || topicArn.equals("arn:aws:sns:null")) {
      logger.debug("topicArn: NULL");
      return;
    }
    try {
      sns.publish(
          new PublishRequest().withTopicArn(topicArn).withSubject(subject).withMessage(message));
      logger.debug("SNS Notification published: {} - {}", topicArn, subject);
    } catch (Exception e) { // NOPMD
      logger.error("SNS Publish failed: {} - {} - {}", topicArn, subject, message, e);
    }
  }
コード例 #2
0
  /**
   * 開発担当者にメッセージを通知する。
   *
   * @param subject タイトル
   * @param messageMap メッセージ
   * @param t 例外
   * @since 0.3
   */
  public void notifyDev(String subject, Map<String, String> messageMap, Throwable t) {
    messageMap.put("environment", env.toString());
    if (instanceInfo != null) {
      messageMap.put("instanceMetadata", Jackson.toJsonString(instanceInfo));
    } else if (instanceMetadata != null) {
      @SuppressWarnings("deprecation")
      String metadataString = instanceMetadata.toString();
      messageMap.put("instanceMetadata", metadataString);
    }

    if (t != null) {
      messageMap.put("stackTrace", toString(t));
    }

    notifyMessage0(devTopicArn, subject, createMessage(messageMap));
  }