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 119-126 while (1) { Link Here
119
        }
119
        }
120
120
121
        my $args = try {
121
        my $args = try {
122
            my $body = $frame->body;
122
            my $command      = $frame->command;
123
            decode_json($body);    # TODO Should this be from_json? Check utf8 flag.
123
            my $body         = $frame->body;
124
            my $content_type = $frame->content_type;
125
            if ( $command && $command eq 'MESSAGE' ) {
126
                if ( $content_type && $content_type eq 'application/json' ) {
127
                    decode_json($body);    # TODO Should this be from_json? Check utf8 flag.
128
                } else {
129
130
                    #TODO: This is a fallback for older enqueued messages which are missing the content-type header
131
                    #TODO: Please replace this decode with a die in the future once content-type is well established
132
                    decode_json($body);    # TODO Should this be from_json? Check utf8 flag.
133
                }
134
            } elsif ( $command && $command eq 'ERROR' ) {
135
136
                #Known errors:
137
                #You must log in using CONNECT first
138
                #"NACK" must include a valid "message-id" header
139
                Koha::Logger->get( { interface => 'worker' } )
140
                    ->warn( sprintf "Shutting down after receiving ERROR frame:\n%s\n", $frame->as_string );
141
                exit 1;
142
            }
124
        } catch {
143
        } catch {
125
            Koha::Logger->get( { interface => 'worker' } )->warn( sprintf "Frame not processed - %s", $_ );
144
            Koha::Logger->get( { interface => 'worker' } )->warn( sprintf "Frame not processed - %s", $_ );
126
            return;
145
            return;
127
- 

Return to bug 34070