acs_mail_lite::sweeper (private)

 acs_mail_lite::sweeper

Defined in packages/acs-mail-lite/tcl/acs-mail-lite-procs.tcl

Send messages in the acs_mail_lite_queue table.

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.
Source code:
        # Make sure that only one thread is processing the queue at a time.
        if {[nsv_incr acs_mail_lite send_mails_p] > 1} {
            nsv_incr acs_mail_lite send_mails_p -1
            return
        }

        ad_try {
            db_foreach get_queued_messages {} {
                # check if record is already there and free to use
                set return_id [db_string get_queued_message {} -default -1]
                if {$return_id == $id} {
                    # lock this record for exclusive use
                    set locking_server [ad_url]
                    db_dml lock_queued_message {}
                    # send the mail
                    ad_try {
                        acs_mail_lite::send_immediately  -to_addr $to_addr  -cc_addr $cc_addr  -bcc_addr $bcc_addr  -from_addr $from_addr  -reply_to $reply_to  -subject $subject  -body $body  -package_id $package_id  -object_id $object_id  -file_ids $file_ids  -filesystem_files $filesystem_files  -delete_filesystem_files_p $delete_filesystem_files_p  -mime_type $mime_type  -no_callback_p $no_callback_p  -extraheaders $extraheaders  -use_sender_p $use_sender_p
                    } on error {errorMsg} {
                        ad_log Error "Could not send queued mail (message $return_id): $errorMsg"
                        # release the lock (MS not now)
                        # set locking_server ""
                        # db_dml lock_queued_message {}
                    } on ok {r} {
                        # mail was sent, delete the queue entry
                        db_dml delete_queue_entry {}
                    }
                }
            }
        } finally {
            nsv_incr acs_mail_lite send_mails_p -1
        }
Generic XQL file:
<fullquery name="acs_mail_lite::sweeper.get_queued_message">
    <querytext>
            select message_id as id
            from acs_mail_lite_queue
            where message_id=:id and (locking_server = '' or locking_server is NULL)
        </querytext>
</fullquery>

<fullquery name="acs_mail_lite::sweeper.lock_queued_message">
    <querytext>
            update acs_mail_lite_queue
               set locking_server = :locking_server
            where message_id=:id
        </querytext>
</fullquery>

<fullquery name="acs_mail_lite::sweeper.delete_queue_entry">
    <querytext>
            delete from acs_mail_lite_queue
            where message_id=:id
        </querytext>
</fullquery>
packages/acs-mail-lite/tcl/acs-mail-lite-procs.xql

PostgreSQL XQL file:
<fullquery name="acs_mail_lite::sweeper.get_queued_messages">
    <querytext>
            select
                   message_id as id,
                   creation_date,
                   locking_server,
                   to_addr,
                   cc_addr,
                   bcc_addr,
                   from_addr,
                   reply_to,
                   subject,
                   body,
                   package_id,
                   file_ids,
                   (case when delete_filesystem_files_p = TRUE then 1 else 0 end) as delete_filesystem_files_p,
		   filesystem_files,
                   mime_type,
                   (case when no_callback_p = TRUE then 1 else 0 end) as no_callback_p,
                   extraheaders,
                   (case when use_sender_p = TRUE then 1 else 0 end) as use_sender_p,
                   object_id
            from acs_mail_lite_queue
            where locking_server = '' or locking_server is NULL
        </querytext>
</fullquery>
packages/acs-mail-lite/tcl/acs-mail-lite-procs-postgresql.xql

Oracle XQL file:
<fullquery name="acs_mail_lite::sweeper.get_queued_messages">
    <querytext>
            select
                   message_id as id,
                   creation_date,
                   locking_server,
                   to_addr,
                   cc_addr,
                   bcc_addr,
                   from_addr,
                   reply_to,
                   subject,
                   body,
                   package_id,
                   file_ids,
		   filesystem_files,
		   delete_filesystem_files_p,
                   mime_type,
                   decode(no_callback_p,'t',1,0) as no_callback_p,
                   extraheaders,
                   decode(use_sender_p,'t',1,0) as use_sender_p,
                   object_id
            from acs_mail_lite_queue
            where locking_server = '' or locking_server is NULL
        </querytext>
</fullquery>
packages/acs-mail-lite/tcl/acs-mail-lite-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: