/** * Callback for scheduled AHEE__EE_Messages_Scheduler__sending */ public static function batch_sending() { /** * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() */ if (!apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) || !EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request) { EE_Messages_Scheduler::initiate_immediate_request_on_cron('send'); } }
/** * This method checks the queue for ANY EE_Message objects with a priority matching the given priority passed in. * If that exists, then we immediately initiate a non-blocking request to do the requested action type. * * Note: Keep in mind that there is the possibility that the request will not execute if there is already another request * running on a queue for the given task. * @param string $task This indicates what type of request is going to be initiated. * @param int $priority This indicates the priority that triggers initiating the request. */ public function initiate_request_by_priority($task = 'generate', $priority = EEM_Message::priority_high) { //determine what status is matched with the priority as part of the trigger conditions. $status = $task == 'generate' ? EEM_Message::status_incomplete : EEM_Message::instance()->stati_indicating_to_send(); // always make sure we save because either this will get executed immediately on a separate request // or remains in the queue for the regularly scheduled queue batch. $this->save(); /** * This filter/option allows users to override processing of messages on separate requests and instead have everything * happen on the same request. If this is utilized remember: * * - message priorities don't matter * - existing unprocessed messages in the queue will not get processed unless manually triggered. * - things will be perceived to take longer to happen for end users (i.e. registrations) because of the additional * processing happening on the same request. * - any race condition protection (locks) are removed because they don't apply when things are processed on * the same request. */ if (apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) || EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request) { $messages_processor = EE_Registry::instance()->load_lib('Messages_Processor'); if ($messages_processor instanceof EE_Messages_Processor) { return $messages_processor->process_immediately_from_queue($this); } //if we get here then that means the messages processor couldn't be loaded so messages will just remain //queued for manual triggering by end user. } if ($this->_message_repository->count_by_priority_and_status($priority, $status)) { EE_Messages_Scheduler::initiate_scheduled_non_blocking_request($task); } }