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

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

Return to bug 34070