From b324da25918a0382cba2ceac9d419121a3d1b5ae Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Mon, 17 Oct 2011 12:27:04 -0400 Subject: [PATCH] Stream results from targetable holds list retrieval Tested and slightly modified patch from Mike R. to improve multi-session hold targeting. This patch includes an update to the targetable holds API call to stream results instead of returning them in 1 big chunk, which has been known to result in messages too large for jabber (max_stanza_size). hold_targer.pl is updated to handle the stream. Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton --- .../Application/Storage/Publisher/action.pm | 2 +- Open-ILS/src/support-scripts/hold_targeter.pl | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm index 10f309f..2beaae5 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm @@ -346,8 +346,8 @@ sub targetable_holds { SQL my $sth = action::hold_request->db_Main->prepare_cached($query); $sth->execute($check_expire); + $client->respond( $_ ) for @{ $sth->fetchall_arrayref }; - $client->respond( $_ ) for ( $sth->fetchall_arrayref ); return undef; } diff --git a/Open-ILS/src/support-scripts/hold_targeter.pl b/Open-ILS/src/support-scripts/hold_targeter.pl index 84c5ba2..cd62227 100755 --- a/Open-ILS/src/support-scripts/hold_targeter.pl +++ b/Open-ILS/src/support-scripts/hold_targeter.pl @@ -56,13 +56,17 @@ if ($parallel == 1) { ); my $storage = OpenSRF::AppSession->create("open-ils.storage"); - my $holds = $storage->request('open-ils.storage.action.hold_request.targetable_holds.id_list', '24h')->gather(); - $storage->disconnect(); - foreach my $hold (@$holds) { - $multi_targeter->request( 'open-ils.storage.action.hold_request.copy_targeter', '', $hold->[0], $hold->[1]); + my $r = $storage->request('open-ils.storage.action.hold_request.targetable_holds.id_list', '24h'); + while ( my $h = $r->recv ) { + die $r->failed->stringify . "\n" if $r->failed; + if (my $hold = $h->content) { + $multi_targeter->request( 'open-ils.storage.action.hold_request.copy_targeter', '', $hold->[0], $hold->[1]); + } } + $storage->disconnect(); + $multi_targeter->session_wait(1); $multi_targeter->disconnect; -- 1.7.2.5