Skip to content

Commit

Permalink
Merge pull request #20062 from agrare/fix_exception_missing_messaging…
Browse files Browse the repository at this point in the history
…_yml

Fix messaging_client exception if no ENV and no yaml are present

(cherry picked from commit d16c6e7)
  • Loading branch information
bdunne authored and simaishi committed Apr 16, 2020
1 parent c3379bf commit 1e4d4d7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/models/miq_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ def self.messaging_client(client_ref)
# caching the client works, even if the connection becomes unavailable
# internally the client will track the state of the connection and re-open it,
# once it's available again - at least thats true for a stomp connection
ManageIQ::Messaging::Client.open(messaging_client_options.merge(:client_ref => client_ref))
options = messaging_client_options&.merge(:client_ref => client_ref)
return if options.nil?

ManageIQ::Messaging::Client.open(options)
rescue => err
_log.warn("Failed to open messaging client: #{err}")
nil
Expand Down Expand Up @@ -643,10 +646,10 @@ def self.optional_values(options, keys = [:zone])
private_class_method :optional_values

def self.messaging_client_options
(messaging_options_from_env || messaging_options_from_file).merge(
(messaging_options_from_env || messaging_options_from_file)&.merge(
:encoding => "json",
:protocol => messaging_protocol,
).tap { |h| h[:password] = MiqPassword.try_decrypt(h.delete(:password)) }
)&.tap { |h| h[:password] = MiqPassword.try_decrypt(h.delete(:password)) }
end
private_class_method :messaging_client_options

Expand Down

0 comments on commit 1e4d4d7

Please sign in to comment.