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

(-)a/Koha/BackgroundJob.pm (-2 / +6 lines)
Lines 151-158 sub enqueue { Link Here
151
        my $namespace    = C4::Context->config('memcached_namespace');
151
        my $namespace    = C4::Context->config('memcached_namespace');
152
        my $encoded_args = Encode::encode_utf8($json_args);           # FIXME We should better leave this to Net::Stomp?
152
        my $encoded_args = Encode::encode_utf8($json_args);           # FIXME We should better leave this to Net::Stomp?
153
        my $destination  = sprintf( "/queue/%s-%s", $namespace, $job_queue );
153
        my $destination  = sprintf( "/queue/%s-%s", $namespace, $job_queue );
154
        $conn->send_with_receipt( { destination => $destination, body => $encoded_args, persistent => 'true' } )
154
        $conn->send_with_receipt(
155
            or Koha::Exceptions::BackgroundJob->throw('Job has not been enqueued');
155
            {
156
                destination    => $destination, body => $encoded_args, persistent => 'true',
157
                'content-type' => 'application/json'
158
            }
159
        ) or Koha::Exceptions::BackgroundJob->throw('Job has not been enqueued');
156
    } catch {
160
    } catch {
157
        $self->status('failed')->store;
161
        $self->status('failed')->store;
158
        if ( ref($_) eq 'Koha::Exceptions::BackgroundJob' ) {
162
        if ( ref($_) eq 'Koha::Exceptions::BackgroundJob' ) {
(-)a/misc/workers/es_indexer_daemon.pl (-3 / +21 lines)
Lines 118-125 while (1) { Link Here
118
        }
118
        }
119
119
120
        my $args = try {
120
        my $args = try {
121
            my $body = $frame->body;
121
            my $command      = $frame->command;
122
            decode_json($body);    # TODO Should this be from_json? Check utf8 flag.
122
            my $body         = $frame->body;
123
            my $content_type = $frame->content_type;
124
            if ( $command && $command eq 'MESSAGE' ) {
125
                if ( $content_type && $content_type eq 'application/json' ) {
126
                    decode_json($body);    # TODO Should this be from_json? Check utf8 flag.
127
                } else {
128
129
                    #TODO: This is a fallback for older enqueued messages which are missing the content-type header
130
                    #TODO: Please replace this decode with a die in the future once content-type is well established
131
                    decode_json($body);    # TODO Should this be from_json? Check utf8 flag.
132
                }
133
            } elsif ( $command && $command eq 'ERROR' ) {
134
135
                #Known errors:
136
                #You must log in using CONNECT first
137
                #"NACK" must include a valid "message-id" header
138
                Koha::Logger->get( { interface => 'worker' } )
139
                    ->warn( sprintf "Shutting down after receiving ERROR frame:\n%s\n", $frame->as_string );
140
                exit 1;
141
            }
123
        } catch {
142
        } catch {
124
            Koha::Logger->get( { interface => 'worker' } )->warn( sprintf "Frame not processed - %s", $_ );
143
            Koha::Logger->get( { interface => 'worker' } )->warn( sprintf "Frame not processed - %s", $_ );
125
            return;
144
            return;
126
- 

Return to bug 34070