Related to issue 29766: Retail Operations Buffer: store all transactions in operations table before processing
authorMartin Taal <martin.taal@openbravo.com>
Thu, 04 Jun 2015 08:17:20 +0200
changeset 26846 56b1ee2b3e33
parent 26845 167206608f8c
child 26847 f594c764c8f8
child 26852 c031eb54738d
Related to issue 29766: Retail Operations Buffer: store all transactions in operations table before processing
Added process to restart entry manager process and report on simple state (number of tasks in queue)
src-db/database/sourcedata/AD_MENU.xml
src-db/database/sourcedata/AD_MESSAGE.xml
src-db/database/sourcedata/AD_TREENODE.xml
src-db/database/sourcedata/OBUIAPP_PROCESS.xml
src/org/openbravo/service/importprocess/ImportEntryManager.java
src/org/openbravo/service/importprocess/ProcessImportEntriesProcessActionHandler.java
--- a/src-db/database/sourcedata/AD_MENU.xml	Wed Jun 03 16:53:19 2015 +0000
+++ b/src-db/database/sourcedata/AD_MENU.xml	Thu Jun 04 08:17:20 2015 +0200
@@ -4735,6 +4735,20 @@
 <!--26BF4F6D476E4D0CAF5E62EBC63E440E-->  <OPENLINKINBROWSER><![CDATA[N]]></OPENLINKINBROWSER>
 <!--26BF4F6D476E4D0CAF5E62EBC63E440E--></AD_MENU>
 
+<!--2B900D4873984239A50C5BD18EA72E04--><AD_MENU>
+<!--2B900D4873984239A50C5BD18EA72E04-->  <AD_MENU_ID><![CDATA[2B900D4873984239A50C5BD18EA72E04]]></AD_MENU_ID>
+<!--2B900D4873984239A50C5BD18EA72E04-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--2B900D4873984239A50C5BD18EA72E04-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--2B900D4873984239A50C5BD18EA72E04-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--2B900D4873984239A50C5BD18EA72E04-->  <NAME><![CDATA[Direct Process Import Entries]]></NAME>
+<!--2B900D4873984239A50C5BD18EA72E04-->  <DESCRIPTION><![CDATA[Directly process import entries]]></DESCRIPTION>
+<!--2B900D4873984239A50C5BD18EA72E04-->  <ISSUMMARY><![CDATA[N]]></ISSUMMARY>
+<!--2B900D4873984239A50C5BD18EA72E04-->  <ACTION><![CDATA[OBUIAPP_Process]]></ACTION>
+<!--2B900D4873984239A50C5BD18EA72E04-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--2B900D4873984239A50C5BD18EA72E04-->  <OPENLINKINBROWSER><![CDATA[N]]></OPENLINKINBROWSER>
+<!--2B900D4873984239A50C5BD18EA72E04-->  <EM_OBUIAPP_PROCESS_ID><![CDATA[C1A39F72074A4FAC8F354CF7CA1BF704]]></EM_OBUIAPP_PROCESS_ID>
+<!--2B900D4873984239A50C5BD18EA72E04--></AD_MENU>
+
 <!--308B984799CC4F5EBE5A5AC298EB260D--><AD_MENU>
 <!--308B984799CC4F5EBE5A5AC298EB260D-->  <AD_MENU_ID><![CDATA[308B984799CC4F5EBE5A5AC298EB260D]]></AD_MENU_ID>
 <!--308B984799CC4F5EBE5A5AC298EB260D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Jun 03 16:53:19 2015 +0000
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Thu Jun 04 08:17:20 2015 +0200
@@ -15669,6 +15669,18 @@
 <!--000000002F5DEF28012F5DFDF05A000A-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--000000002F5DEF28012F5DFDF05A000A--></AD_MESSAGE>
 
+<!--00A0154871AD4AA5893DA4D18B57422C--><AD_MESSAGE>
+<!--00A0154871AD4AA5893DA4D18B57422C-->  <AD_MESSAGE_ID><![CDATA[00A0154871AD4AA5893DA4D18B57422C]]></AD_MESSAGE_ID>
+<!--00A0154871AD4AA5893DA4D18B57422C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--00A0154871AD4AA5893DA4D18B57422C-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--00A0154871AD4AA5893DA4D18B57422C-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--00A0154871AD4AA5893DA4D18B57422C-->  <VALUE><![CDATA[ImportProcessRunning]]></VALUE>
+<!--00A0154871AD4AA5893DA4D18B57422C-->  <MSGTEXT><![CDATA[Import Process Running, active task count: %1, queued task count: %2]]></MSGTEXT>
+<!--00A0154871AD4AA5893DA4D18B57422C-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--00A0154871AD4AA5893DA4D18B57422C-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--00A0154871AD4AA5893DA4D18B57422C-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--00A0154871AD4AA5893DA4D18B57422C--></AD_MESSAGE>
+
 <!--010321C0FB2F42DAB68E93EC6FF287EC--><AD_MESSAGE>
 <!--010321C0FB2F42DAB68E93EC6FF287EC-->  <AD_MESSAGE_ID><![CDATA[010321C0FB2F42DAB68E93EC6FF287EC]]></AD_MESSAGE_ID>
 <!--010321C0FB2F42DAB68E93EC6FF287EC-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -23687,6 +23699,18 @@
 <!--BB8F6CA9813740E69189C36166303191-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--BB8F6CA9813740E69189C36166303191--></AD_MESSAGE>
 
+<!--BBB537C2BBA54C28A32F8F78A7FBABF4--><AD_MESSAGE>
+<!--BBB537C2BBA54C28A32F8F78A7FBABF4-->  <AD_MESSAGE_ID><![CDATA[BBB537C2BBA54C28A32F8F78A7FBABF4]]></AD_MESSAGE_ID>
+<!--BBB537C2BBA54C28A32F8F78A7FBABF4-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--BBB537C2BBA54C28A32F8F78A7FBABF4-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--BBB537C2BBA54C28A32F8F78A7FBABF4-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--BBB537C2BBA54C28A32F8F78A7FBABF4-->  <VALUE><![CDATA[ImportProcess]]></VALUE>
+<!--BBB537C2BBA54C28A32F8F78A7FBABF4-->  <MSGTEXT><![CDATA[Import Process]]></MSGTEXT>
+<!--BBB537C2BBA54C28A32F8F78A7FBABF4-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--BBB537C2BBA54C28A32F8F78A7FBABF4-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--BBB537C2BBA54C28A32F8F78A7FBABF4-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--BBB537C2BBA54C28A32F8F78A7FBABF4--></AD_MESSAGE>
+
 <!--BBFC2F1F3A7145A08CB96644E7B0E916--><AD_MESSAGE>
 <!--BBFC2F1F3A7145A08CB96644E7B0E916-->  <AD_MESSAGE_ID><![CDATA[BBFC2F1F3A7145A08CB96644E7B0E916]]></AD_MESSAGE_ID>
 <!--BBFC2F1F3A7145A08CB96644E7B0E916-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -25339,6 +25363,18 @@
 <!--E36A09BF7B3C495FAB705AB0D3EE0958-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--E36A09BF7B3C495FAB705AB0D3EE0958--></AD_MESSAGE>
 
+<!--E37E39024BE842A8B0EB78D801D3F323--><AD_MESSAGE>
+<!--E37E39024BE842A8B0EB78D801D3F323-->  <AD_MESSAGE_ID><![CDATA[E37E39024BE842A8B0EB78D801D3F323]]></AD_MESSAGE_ID>
+<!--E37E39024BE842A8B0EB78D801D3F323-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--E37E39024BE842A8B0EB78D801D3F323-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--E37E39024BE842A8B0EB78D801D3F323-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--E37E39024BE842A8B0EB78D801D3F323-->  <VALUE><![CDATA[ImportProcessNotRunning]]></VALUE>
+<!--E37E39024BE842A8B0EB78D801D3F323-->  <MSGTEXT><![CDATA[Import process is not running, contact the system administrator to check for technical system error messages.]]></MSGTEXT>
+<!--E37E39024BE842A8B0EB78D801D3F323-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--E37E39024BE842A8B0EB78D801D3F323-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--E37E39024BE842A8B0EB78D801D3F323-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--E37E39024BE842A8B0EB78D801D3F323--></AD_MESSAGE>
+
 <!--E3B45E07261C456C9643C6E85C9149EE--><AD_MESSAGE>
 <!--E3B45E07261C456C9643C6E85C9149EE-->  <AD_MESSAGE_ID><![CDATA[E3B45E07261C456C9643C6E85C9149EE]]></AD_MESSAGE_ID>
 <!--E3B45E07261C456C9643C6E85C9149EE-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_TREENODE.xml	Wed Jun 03 16:53:19 2015 +0000
+++ b/src-db/database/sourcedata/AD_TREENODE.xml	Thu Jun 04 08:17:20 2015 +0200
@@ -66,6 +66,17 @@
 <!--1CF209805D0946ABAEC796C4DCD007CE-->  <SEQNO><![CDATA[129]]></SEQNO>
 <!--1CF209805D0946ABAEC796C4DCD007CE--></AD_TREENODE>
 
+<!--21B1F5DA774D4701A6B335E2D98E6465--><AD_TREENODE>
+<!--21B1F5DA774D4701A6B335E2D98E6465-->  <AD_TREENODE_ID><![CDATA[21B1F5DA774D4701A6B335E2D98E6465]]></AD_TREENODE_ID>
+<!--21B1F5DA774D4701A6B335E2D98E6465-->  <AD_TREE_ID><![CDATA[10]]></AD_TREE_ID>
+<!--21B1F5DA774D4701A6B335E2D98E6465-->  <NODE_ID><![CDATA[2B900D4873984239A50C5BD18EA72E04]]></NODE_ID>
+<!--21B1F5DA774D4701A6B335E2D98E6465-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--21B1F5DA774D4701A6B335E2D98E6465-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--21B1F5DA774D4701A6B335E2D98E6465-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--21B1F5DA774D4701A6B335E2D98E6465-->  <PARENT_ID><![CDATA[161]]></PARENT_ID>
+<!--21B1F5DA774D4701A6B335E2D98E6465-->  <SEQNO><![CDATA[280]]></SEQNO>
+<!--21B1F5DA774D4701A6B335E2D98E6465--></AD_TREENODE>
+
 <!--2342C6FFC04A49BCB7963EB09D9DDC68--><AD_TREENODE>
 <!--2342C6FFC04A49BCB7963EB09D9DDC68-->  <AD_TREENODE_ID><![CDATA[2342C6FFC04A49BCB7963EB09D9DDC68]]></AD_TREENODE_ID>
 <!--2342C6FFC04A49BCB7963EB09D9DDC68-->  <AD_TREE_ID><![CDATA[10]]></AD_TREE_ID>
@@ -4340,7 +4351,7 @@
 <!--E4A1D5C890444A32B206697920497AFF-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--E4A1D5C890444A32B206697920497AFF-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--E4A1D5C890444A32B206697920497AFF-->  <PARENT_ID><![CDATA[161]]></PARENT_ID>
-<!--E4A1D5C890444A32B206697920497AFF-->  <SEQNO><![CDATA[90]]></SEQNO>
+<!--E4A1D5C890444A32B206697920497AFF-->  <SEQNO><![CDATA[280]]></SEQNO>
 <!--E4A1D5C890444A32B206697920497AFF--></AD_TREENODE>
 
 <!--EB68A542EF0F4B68B33711E733E850B3--><AD_TREENODE>
--- a/src-db/database/sourcedata/OBUIAPP_PROCESS.xml	Wed Jun 03 16:53:19 2015 +0000
+++ b/src-db/database/sourcedata/OBUIAPP_PROCESS.xml	Thu Jun 04 08:17:20 2015 +0200
@@ -471,6 +471,24 @@
 <!--B5C942145F354ABEBC9F16235D80D776-->  <ISCANADDRECORDSTOSELECTOR><![CDATA[N]]></ISCANADDRECORDSTOSELECTOR>
 <!--B5C942145F354ABEBC9F16235D80D776--></OBUIAPP_PROCESS>
 
+<!--C1A39F72074A4FAC8F354CF7CA1BF704--><OBUIAPP_PROCESS>
+<!--C1A39F72074A4FAC8F354CF7CA1BF704-->  <OBUIAPP_PROCESS_ID><![CDATA[C1A39F72074A4FAC8F354CF7CA1BF704]]></OBUIAPP_PROCESS_ID>
+<!--C1A39F72074A4FAC8F354CF7CA1BF704-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--C1A39F72074A4FAC8F354CF7CA1BF704-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--C1A39F72074A4FAC8F354CF7CA1BF704-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--C1A39F72074A4FAC8F354CF7CA1BF704-->  <VALUE><![CDATA[Direct Process Import Entries]]></VALUE>
+<!--C1A39F72074A4FAC8F354CF7CA1BF704-->  <NAME><![CDATA[Direct Process Import Entries]]></NAME>
+<!--C1A39F72074A4FAC8F354CF7CA1BF704-->  <ACCESSLEVEL><![CDATA[7]]></ACCESSLEVEL>
+<!--C1A39F72074A4FAC8F354CF7CA1BF704-->  <CLASSNAME><![CDATA[org.openbravo.service.importprocess.ProcessImportEntriesProcessActionHandler]]></CLASSNAME>
+<!--C1A39F72074A4FAC8F354CF7CA1BF704-->  <ISBACKGROUND><![CDATA[N]]></ISBACKGROUND>
+<!--C1A39F72074A4FAC8F354CF7CA1BF704-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--C1A39F72074A4FAC8F354CF7CA1BF704-->  <UIPATTERN><![CDATA[OBUIAPP_PickAndExecute]]></UIPATTERN>
+<!--C1A39F72074A4FAC8F354CF7CA1BF704-->  <ISMULTIRECORD><![CDATA[N]]></ISMULTIRECORD>
+<!--C1A39F72074A4FAC8F354CF7CA1BF704-->  <IS_EXPLICIT_ACCESS><![CDATA[N]]></IS_EXPLICIT_ACCESS>
+<!--C1A39F72074A4FAC8F354CF7CA1BF704-->  <ISGRIDLEGACY><![CDATA[N]]></ISGRIDLEGACY>
+<!--C1A39F72074A4FAC8F354CF7CA1BF704-->  <ISCANADDRECORDSTOSELECTOR><![CDATA[N]]></ISCANADDRECORDSTOSELECTOR>
+<!--C1A39F72074A4FAC8F354CF7CA1BF704--></OBUIAPP_PROCESS>
+
 <!--C600DAD457664EFDA6B1AA76931552BA--><OBUIAPP_PROCESS>
 <!--C600DAD457664EFDA6B1AA76931552BA-->  <OBUIAPP_PROCESS_ID><![CDATA[C600DAD457664EFDA6B1AA76931552BA]]></OBUIAPP_PROCESS_ID>
 <!--C600DAD457664EFDA6B1AA76931552BA-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src/org/openbravo/service/importprocess/ImportEntryManager.java	Wed Jun 03 16:53:19 2015 +0000
+++ b/src/org/openbravo/service/importprocess/ImportEntryManager.java	Thu Jun 04 08:17:20 2015 +0200
@@ -189,6 +189,19 @@
     importEntryArchiveManager.start();
   }
 
+  public long getNumberOfQueuedTasks() {
+    return executorService.getQueue().size();
+  }
+
+  public long getNumberOfActiveTasks() {
+    return executorService.getActiveCount();
+  }
+
+  public boolean isExecutorRunning() {
+    return executorService != null && !executorService.isShutdown()
+        && !executorService.isTerminated() && managerThread.isRunning();
+  }
+
   /**
    * Is called by the {@link ImportEntryProcessor} objects to submit a
    * {@link ImportEntryProcessor.ImportEntryProcessRunnable}. for execution.
@@ -214,6 +227,9 @@
       importEntryProcessor.shutdown();
     }
     importEntryArchiveManager.shutdown();
+    executorService = null;
+    threadsStarted = false;
+    managerThread = null;
   }
 
   /**
@@ -403,6 +419,7 @@
 
     private final ImportEntryManager manager;
 
+    private boolean isRunning = false;
     private Object monitorObject = new Object();
     private boolean wasNotifiedInParallel = false;
 
@@ -436,6 +453,7 @@
 
     @Override
     public void run() {
+      isRunning = true;
 
       Thread.currentThread().setName("Import Entry Manager Main");
 
@@ -447,99 +465,106 @@
       } catch (Exception ignored) {
       }
       log.debug("Run loop started");
-
-      while (true) {
-        // obcontext cleared or wrong obcontext, repair
-        if (OBContext.getOBContext() == null
-            || !"0".equals(OBContext.getOBContext().getUser().getId())) {
-          // make ourselves an admin
-          OBContext.setOBContext("0", "0", "0", "0");
-        }
-        try {
-
-          // too busy, don't process, but wait
-          if (manager.executorService.getQueue().size() > (manager.maxTaskQueueSize - 1)) {
-            doWait();
-            // woken, re-start from beginning of loop
-            continue;
+      try {
+        while (true) {
+          // obcontext cleared or wrong obcontext, repair
+          if (OBContext.getOBContext() == null
+              || !"0".equals(OBContext.getOBContext().getUser().getId())) {
+            // make ourselves an admin
+            OBContext.setOBContext("0", "0", "0", "0");
           }
-
-          List<String> typesOfData = null;
-          if (typesOfData == null) {
-            typesOfData = ImportProcessUtils.getOrderedTypesOfData();
-          }
-
-          int entryCount = 0;
           try {
 
-            // start processing, so ignore any notifications happening before
-            wasNotifiedInParallel = false;
+            // too busy, don't process, but wait
+            if (manager.executorService.getQueue().size() > (manager.maxTaskQueueSize - 1)) {
+              doWait();
+              // woken, re-start from beginning of loop
+              continue;
+            }
 
-            // read the types of data one by one in a specific order, so that they
-            // don't block eachother with the limited batch size
-            // being read
-            for (String typeOfData : typesOfData) {
-              OBQuery<ImportEntry> entriesQry = OBDal.getInstance().createQuery(
-                  ImportEntry.class,
-                  ImportEntry.PROPERTY_TYPEOFDATA + "='" + typeOfData + "' and "
-                      + ImportEntry.PROPERTY_IMPORTSTATUS + "='Initial' order by "
-                      + ImportEntry.PROPERTY_CREATIONDATE);
-              entriesQry.setFilterOnReadableClients(false);
-              entriesQry.setFilterOnReadableOrganization(false);
-              entriesQry.setMaxResult(manager.importBatchSize);
+            List<String> typesOfData = null;
+            if (typesOfData == null) {
+              typesOfData = ImportProcessUtils.getOrderedTypesOfData();
+            }
 
-              final ScrollableResults entries = entriesQry.scroll(ScrollMode.FORWARD_ONLY);
-              while (entries.next()) {
-                entryCount++;
-                final ImportEntry importEntry = (ImportEntry) entries.get()[0];
-                try {
-                  manager.handleImportEntry(importEntry);
-                } catch (Throwable t) {
-                  // ImportEntryProcessors are custom implementations which can cause
-                  // errors, so always catch them to prevent other import entries
-                  // from not getting processed
-                  manager.setImportEntryError(importEntry.getId(), t);
-                  OBDal.getInstance().flush();
+            int entryCount = 0;
+            try {
+
+              // start processing, so ignore any notifications happening before
+              wasNotifiedInParallel = false;
+
+              // read the types of data one by one in a specific order, so that they
+              // don't block eachother with the limited batch size
+              // being read
+              for (String typeOfData : typesOfData) {
+                OBQuery<ImportEntry> entriesQry = OBDal.getInstance().createQuery(
+                    ImportEntry.class,
+                    ImportEntry.PROPERTY_TYPEOFDATA + "='" + typeOfData + "' and "
+                        + ImportEntry.PROPERTY_IMPORTSTATUS + "='Initial' order by "
+                        + ImportEntry.PROPERTY_CREATIONDATE);
+                entriesQry.setFilterOnReadableClients(false);
+                entriesQry.setFilterOnReadableOrganization(false);
+                entriesQry.setMaxResult(manager.importBatchSize);
+
+                final ScrollableResults entries = entriesQry.scroll(ScrollMode.FORWARD_ONLY);
+                while (entries.next()) {
+                  entryCount++;
+                  final ImportEntry importEntry = (ImportEntry) entries.get()[0];
+                  try {
+                    manager.handleImportEntry(importEntry);
+                  } catch (Throwable t) {
+                    // ImportEntryProcessors are custom implementations which can cause
+                    // errors, so always catch them to prevent other import entries
+                    // from not getting processed
+                    manager.setImportEntryError(importEntry.getId(), t);
+                    OBDal.getInstance().flush();
+                  }
+                  // get rid of it to keep the session small
+                  OBDal.getInstance().getSession().evict(importEntry);
                 }
-                // get rid of it to keep the session small
-                OBDal.getInstance().getSession().evict(importEntry);
               }
+
+            } catch (Throwable t) {
+              ImportProcessUtils.logError(log, t);
+            } finally {
+              OBDal.getInstance().commitAndClose();
+            }
+
+            if (entryCount > 0) {
+              // if there was data then just wait some time
+              // give the threads time to process it all before trying
+              // a next batch of entries
+              try {
+                // wait one second per 50 records, somewhat arbitrary
+                // but high enough for most cases
+                Thread.sleep(1000 * (entryCount / 50));
+              } catch (Exception ignored) {
+              }
+            } else {
+              // else wait for new ones to arrive or check after a certain
+              // amount of time
+              doWait();
             }
 
           } catch (Throwable t) {
             ImportProcessUtils.logError(log, t);
-          } finally {
-            OBDal.getInstance().commitAndClose();
-          }
 
-          if (entryCount > 0) {
-            // if there was data then just wait some time
-            // give the threads time to process it all before trying
-            // a next batch of entries
+            // wait otherwise the loop goes wild in case of really severe
+            // system errors like full disk
             try {
-              // wait one second per 50 records, somewhat arbitrary
-              // but high enough for most cases
-              Thread.sleep(1000 * (entryCount / 50));
+              Thread.sleep(5 * manager.managerWaitTime);
             } catch (Exception ignored) {
             }
-          } else {
-            // else wait for new ones to arrive or check after a certain
-            // amount of time
-            doWait();
-          }
-
-        } catch (Throwable t) {
-          ImportProcessUtils.logError(log, t);
-
-          // wait otherwise the loop goes wild in case of really severe
-          // system errors like full disk
-          try {
-            Thread.sleep(5 * manager.managerWaitTime);
-          } catch (Exception ignored) {
           }
         }
+      } finally {
+        isRunning = false;
       }
     }
+
+    public boolean isRunning() {
+      return isRunning;
+    }
   }
 
   @javax.inject.Qualifier
--- a/src/org/openbravo/service/importprocess/ProcessImportEntriesProcessActionHandler.java	Wed Jun 03 16:53:19 2015 +0000
+++ b/src/org/openbravo/service/importprocess/ProcessImportEntriesProcessActionHandler.java	Thu Jun 04 08:17:20 2015 +0200
@@ -26,6 +26,9 @@
 import org.codehaus.jettison.json.JSONObject;
 import org.openbravo.base.weld.WeldUtils;
 import org.openbravo.client.application.process.BaseProcessActionHandler;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.erpCommon.utility.Utility;
+import org.openbravo.service.db.DalConnectionProvider;
 
 /**
  * Will trigger the import process.
@@ -43,12 +46,35 @@
 
       entryManager.notifyNewImportEntryCreated();
 
+      // do a 5 second wait to let the import entry manager time to start
+      try {
+        Thread.sleep(5000);
+      } catch (Exception ignored) {
+      }
+
       JSONObject result = new JSONObject();
       JSONObject msgTotal = new JSONObject();
       JSONArray actions = new JSONArray();
+
+      final DalConnectionProvider dalConnectionProvider = new DalConnectionProvider();
+
+      final String importProcessLbl = Utility.messageBD(dalConnectionProvider, "ImportProcess",
+          OBContext.getOBContext().getLanguage().getLanguage());
+
+      String importProcessRunningLbl = Utility.messageBD(dalConnectionProvider,
+          "ImportProcessRunning", OBContext.getOBContext().getLanguage().getLanguage());
+      importProcessRunningLbl = importProcessRunningLbl.replaceAll("%1",
+          "" + entryManager.getNumberOfActiveTasks());
+      importProcessRunningLbl = importProcessRunningLbl.replaceAll("%2",
+          "" + entryManager.getNumberOfQueuedTasks());
+
+      final String importProcessNotRunningLbl = Utility.messageBD(dalConnectionProvider,
+          "ImportProcessNotRunning", OBContext.getOBContext().getLanguage().getLanguage());
+
       msgTotal.put("msgType", "info");
-      msgTotal.put("msgTitle", "Import Process");
-      msgTotal.put("msgText", "Import process has been triggered");
+      msgTotal.put("msgTitle", importProcessLbl);
+      msgTotal.put("msgText", entryManager.isExecutorRunning() ? importProcessRunningLbl
+          : importProcessNotRunningLbl);
 
       JSONObject msgTotalAction = new JSONObject();
       msgTotalAction.put("showMsgInProcessView", msgTotal);