Stream results from targetable holds list retrieval
authorMike Rylander <mrylander@gmail.com>
Mon, 17 Oct 2011 16:27:04 +0000 (12:27 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Thu, 9 Feb 2012 21:48:45 +0000 (16:48 -0500)
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 <berick@esilibrary.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>

Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm
Open-ILS/src/support-scripts/hold_targeter.pl

index 10f309f..2beaae5 100644 (file)
@@ -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;
 }
 
index 84c5ba2..cd62227 100755 (executable)
@@ -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;