https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14791
Lari Taskula <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #62615|0 |1 is obsolete| | --- Comment #10 from Lari Taskula <[email protected]> --- Created attachment 62622 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=62622&action=edit Bug 14791: Resend failed notices - Add Koha::Exceptions to SMS::Send drivers Sometimes notices keep failing due to various reasons. One common problem is network connection failures. Because of this, the notices go into 'failed' status without another attempt for sending. This is very problematic, because we have to not only monitor the failed messages but also resend them manually. The purpose of this patch is to move us into more automated way of handling delivery failures. This patch enables us to handle exceptions in SMS messaging. The main idea is to throw an exception from SMS::Send driver in case of a failure. The exception will be caught by C4::SMS and from here it will be forwarded to C4::Letters where instead of automatically setting the message into 'failed' status, we now can do as we wish with various exceptions. As an example I have caught Koha::Exceptions::ConnectionFailed in C4::Letters::_send_message_by_sms(). When we catch the said exception, we simply leave the message in 'pending' status. This way it will be resent whenever process_message_queue.pl is executed again. sub send_sms { #.....your implementation..... # Throw an exception in case of a connection error # $connError can be for example: ($curl->{'retcode'} == 6) # cURL code 6: CURLE_COULDNT_RESOLVE_HOST if ($connError){ Koha::Exceptions::ConnectionFailed->throw(error => "Connection failed"); } } To test: 1. prove t/db_dependent/Letters.t Also testable with your own implementation of SMSSendDriver. 1. Have/create some pending sms messages into message_queue 2. Go to Patrons -> Notices 3. Observe that the your message is in pending status 4. Run misc/cronjob/process_message_queue.pl 5. Observe that the message is no longer pending 6. Add Koha::Exceptions::ConnectionFailed->throw(error => "Connection failed"); to your SMS::Send driver send_sms. 7. Set your message back to pending status 8. Run misc/cronjob/process_message_queue.pl 9. Observe that your message is back in pending status 10. Observe it also has the following delivery note: "Connection failed. Attempting to resend." -- You are receiving this mail because: You are watching all bug changes. _______________________________________________ Koha-bugs mailing list [email protected] http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
