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 acs_mail_lite::send_immediately acs_mail_lite::send_immediately (private) ad_log ad_log (public) ad_try ad_try (public) ad_url ad_url (public) db_dml db_dml (public) acs_mail_lite::sweeper acs_mail_lite::sweeper acs_mail_lite::sweeper->acs_mail_lite::send_immediately acs_mail_lite::sweeper->ad_log acs_mail_lite::sweeper->ad_try acs_mail_lite::sweeper->ad_url acs_mail_lite::sweeper->db_dml

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} {
            return
        }

        ad_try {
            db_foreach get_queued_messages {} {
                # Lock the message and also make sure that it was not
                # locked or deleted by somebody else in the meantime.
                set locking_server [ad_url]
                db_dml lock_queued_message {}

                if {[db_resultrows] == 1} {
                    # 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 $id): $errorMsg"
                        # Uncommenting the following two lines would
                        # cause failed emails to be retried at the
                        # next sweep. This could make sense only for
                        # certain kinds of errors, so it is best left
                        # commented and delegated to e.g. downstream
                        # callbacks.
                        ## 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_unset acs_mail_lite send_mails_p
        }
Generic XQL file:
<fullquery name="acs_mail_lite::sweeper.lock_queued_message">
    <querytext>
            update acs_mail_lite_queue
               set locking_server = :locking_server
             where message_id = :id
               and locking_server is NULL
        </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: