/**
   * Send the JMS message (under new transaction) with Retry mechanism enable when encounter JMS
   * related error
   *
   * @param destName
   * @param msgObj
   * @param msgProps
   * @param jmsSendProps
   * @param isLocal
   * @throws Throwable
   */
  public static void sendMessage(
      String destName,
      Serializable msgObj,
      Hashtable msgProps,
      Hashtable<String, String> jmsSendProps,
      boolean isLocal)
      throws Throwable {
    boolean isRetryEnabled = _retryCount <= 0 ? false : true;
    int retryCount = _retryCount;
    Throwable th1 = null;

    do {
      try {
        sendJMS(isLocal, jmsSendProps, destName, msgObj, msgProps);
        retryCount = -10;
      } catch (Throwable th) {
        if (isRetryableException(th) && isRetryEnabled) {
          Log.warn(
              Log.FRAMEWORK,
              "sendMessageWithRetry: JMS exception found. Reconnect after "
                  + _sleepFor / 1000
                  + " num retry left: "
                  + retryCount,
              th);

          try {
            Thread.sleep(_sleepFor);
          } catch (Exception ex) {

          }
          Log.debug(Log.FRAMEWORK, "sendMessageWithRetry: JMS exception catched: wake up !");
          th1 = new JMSFailureException(th);

        } else {
          Log.warn(
              Log.FRAMEWORK,
              "sendMessageWithRetry: Non Retryable exception found. No retry will be performed.",
              th);
          throw th;
        }
      }
    } while (retryCount-- > 0);

    if (isRetryEnabled && retryCount == -1 && th1 != null) {
      Log.debug(
          Log.FRAMEWORK,
          "sendMessageWithRetry: JMS retry exhausted. exception is: " + th1.getMessage(),
          th1);
      throw th1;
    }
  }
  /**
   * Send the JMS message (under new transaction) with Retry mechanism enable when encounter JMS
   * related error. If the retry count has exceeded, that JMS will be stored into DB for later
   * retry.
   *
   * @param configName The JMS properties config name
   * @param destName
   * @param msgObj
   * @param msgProps
   * @throws Throwable
   */
  public static void sendMessageWithPersist(
      String configName, String destName, Serializable msgObj, Hashtable msgProps)
      throws Throwable {
    boolean isRetryEnabled = _retryCount <= 0 ? false : true;
    int retryCount = _retryCount;
    Throwable th1 = null;

    do {
      try {
        getJMSMgr().sendMessage(configName, destName, msgObj, msgProps);
        retryCount = -10;
      } catch (Throwable th) {
        if (isRetryableException(th) && isRetryEnabled) {
          Log.warn(
              Log.FRAMEWORK,
              "Send: JMS exception found. Reconnect after "
                  + _sleepFor / 1000
                  + " num retry left: "
                  + retryCount,
              th);

          try {
            Thread.sleep(_sleepFor);
          } catch (Exception ex) {

          }
          Log.debug(Log.FRAMEWORK, "Send: JMS exception catched: wake up !");
          th1 = th;

        } else {
          Log.warn(
              Log.FRAMEWORK,
              "Send: Non Retryable exception found. No retry will be performed.",
              th);
          throw th;
        }
      }
    } while (retryCount-- > 0);

    if (isRetryEnabled && retryCount == -1 && th1 != null) {
      Log.debug(Log.FRAMEWORK, "Send: JMS retry exhausted. exception is: " + th1.getMessage(), th1);
      dumpFailedJMS(
          JMS_DEST_TYPE_QUEUE, getJmsSetupPropsKey(configName), destName, msgObj, msgProps);
    }
  }
  /**
   * Broadcast the JMS msg under a new transaction. It will perform retry if encoutner retryable
   * exception. If exceed the max retry, exception will be propageted up.
   *
   * @param notification
   * @throws Exception
   */
  public static void broadcastInNewTrans(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 = 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;
    }
  }
 /**
  * Call when create() is called on Home. Overwrite to set create time.
  *
  * @param entity The entity to create.
  * @return The primary key of the created entity.
  * @exception CreateException Create failed due to data error.
  * @exception EJBException Create failed due to system service errors.
  * @since 2.0
  */
 public Long ejbCreate(IEntity entity) throws CreateException {
   _entity = entity;
   try {
     checkDuplicate(_entity);
     ((Partner) _entity).setCreateTime(new java.sql.Timestamp(System.currentTimeMillis()));
     return getDAO().create(_entity);
   } catch (ApplicationException ex) {
     Log.warn(Log.DB, "[AbstractEntityBean.ejbCreate] Error Exit ", ex);
     throw new CreateException(ex.getLocalizedMessage());
   } catch (Exception ex) {
     throw new EJBException(ex);
   }
 }
Example #5
0
 /**
  * Log a warning message with the specified category and <code>Throwable</code> object of origin
  *
  * @param msg The warning message
  * @param ex The <code>Throwable</code> object of origin
  * @since GT 4.0 VAN
  * @version GT 4.0 VAN
  */
 public static void warn(String msg, Throwable ex) {
   Log.warn(CATEGORY, msg, ex);
 }
Example #6
0
 /**
  * Log a warning message with the specified category
  *
  * @param msg The warning message
  * @since GT 4.0 VAN
  * @version GT 4.0 VAN
  */
 public static void warn(Object msg) {
   Log.warn(CATEGORY, msg);
 }
  /**
   * 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);
    }
  }