Commit 1efc2179 authored by Vincent Pelletier's avatar Vincent Pelletier

Implement prepareQueueMessageList and SQLQueue_writeMessageList for SQLQueue.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20047 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0fdef759
...@@ -61,26 +61,28 @@ class SQLQueue(RAMQueue, SQLBase): ...@@ -61,26 +61,28 @@ class SQLQueue(RAMQueue, SQLBase):
and provide sequentiality. Should not create conflict and provide sequentiality. Should not create conflict
because use of OOBTree. because use of OOBTree.
""" """
def prepareQueueMessage(self, activity_tool, m):
if m.is_registered: def prepareQueueMessageList(self, activity_tool, message_list):
id_tool = activity_tool.getPortalObject().portal_ids registered_message_list = [m for m in message_list if m.is_registered]
uid = id_tool.generateNewLengthId(id_group='portal_activity_queue', store=0) if len(registered_message_list):
path = '/'.join(m.object_path) uid_list = activity_tool.getPortalObject().portal_ids.generateNewLengthIdList(
method_id = m.method_id id_group='portal_activity_queue', id_count=len(registered_message_list),
priority = m.activity_kw.get('priority', 1) store=0)
date = m.activity_kw.get('at_date', None) path_list = ['/'.join(m.object_path) for m in registered_message_list]
if date is None: method_id_list = [m.method_id for m in registered_message_list]
date = self.getNow(activity_tool) priority_list = [m.activity_kw.get('priority', 1) for m in registered_message_list]
tag = m.activity_kw.get('tag', '') date_list = [m.activity_kw.get('at_date', None) for m in registered_message_list]
serialization_tag = m.activity_kw.get('serialization_tag', '') tag_list = [m.activity_kw.get('tag', '') for m in registered_message_list]
activity_tool.SQLQueue_writeMessage(uid=uid, serialization_tag_list = [m.activity_kw.get('serialization_tag', '') for m in registered_message_list]
path=path, message_list = [self.dumpMessage(m) for m in registered_message_list]
method_id=method_id, activity_tool.SQLQueue_writeMessageList(uid_list=uid_list,
priority=priority, path_list=path_list,
message=self.dumpMessage(m), method_id_list=method_id_list,
date=date, priority_list=priority_list,
tag=tag, message_list=message_list,
serialization_tag=serialization_tag) date_list=date_list,
tag_list=tag_list,
serialization_tag_list=serialization_tag_list)
def prepareDeleteMessage(self, activity_tool, m): def prepareDeleteMessage(self, activity_tool, m):
# Erase all messages in a single transaction # Erase all messages in a single transaction
......
<dtml-comment>
title:
connection_id:cmf_activity_sql_connection
max_rows:1000
max_cache:100
cache_time:0
class_name:
class_file:
</dtml-comment>
<params>uid
path
method_id
message
priority
processing_node
date
tag
serialization_tag
</params>
INSERT INTO message_queue
SET
uid = <dtml-sqlvar uid type="int">,
path = <dtml-sqlvar path type="string">,
date = <dtml-if date><dtml-sqlvar date type="datetime"><dtml-else>UTC_TIMESTAMP()</dtml-if>,
method_id = <dtml-sqlvar method_id type="string">,
<dtml-if processing_node>
processing_node = <dtml-sqlvar processing_node type="int">,
</dtml-if>
processing = 0,
priority = <dtml-sqlvar priority type="int">,
tag = <dtml-sqlvar tag type="string">,
serialization_tag = <dtml-sqlvar serialization_tag type="string">,
message = <dtml-sqlvar message type="string">
<dtml-comment>
title:
connection_id:cmf_activity_sql_connection
max_rows:1000
max_cache:100
cache_time:0
class_name:
class_file:
</dtml-comment>
<params>uid_list
path_list
method_id_list
message_list
priority_list
processing_node_list
date_list
tag_list
serialization_tag_list
</params>
INSERT INTO message_queue
(uid, path, date, method_id, processing_node, processing, priority, tag, serialization_tag, message)
VALUES
<dtml-in prefix="loop" expr="_.range(_.len(path_list))">
<dtml-if sequence-start><dtml-else>,</dtml-if>
(
<dtml-sqlvar expr="uid_list[loop_item]" type="int">,
<dtml-sqlvar expr="path_list[loop_item]" type="string">,
<dtml-if date><dtml-sqlvar expr="date_list[loop_item]" type="datetime"><dtml-else>UTC_TIMESTAMP()</dtml-if>,
<dtml-sqlvar expr="method_id_list[loop_item]" type="string">,
<dtml-if processing_node_list><dtml-sqlvar expr="processing_node_list[loop_item]" type="int"><dtml-else>-1</dtml-if>,
0,
<dtml-sqlvar expr="priority_list[loop_item]" type="int">,
<dtml-sqlvar expr="tag_list[loop_item]" type="string">,
<dtml-sqlvar expr="serialization_tag_list[loop_item]" type="string">,
<dtml-sqlvar expr="message_list[loop_item]" type="string">
)
</dtml-in>
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