Search in sources :

Example 26 with GenericConfigException

use of org.apache.ofbiz.base.config.GenericConfigException in project ofbiz-framework by apache.

the class JmsListenerFactory method loadListeners.

// Load the JMS listeners
private void loadListeners() {
    try {
        List<JmsService> jmsServices = ServiceConfigUtil.getServiceEngine().getJmsServices();
        if (Debug.verboseOn())
            Debug.logVerbose("Loading JMS Listeners.", module);
        for (JmsService service : jmsServices) {
            StringBuilder serverKey = new StringBuilder();
            for (Server server : service.getServers()) {
                try {
                    if (server.getListen()) {
                        // create a server key
                        serverKey.append(server.getJndiServerName() + ":");
                        serverKey.append(server.getJndiName() + ":");
                        serverKey.append(server.getTopicQueue());
                        // store the server element
                        servers.put(serverKey.toString(), server);
                        // load the listener
                        GenericMessageListener listener = loadListener(serverKey.toString(), server);
                        // store the listener w/ the key
                        if (serverKey.length() > 0 && listener != null)
                            listeners.put(serverKey.toString(), listener);
                    }
                } catch (GenericServiceException gse) {
                    Debug.logInfo("Cannot load message listener " + serverKey + " error: (" + gse.toString() + ").", module);
                } catch (Exception e) {
                    Debug.logError(e, "Uncaught exception.", module);
                }
            }
        }
    } catch (GenericConfigException e) {
        Debug.logError(e, "Exception thrown while loading JMS listeners: ", module);
    }
}
Also used : GenericConfigException(org.apache.ofbiz.base.config.GenericConfigException) JmsService(org.apache.ofbiz.service.config.model.JmsService) Server(org.apache.ofbiz.service.config.model.Server) GenericServiceException(org.apache.ofbiz.service.GenericServiceException) GenericConfigException(org.apache.ofbiz.base.config.GenericConfigException) GenericServiceException(org.apache.ofbiz.service.GenericServiceException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 27 with GenericConfigException

use of org.apache.ofbiz.base.config.GenericConfigException in project ofbiz-framework by apache.

the class PersistedServiceJob method failed.

@Override
protected void failed(Throwable t) throws InvalidJobException {
    super.failed(t);
    // if the job has not been re-scheduled; we need to re-schedule and run again
    if (nextRecurrence == -1) {
        if (this.canRetry()) {
            // create a recurrence
            Calendar cal = Calendar.getInstance();
            try {
                cal.add(Calendar.MINUTE, ServiceConfigUtil.getServiceEngine().getThreadPool().getFailedRetryMin());
            } catch (GenericConfigException e) {
                Debug.logWarning(e, "Unable to get retry minutes for job [" + getJobId() + "], defaulting to now: ", module);
            }
            long next = cal.getTimeInMillis();
            try {
                createRecurrence(next, true);
            } catch (GenericEntityException e) {
                Debug.logError(e, "Unable to re-schedule job [" + getJobId() + "]: ", module);
            }
            Debug.logInfo("Persisted Job [" + getJobId() + "] Failed. Re-Scheduling : " + next, module);
        } else {
            Debug.logWarning("Persisted Job [" + getJobId() + "] Failed. Max Retry Hit, not re-scheduling", module);
        }
    }
    // set the failed status
    jobValue.set("statusId", "SERVICE_FAILED");
    jobValue.set("finishDateTime", UtilDateTime.nowTimestamp());
    jobValue.set("jobResult", StringUtils.substring(t.getMessage(), 0, 255));
    try {
        jobValue.store();
    } catch (GenericEntityException e) {
        Debug.logError(e, "Cannot update the JobSandbox entity", module);
    }
}
Also used : GenericConfigException(org.apache.ofbiz.base.config.GenericConfigException) GenericEntityException(org.apache.ofbiz.entity.GenericEntityException) Calendar(com.ibm.icu.util.Calendar)

Aggregations

GenericConfigException (org.apache.ofbiz.base.config.GenericConfigException)27 Element (org.w3c.dom.Element)9 LinkedList (java.util.LinkedList)7 MainResourceHandler (org.apache.ofbiz.base.config.MainResourceHandler)7 ResourceHandler (org.apache.ofbiz.base.config.ResourceHandler)7 GenericEntityException (org.apache.ofbiz.entity.GenericEntityException)7 GenericValue (org.apache.ofbiz.entity.GenericValue)5 ComponentConfig (org.apache.ofbiz.base.component.ComponentConfig)4 UtilTimer (org.apache.ofbiz.base.util.UtilTimer)4 GenericEntityConfException (org.apache.ofbiz.entity.GenericEntityConfException)4 GenericServiceException (org.apache.ofbiz.service.GenericServiceException)4 Document (org.w3c.dom.Document)4 Calendar (com.ibm.icu.util.Calendar)3 Timestamp (java.sql.Timestamp)3 HashMap (java.util.HashMap)3 DelegatorElement (org.apache.ofbiz.entity.config.model.DelegatorElement)3 IOException (java.io.IOException)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 Locale (java.util.Locale)2