incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r762678 - /incubator/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/EventUtil.java
Date Tue, 07 Apr 2009 10:31:36 GMT
Author: cziegeler
Date: Tue Apr  7 10:31:36 2009
New Revision: 762678

URL: http://svn.apache.org/viewvc?rev=762678&view=rev
Log:
Acknowledge the job processing before thread is started to avoid problems when a thread pool
is used

Modified:
    incubator/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/EventUtil.java

Modified: incubator/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/EventUtil.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/EventUtil.java?rev=762678&r1=762677&r2=762678&view=diff
==============================================================================
--- incubator/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/EventUtil.java
(original)
+++ incubator/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/EventUtil.java
Tue Apr  7 10:31:36 2009
@@ -236,6 +236,19 @@
      * This method also sends an acknowledge message to the job event handler.
      */
     public static void processJob(final Event job, final JobProcessor processor) {
+        // first check for a notifier context to send an acknowledge
+        boolean notify = true;
+        final JobStatusNotifier.NotifierContext ctx = getNotifierContext(job);
+        if ( ctx != null ) {
+            if ( !ctx.notifier.sendAcknowledge(job, ctx.eventNodePath) ) {
+                // if we don't get an ack, someone else is already processing this job.
+                // we process but do not notify the job event handler.
+                LoggerFactory.getLogger(EventUtil.class).info("Someone else is already processing
job {}.", job);
+                notify = false;
+            }
+        }
+        final boolean notifyResult = notify;
+
         final Runnable task = new Runnable() {
 
             /**
@@ -243,19 +256,7 @@
              */
             public void run() {
                 boolean result = false;
-                boolean notifyResult = true;
                 try {
-                    // first check for a notifier context to send an acknowledge
-                    final JobStatusNotifier.NotifierContext ctx = getNotifierContext(job);
-                    if ( ctx != null ) {
-                        if ( !ctx.notifier.sendAcknowledge(job, ctx.eventNodePath) ) {
-                            // if we don't get an ack, someone else is already processing
this job.
-                            // we process but do not notify the job event handler.
-                            LoggerFactory.getLogger(EventUtil.class).info("Someone else is
already processing job {}.", job);
-                            notifyResult = false;
-                        }
-                    }
-
                     result = processor.process(job);
                 } catch (Throwable t) {
                     LoggerFactory.getLogger(EventUtil.class).error("Unhandled error occured
in job processor " + t.getMessage() + " while processing job " + job, t);



Mime
View raw message