Related to issue 31340: Many warnings in log generated by import entry code when a cashup can not be processed
authorMartin Taal <martin.taal@openbravo.com>
Wed, 04 Nov 2015 23:32:41 +0100
changeset 27827 7cf9102a8066
parent 27826 6014133a6a4d
child 27828 e4d5e3db31fd
Related to issue 31340: Many warnings in log generated by import entry code when a cashup can not be processed
More log statements for debugging, add a minimum 1 second wait before re-reading entries
.hgignore
src/org/openbravo/service/importprocess/ImportEntryManager.java
src/org/openbravo/service/importprocess/ImportEntryProcessor.java
--- a/.hgignore	Thu Nov 05 00:24:35 2015 +0100
+++ b/.hgignore	Wed Nov 04 23:32:41 2015 +0100
@@ -44,3 +44,5 @@
 
 sources
 scripts
+
+modules/org.bpmc
--- a/src/org/openbravo/service/importprocess/ImportEntryManager.java	Thu Nov 05 00:24:35 2015 +0100
+++ b/src/org/openbravo/service/importprocess/ImportEntryManager.java	Wed Nov 04 23:32:41 2015 +0100
@@ -515,6 +515,9 @@
               // don't block eachother with the limited batch size
               // being read
               for (String typeOfData : typesOfData) {
+
+                log.debug("Reading import entries for type of data " + typeOfData);
+
                 final String importEntryQryStr = "from " + ImportEntry.ENTITY_NAME + " where "
                     + ImportEntry.PROPERTY_TYPEOFDATA + "='" + typeOfData + "' and "
                     + ImportEntry.PROPERTY_IMPORTSTATUS + "='Initial' order by "
@@ -531,11 +534,18 @@
                   while (entries.next()) {
                     entryCount++;
                     final ImportEntry entry = (ImportEntry) entries.get(0);
+
+                    if (log.isDebugEnabled()) {
+                      log.debug("Handle import entry " + entry.getIdentifier());
+                    }
+
                     try {
                       manager.handleImportEntry(entry);
                       // remove it from the internal cache to keep it small
                       OBDal.getInstance().getSession().evict(entry);
                     } catch (Throwable t) {
+                      ImportProcessUtils.logError(log, t);
+
                       // ImportEntryProcessors are custom implementations which can cause
                       // errors, so always catch them to prevent other import entries
                       // from not getting processed
@@ -560,7 +570,7 @@
               try {
                 // wait one second per 50 records, somewhat arbitrary
                 // but high enough for most cases
-                Thread.sleep(1000 * (entryCount / 50));
+                Thread.sleep(Math.max(2000, 1000 * (entryCount / 50)));
               } catch (Exception ignored) {
               }
             } else {
--- a/src/org/openbravo/service/importprocess/ImportEntryProcessor.java	Thu Nov 05 00:24:35 2015 +0100
+++ b/src/org/openbravo/service/importprocess/ImportEntryProcessor.java	Wed Nov 04 23:32:41 2015 +0100
@@ -302,8 +302,19 @@
 
               // not changed, process
               final String typeOfData = localImportEntry.getTypeofdata();
+
+              if (logger.isDebugEnabled()) {
+                logger.debug("Processing entry " + localImportEntry.getIdentifier() + " "
+                    + typeOfData);
+              }
+
               processEntry(localImportEntry);
 
+              if (logger.isDebugEnabled()) {
+                logger.debug("Finished Processing entry " + localImportEntry.getIdentifier() + " "
+                    + typeOfData);
+              }
+
               // don't use the import entry anymore, touching methods on it
               // may re-open a session
               localImportEntry = null;
@@ -340,6 +351,8 @@
               }
 
             } catch (Throwable t) {
+              ImportProcessUtils.logError(logger, t);
+
               // bit rough but ensures that the connection is released/closed
               try {
                 OBDal.getInstance().rollbackAndClose();
@@ -381,6 +394,8 @@
           } catch (Exception ignored) {
           }
 
+          logger.debug("Trying to deregister process " + key);
+
           // no more entries and deregistered
           if (importEntryProcessor.deregisterProcessThread(this)) {
             importEntryIds.clear();