Skip to content

Commit 04c4550

Browse files
Merge pull request #1431 from sanger/1427-y24-306---bug-as-developers-we-need-to-modify-the-emq-publishing-job-so-it-doesnt-raise-an-error-as-this-stops-users-being-able-to-create-libraries-pools-or-runs-if-the-queue-is-down
Updating the code to not to throw when the EMQ is down
2 parents 0c89312 + 68c9bc6 commit 04c4550

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

app/messages/emq/publishing_job.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ def publish(objects, message_config, schema_key) # rubocop:disable Metrics/AbcSi
7373
# Log success message after successful publishing
7474
Rails.logger.info('Published volume tracking message to EMQ')
7575
rescue StandardError => e
76-
# Raise an exception if any error occurs
77-
raise "Failed to publish message to EMQ: #{e.message}"
76+
# DO NOT Raise an exception if any error occurs; logs the error instead
77+
# This is to prevent the job from failing and to allow the job to continue
78+
# These logs can be monitored through Kibana
79+
Rails.logger.error("Failed to publish message to EMQ: #{e.message}")
7880
end
7981
end
8082

spec/messages/emq/publishing_job_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,10 @@
104104
assert_equal 'create-aliquot-in-mlwh', deep_struct.amqp.schemas.subjects.volume_tracking.subject
105105
assert_equal 1, deep_struct.amqp.schemas.subjects.volume_tracking.version
106106
end
107+
108+
it 'logs error message when the EMQ is down' do
109+
allow(emq_sender_mock).to receive(:send_message).and_raise(StandardError)
110+
expect(Rails.logger).to receive(:error).with('Failed to publish message to EMQ: StandardError')
111+
publishing_job.publish(aliquot, Pipelines.pacbio, 'volume_tracking')
112+
end
107113
end

0 commit comments

Comments
 (0)