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

(-)a/Koha/BackgroundJob.pm (-8 / +16 lines)
Lines 63-68 Connect to the message broker using default guest/guest credential Link Here
63
63
64
sub connect {
64
sub connect {
65
    my ( $self );
65
    my ( $self );
66
    my $notification_method = C4::Context->preference('JobsNotificationMethod') // 'STOMP';
67
    return undef
68
        unless $notification_method eq 'STOMP';
69
66
    my $hostname = 'localhost';
70
    my $hostname = 'localhost';
67
    my $port = '61613';
71
    my $port = '61613';
68
    my $config = C4::Context->config('message_broker');
72
    my $config = C4::Context->config('message_broker');
Lines 77-84 sub connect { Link Here
77
        $credentials->{passcode} = $config->{password} if $config->{password};
81
        $credentials->{passcode} = $config->{password} if $config->{password};
78
        $credentials->{host} = $config->{vhost} if $config->{vhost};
82
        $credentials->{host} = $config->{vhost} if $config->{vhost};
79
    }
83
    }
80
    my $stomp = Net::Stomp->new( { hostname => $hostname, port => $port } );
84
81
    $stomp->connect( $credentials );
85
    my $stomp;
86
87
    try {
88
        $stomp = Net::Stomp->new( { hostname => $hostname, port => $port } );
89
        $stomp->connect( $credentials );
90
    } catch {
91
        warn "Cannot connect to broker " . $_;
92
        $stomp = undef;
93
    };
94
82
    return $stomp;
95
    return $stomp;
83
}
96
}
84
97
Lines 123-134 sub enqueue { Link Here
123
136
124
    $job_args->{job_id} = $self->id;
137
    $job_args->{job_id} = $self->id;
125
138
126
    my $conn;
139
    my $conn = $self->connect;
127
    try {
128
        $conn = $self->connect;
129
    } catch {
130
        warn "Cannot connect to broker " . $_;
131
    };
132
    return $self->id unless $conn;
140
    return $self->id unless $conn;
133
141
134
    $json_args = $json->encode($job_args);
142
    $json_args = $json->encode($job_args);
(-)a/about.pl (-4 / +9 lines)
Lines 906-915 sub message_broker_check { Link Here
906
    my $template = shift;
906
    my $template = shift;
907
    {
907
    {
908
        # BackgroundJob - test connection to message broker
908
        # BackgroundJob - test connection to message broker
909
        eval { Koha::BackgroundJob->connect; };
909
        my $conn = Koha::BackgroundJob->connect;
910
        if ($@) {
910
        if (! $conn) {
911
            warn $@;
911
            if (C4::Context->preference('JobsNotificationMethod') eq 'STOMP' ) {
912
            $template->param( warnConnectBroker => $@ );
912
                $template->param( warnConnectBroker => 'Error connecting' );
913
            } else {
914
                $template->param(
915
                    warnConnectBroker => C4::Context->preference('JobsNotificationMethod')
916
                );
917
            }
913
        }
918
        }
914
    }
919
    }
915
  }
920
  }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt (-2 / +3 lines)
Lines 202-208 Link Here
202
            </tr>
202
            </tr>
203
            <tr>
203
            <tr>
204
                <th scope="row">Message broker: </th>
204
                <th scope="row">Message broker: </th>
205
                [% IF warnConnectBroker %]
205
                [% IF warnConnectBroker == 'Error connecting' %]
206
                    <td class="text-bg-warning"><strong>Using SQL polling (Fallback, Error connecting to RabbitMQ)</strong></td>
207
                [% ELSIF warnConnectBroker %]
206
                    <td class="text-bg-warning"><strong>Using SQL polling</strong></td>
208
                    <td class="text-bg-warning"><strong>Using SQL polling</strong></td>
207
                [% ELSE %]
209
                [% ELSE %]
208
                    <td class="text-bg-info">Using RabbitMQ</td>
210
                    <td class="text-bg-info">Using RabbitMQ</td>
209
- 

Return to bug 35655