From f428584c5f1fb4c3d24bfc3a4e509e0346922729 Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 3 Nov 2009 23:05:47 +0000 Subject: [PATCH] make event firing more fault-tolerant to allow continued processing of very large data sets when one event or event group fails git-svn-id: svn://svn.open-ils.org/ILS/trunk@14755 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Trigger.pm | 44 ++++++++++++++++------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm index 73176f1187..5a4f6cf8fd 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm @@ -532,8 +532,18 @@ sub grouped_events { my %groups = ( '*' => [] ); for my $e_id ( @$events ) { - my $e = OpenILS::Application::Trigger::Event->new($e_id); - if ($e->validate->valid) { + + my $e; + try { + $e = OpenILS::Application::Trigger::Event->new($e_id); + } otherwise {}; + + next unless $e; + + if (try { $e->validate->valid } otherwise { $e = undef; }) { + + next unless $e; + if (my $group = $e->event->event_def->group_field) { # split the grouping link steps @@ -575,20 +585,30 @@ sub run_all_events { for my $def ( %$groups ) { if ($def eq '*') { for my $event ( @{ $$groups{'*'} } ) { - $client->respond( - $self - ->method_lookup('open-ils.trigger.event.fire') - ->run($event) - ); + try { + $client->respond( + $self + ->method_lookup('open-ils.trigger.event.fire') + ->run($event) + ); + } otherwise { + # un-oh + $logger->error("event firing failed"); + }; } } else { my $defgroup = $$groups{$def}; for my $ident ( keys %$defgroup ) { - $client->respond( - $self - ->method_lookup('open-ils.trigger.event_group.fire') - ->run($$defgroup{$ident}) - ); + try { + $client->respond( + $self + ->method_lookup('open-ils.trigger.event_group.fire') + ->run($$defgroup{$ident}) + ); + } otherwise { + # uh-oh + $logger->error("event group firing failed"); + }; } } } -- 2.11.0