Commit 025251c6 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Ensure that SQLQueue never leave messages as processed.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8158 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 563c86c1
...@@ -95,16 +95,19 @@ class SQLQueue(RAMQueue): ...@@ -95,16 +95,19 @@ class SQLQueue(RAMQueue):
# Make sure message can not be processed anylonger # Make sure message can not be processed anylonger
activity_tool.SQLQueue_processMessage(uid=line.uid) activity_tool.SQLQueue_processMessage(uid=line.uid)
get_transaction().commit() # Release locks before starting a potentially long calculation get_transaction().commit() # Release locks before starting a potentially long calculation
# At this point, the message is marked as processed.
try:
m = self.loadMessage(line.message) m = self.loadMessage(line.message)
# Make sure object exists # Make sure object exists
validation_state = m.validate(self, activity_tool) validation_state = m.validate(self, activity_tool)
if validation_state is not VALID: if validation_state is not VALID:
if validation_state in (EXCEPTION, INVALID_PATH): if validation_state in (EXCEPTION, INVALID_PATH):
if line.priority > MAX_PRIORITY: if line.priority > MAX_PRIORITY:
# This is an error # This is an error.
activity_tool.SQLQueue_assignMessage(uid=line.uid, processing_node = VALIDATE_ERROR_STATE) # Assign message back to 'error' state.
# Assign message back to 'error' state activity_tool.SQLQueue_assignMessage(uid=line.uid,
#m.notifyUser(activity_tool) # Notify Error processing_node = VALIDATE_ERROR_STATE)
get_transaction().commit() # and commit get_transaction().commit() # and commit
else: else:
# Lower priority # Lower priority
...@@ -115,7 +118,15 @@ class SQLQueue(RAMQueue): ...@@ -115,7 +118,15 @@ class SQLQueue(RAMQueue):
activity_tool.SQLQueue_setPriority(uid = line.uid, date = next_processing_date, activity_tool.SQLQueue_setPriority(uid = line.uid, date = next_processing_date,
priority = line.priority) priority = line.priority)
get_transaction().commit() # Release locks before starting a potentially long calculation get_transaction().commit() # Release locks before starting a potentially long calculation
else: return 0
except:
# If any exception occurs, catch it and delay the operation.
get_transaction().abort()
activity_tool.SQLQueue_setPriority(uid = line.uid, date = next_processing_date,
priority = line.priority)
get_transaction().commit()
return 0
# Try to invoke # Try to invoke
activity_tool.invoke(m) # Try to invoke the message - what happens if read conflict error restarts transaction ? activity_tool.invoke(m) # Try to invoke the message - what happens if read conflict error restarts transaction ?
if m.is_executed: # Make sure message could be invoked if m.is_executed: # Make sure message could be invoked
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment