View | Details | Raw Unified | Return to bug 22417
Collapse All | Expand All

(-)a/koha_worker.pl (+37 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
use Net::RabbitFoot;
5
use JSON qw( encode_json decode_json );
6
7
use Koha::BackgroundJob::BatchUpdateBiblio;
8
use Koha::BackgroundJob;
9
10
my $conn = Koha::BackgroundJob->connect;
11
12
my $channel = $conn->open_channel();
13
14
my $job_type = 'batch_biblio_record_modification';
15
$channel->declare_queue(
16
    queue => $job_type,
17
    durable => 1,
18
);
19
20
$channel->qos(prefetch_count => 1,);
21
22
$channel->consume(
23
    on_consume => sub {
24
        my $var = shift;
25
        my $body = $var->{body}->{payload};
26
        say " [x] Received $body";
27
28
        my $args = decode_json( $body );
29
30
        Koha::BackgroundJob::BatchUpdateBiblio->process($args, $channel);
31
        say " [x] Done";
32
    },
33
    no_ack => 0,
34
);
35
36
# Wait forever
37
AnyEvent->condvar->recv;
(-)a/new_koha_job.pl (-1 / +26 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
use C4::Context;
5
use Koha::BackgroundJob::BatchUpdateBiblio;
6
use Koha::BackgroundJob;
7
8
use Net::RabbitFoot;
9
10
my $mmtid       = 1;
11
my $record_type = 'biblio';
12
my @record_ids  = ( 1, 2, 3 );
13
14
C4::Context->_new_userenv(42);
15
C4::Context->set_userenv( 51, 51, 42, 'koha', 'koha', 'CPL', 'CPL', 1 );
16
17
say " [x] Enqueuing BatchUpdateBiblio mmtid=$mmtid with biblionumber="
18
  . join( ',', @record_ids );
19
Koha::BackgroundJob::BatchUpdateBiblio->new->enqueue(
20
    {
21
        job_type    => 'batch_record_modification',
22
        mmtid       => $mmtid,
23
        record_type => $record_type,
24
        record_ids  => \@record_ids,
25
    }
26
);

Return to bug 22417