@@ -703,57 +703,56 @@ private int getAndResetPendingSignals(AsyncJob job) {
703703
704704 protected void executeQueueItem (SyncQueueItemVO item , boolean fromPreviousSession ) {
705705 AsyncJobVO job = _jobDao .findById (item .getContentId ());
706- if (job ! = null ) {
706+ if (job = = null ) {
707707 if (logger .isDebugEnabled ()) {
708- logger .debug ("Schedule queued job-" + job .getId ());
709- }
710-
711- job .setSyncSource (item );
712-
713- //
714- // TODO: a temporary solution to work-around DB deadlock situation
715- //
716- // to live with DB deadlocks, we will give a chance for job to be rescheduled
717- // in case of exceptions (most-likely DB deadlock exceptions)
718- try {
719- job .setExecutingMsid (getMsid ());
720- _jobDao .update (job .getId (), job );
721- } catch (Exception e ) {
722- logger .warn ("Unexpected exception while dispatching job-" + item .getContentId (), e );
723-
724- try {
725- _queueMgr .returnItem (item .getId ());
726- } catch (Throwable thr ) {
727- logger .error ("Unexpected exception while returning job-" + item .getContentId () + " to queue" , thr );
728- }
729- return ;
708+ logger .debug ("Unable to find related job for queue item: " + item .toString ());
730709 }
710+ _queueMgr .purgeItem (item .getId ());
711+ return ;
712+ }
731713
732- try {
733- scheduleExecution ( job );
734- } catch ( RejectedExecutionException e ) {
735- logger . warn ( "Execution for job-" + job . getId () + " is rejected, return it to the queue for next turn" );
714+ if ( logger . isDebugEnabled ()) {
715+ logger . debug ( "Schedule queued job-" + job . getId () );
716+ }
717+ job . setSyncSource ( item );
736718
737- try {
738- _queueMgr .returnItem (item .getId ());
739- } catch (Exception e2 ) {
740- logger .error ("Unexpected exception while returning job-" + item .getContentId () + " to queue" , e2 );
741- }
719+ //
720+ // TODO: a temporary solution to work-around DB deadlock situation
721+ //
722+ // to live with DB deadlocks, we will give a chance for job to be rescheduled
723+ // in case of exceptions (most-likely DB deadlock exceptions)
724+ try {
725+ job .setExecutingMsid (getMsid ());
726+ _jobDao .update (job .getId (), job );
727+ } catch (Exception e ) {
728+ logger .warn ("Unexpected exception while dispatching job-" + item .getContentId (), e );
729+ returnItemToQueue (item );
730+ return ;
731+ }
742732
743- try {
744- job .setExecutingMsid (null );
745- _jobDao .update (job .getId (), job );
746- } catch (Exception e3 ) {
747- logger .warn ("Unexpected exception while update job-" + item .getContentId () + " msid for bookkeeping" );
748- }
749- }
733+ try {
734+ scheduleExecution (job );
735+ } catch (RejectedExecutionException e ) {
736+ logger .warn ("Execution for job-" + job .getId () + " is rejected, return it to the queue for next turn" );
737+ returnItemToQueue (item );
738+ clearExecutingMsid (job , item );
739+ }
740+ }
750741
751- } else {
752- if (logger .isDebugEnabled ()) {
753- logger .debug ("Unable to find related job for queue item: " + item .toString ());
754- }
742+ private void returnItemToQueue (SyncQueueItemVO item ) {
743+ try {
744+ _queueMgr .returnItem (item .getId ());
745+ } catch (Throwable thr ) {
746+ logger .error ("Unexpected exception while returning job-" + item .getContentId () + " to queue" , thr );
747+ }
748+ }
755749
756- _queueMgr .purgeItem (item .getId ());
750+ private void clearExecutingMsid (AsyncJobVO job , SyncQueueItemVO item ) {
751+ try {
752+ job .setExecutingMsid (null );
753+ _jobDao .update (job .getId (), job );
754+ } catch (Exception e ) {
755+ logger .warn ("Unexpected exception while update job-" + item .getContentId () + " msid for bookkeeping" );
757756 }
758757 }
759758
0 commit comments