Commit 0a2ec613 authored by Vincent Pelletier's avatar Vincent Pelletier

Make possible to process more than one message per dequeueMessage call. This...

Make possible to process more than one message per dequeueMessage call. This factorises MySQL access cost which is rather high because of a sort occuring in the query. SQLQueue_readMessage will still return just one message by default, so behaviour will not change unless default number of fetched rows is increased in that ZSQLMethod.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16505 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e6e79cc6
...@@ -85,9 +85,8 @@ class SQLQueue(RAMQueue): ...@@ -85,9 +85,8 @@ class SQLQueue(RAMQueue):
now_date = DateTime() now_date = DateTime()
# Next processing date in case of error # Next processing date in case of error
next_processing_date = now_date + float(VALIDATION_ERROR_DELAY)/86400 next_processing_date = now_date + float(VALIDATION_ERROR_DELAY)/86400
result = readMessage(processing_node=processing_node, to_date=now_date) message_list = readMessage(processing_node=processing_node, to_date=now_date)
if len(result) > 0: for line in message_list:
line = result[0]
path = line.path path = line.path
method_id = line.method_id method_id = line.method_id
# Make sure message can not be processed anylonger # Make sure message can not be processed anylonger
...@@ -110,7 +109,7 @@ class SQLQueue(RAMQueue): ...@@ -110,7 +109,7 @@ class SQLQueue(RAMQueue):
# Lower priority # Lower priority
activity_tool.SQLQueue_setPriority(uid=line.uid, priority=line.priority + 1) activity_tool.SQLQueue_setPriority(uid=line.uid, priority=line.priority + 1)
get_transaction().commit() # Release locks before starting a potentially long calculation get_transaction().commit() # Release locks before starting a potentially long calculation
return 0 continue
# Try to invoke # Try to invoke
activity_tool.invoke(m) # Try to invoke the message activity_tool.invoke(m) # Try to invoke the message
...@@ -135,7 +134,7 @@ class SQLQueue(RAMQueue): ...@@ -135,7 +134,7 @@ class SQLQueue(RAMQueue):
LOG('SQLQueue', ERROR, 'SQLQueue.dequeueMessage raised, and cannot even set processing to zero due to an exception', LOG('SQLQueue', ERROR, 'SQLQueue.dequeueMessage raised, and cannot even set processing to zero due to an exception',
error=sys.exc_info()) error=sys.exc_info())
raise raise
return 0 continue
try: try:
if m.is_executed: if m.is_executed:
...@@ -170,9 +169,8 @@ class SQLQueue(RAMQueue): ...@@ -170,9 +169,8 @@ class SQLQueue(RAMQueue):
'SQLQueue.dequeueMessage raised an exception during checking for the results of processed messages', 'SQLQueue.dequeueMessage raised an exception during checking for the results of processed messages',
error=sys.exc_info()) error=sys.exc_info())
raise raise
return 0
get_transaction().commit() # Release locks before starting a potentially long calculation get_transaction().commit() # Release locks before starting a potentially long calculation
return 1 return len(message_list) == 0
def hasActivity(self, activity_tool, object, **kw): def hasActivity(self, activity_tool, object, **kw):
hasMessage = getattr(activity_tool, 'SQLQueue_hasMessage', None) hasMessage = getattr(activity_tool, 'SQLQueue_hasMessage', None)
......
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