private void resetAMQueueAsNecessary()

in wilma-application/modules/wilma-safeguard/src/main/java/com/epam/wilma/safeguard/monitor/JmsQueueMonitorTask.java [136:165]


    private void resetAMQueueAsNecessary(final Long totalQueueSize) {
        boolean valueIsValid = false;
        Integer memoryPercentUsage = Integer.valueOf(0);
        Long totalQueueSizeLimit = MAX_MULTIPLIER_OF_MESSAGE_OFF_LIMIT * safeguardLimits.getMwOffLimit();
        if (totalQueueSize > totalQueueSizeLimit) {
            try {
                mBeanServerConnection.invoke(amqObject, "restart", null, null);
                logger.info("ActiveMQ Total Queue Size is too high ({}>{}), AMQ restart initiated.", totalQueueSize, totalQueueSizeLimit);
            } catch (Exception e) {
                throw new SystemException("ActiveMQ Total Queue Size is too high (\" + totalQueueSize + \">\" + totalQueueSizeLimit + \"), AMQ RESTART FAILED.", e);
            }
        }
        try {
            memoryPercentUsage = (Integer) mBeanServerConnection.getAttribute(amqObject, "MemoryPercentUsage");
            valueIsValid = true;
            if (memoryPercentUsage > MAX_AMQ_MEMORY_USAGE) {
                mBeanServerConnection.invoke(amqObject, "restart", null, null);
                logger.info("ActiveMQ Memory usage is too high:{}%, AMQ restart initiated.", memoryPercentUsage);
            }
        } catch (Exception e) {
            if (!(e instanceof InstanceNotFoundException)) {
                if (valueIsValid) {
                    throw new SystemException("ActiveMQ Memory usage is too high:" + memoryPercentUsage + "%, AMQ RESTART FAILED.", e);
                } else {
                    throw new SystemException("ActiveMQ Memory usage cannot be detected.", e);
                }
            }
        }

    }