コード例 #1
0
 /**
  * Broadcast a Notification message.
  *
  * @param notification The Notification message to broadcast.
  */
 static void broadcast(INotification notification) {
   try {
     Notifier.getInstance().broadcast(notification);
   } catch (Exception ex) {
     Logger.error(
         ILogErrorCodes.GT_CONNECTION_DELEGATE_HELPER,
         "[DelegateHelper.broadcastConnectionState] Fail to broadcast. Error: " + ex.getMessage(),
         ex);
   }
 }
コード例 #2
0
  /**
   * TWX 23072008 Add in broadcast with retry (not under new transaction)
   *
   * @param notification
   * @throws Exception
   */
  public static void broadcast(INotification notification) throws Exception {
    boolean isRetryEnabled = _retryCount <= 0 ? false : true;
    int retryCount = _retryCount;
    Exception ex1 = null;

    do {
      try {
        Notifier.getInstance().broadcast(notification);
        retryCount = -10;
      } catch (Exception ex) {

        if (isRetryEnabled && isRetryableException(ex)) {
          ex1 = new JMSFailureException(ex);
          Log.warn(
              Log.FRAMEWORK,
              "Broadcast: JMS exception found. Reconnect after "
                  + _sleepFor / 1000
                  + " num retry left: "
                  + retryCount,
              ex);
          try {
            Thread.sleep(_sleepFor);
          } catch (Exception e) {

          }
          Log.debug(Log.FRAMEWORK, "Broadcast: JMS exception catched: wake up !");
        } else {
          Log.warn(
              Log.FRAMEWORK,
              "Broadcast: Non Retryable exception found. No retry will be performed.",
              ex);
          throw ex;
        }
      }
    } while (retryCount-- > 0);

    if (isRetryEnabled && retryCount == -1 && ex1 != null) {
      Log.debug(Log.FRAMEWORK, "Broadcast: JMS retry send exhausted. Throw up ex.", ex1);

      throw ex1;
    }
  }
コード例 #3
0
  /**
   * Broadcast the notification under a new transaction. Whenever encouter JMS retryable error, it
   * will perform retry until max retry has reached. If it happen, the JMS msg will be stored in the
   * DB.
   *
   * @param notification
   * @throws Exception
   */
  public static void broadcastWithPersist(INotification notification) throws Exception {
    boolean isRetryEnabled = _retryCount <= 0 ? false : true;
    int retryCount = _retryCount;
    Exception ex1 = null;

    do {
      try {
        getLocalNotifierMgr().broadCastNotification(notification);
        retryCount = -10;
      } catch (Exception ex) {

        if (isRetryEnabled && isRetryableException(ex)) {
          ex1 = ex;
          Log.warn(
              Log.FRAMEWORK,
              "Broadcast: JMS exception found. Reconnect after "
                  + _sleepFor / 1000
                  + " num retry left: "
                  + retryCount,
              ex);
          try {
            Thread.sleep(_sleepFor);
          } catch (Exception e) {

          }
          Log.debug(Log.FRAMEWORK, "Broadcast: JMS exception catched: wake up !");
        } else {
          Log.warn(
              Log.FRAMEWORK,
              "Broadcast: Non Retryable exception found. No retry will be performed.",
              ex);
          throw ex;
        }
      }
    } while (retryCount-- > 0);

    if (isRetryEnabled && retryCount == -1 && ex1 != null) {
      Log.debug(
          Log.FRAMEWORK,
          "Broadcast: JMS retry send exhausted. Dumping the out JMS message for later retry.",
          ex1);

      Hashtable<String, String> msgProps = new Hashtable<String, String>();
      msgProps.put("id", notification.getNotificationID());
      msgProps.put(SystemUtil.HOSTID_PROP_KEY, SystemUtil.getHostId());
      String[] properties = notification.getPropertyKeys();
      for (int i = 0; i < properties.length; i++) {
        Log.debug(
            Log.FRAMEWORK,
            "Broadcast: Adding msg props : key: "
                + properties[i]
                + " value: "
                + notification.getProperty(properties[i]));
        msgProps.put(properties[i], notification.getProperty(properties[i]));
      }

      // debug
      Hashtable<String, String> jmsConfigProps = Notifier.getInstance().getJmsSetupPropsKey();
      Log.debug(Log.FRAMEWORK, "JMSConfigProps is: " + jmsConfigProps);
      String destName = jmsConfigProps.get(JMSSender.JMS_DEST_NAME);

      dumpFailedJMS(
          JMS_DEST_TYPE_TOPIC,
          Notifier.getInstance().getJmsSetupPropsKey(),
          destName,
          notification,
          msgProps);
    }
  }