-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19984 from agrare/add_support_for_kafka
Add kafka as an option for prototype.queue_type (cherry picked from commit beea070)
- Loading branch information
Showing
5 changed files
with
79 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,2 @@ | ||
class MiqEventHandler::Runner < MiqQueueWorkerBase::Runner | ||
def artemis? | ||
Settings.prototype.queue_type == 'artemis' | ||
end | ||
|
||
def do_before_work_loop | ||
if artemis? | ||
topic_options = { | ||
:service => "events", | ||
:persist_ref => "event_handler" | ||
} | ||
|
||
# this block is stored in a lambda callback and is executed in another thread once a msg is received | ||
MiqQueue.artemis_client('event_handler').subscribe_topic(topic_options) do |sender, event, payload| | ||
_log.info "Received Event (#{event}) by sender #{sender}: #{payload[:event_type]} #{payload[:chain_id]}" | ||
EmsEvent.add(sender.to_i, payload) | ||
end | ||
_log.info "Listening for events..." | ||
end | ||
end | ||
|
||
def do_work | ||
# If we are using MiqQueue then use the default do_work method | ||
super unless artemis? | ||
|
||
# we dont do any work, we are lazy | ||
# upon msg received, the messaging thread will execute the block in .subscribe_topic as above | ||
# sleeping is done in do_work_loop | ||
end | ||
|
||
def before_exit(_message, _exit_code) | ||
return unless artemis? | ||
MiqQueue.artemis_client('event_handler').close | ||
rescue => e | ||
safe_log("Could not close artemis connection: #{e}", 1) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters