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

(-)a/Koha/BackgroundJob.pm (-12 / +13 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 78-84 sub connect { Link Here
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
    my $stomp = Net::Stomp->new( { hostname => $hostname, port => $port } );
81
    $stomp->connect( $credentials );
85
    try {
86
        $stomp = $self->connect;
87
    } catch {
88
        warn "Cannot connect to broker " . $_;
89
        $stomp = undef;
90
    };
91
82
    return $stomp;
92
    return $stomp;
83
}
93
}
84
94
Lines 121-139 sub enqueue { Link Here
121
        }
131
        }
122
    )->store;
132
    )->store;
123
133
124
    my $notification_method = C4::Context->preference('JobsNotificationMethod') // 'STOMP';
125
126
    return $self->id
127
        unless $notification_method eq 'STOMP';
128
129
    $job_args->{job_id} = $self->id;
134
    $job_args->{job_id} = $self->id;
130
135
131
    my $conn;
136
    my $conn = $self->connect;
132
    try {
137
133
        $conn = $self->connect;
134
    } catch {
135
        warn "Cannot connect to broker " . $_;
136
    };
137
    return $self->id unless $conn;
138
    return $self->id unless $conn;
138
139
139
    $json_args = $json->encode($job_args);
140
    $json_args = $json->encode($job_args);
(-)a/about.pl (-5 / +3 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
            $template->param( warnConnectBroker => C4::Context->preference('JobsNotificationMethod') );
912
            $template->param( warnConnectBroker => $@ );
913
        }
912
        }
914
    }
913
    }
915
  }
914
  }
916
- 

Return to bug 35655