From 632dd10abfe82ec1f5fa203ae43ef93bdac659b4 Mon Sep 17 00:00:00 2001 From: vkghub Date: Mon, 9 Sep 2024 10:45:42 -0400 Subject: [PATCH 1/9] Add event_source with auto-scaling. --- Gemfile | 2 +- Gemfile.lock | 6 +++--- components/mitc_service/Gemfile | 2 +- components/mitc_service/Gemfile.lock | 6 +++--- .../spec/dummy/config/initializers/event_source.rb | 5 +++++ config/initializers/event_source.rb | 2 +- 6 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 components/mitc_service/spec/dummy/config/initializers/event_source.rb diff --git a/Gemfile b/Gemfile index 39e50360..395fa377 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ ruby '2.7.6' gem 'mitc_service', path: 'components/mitc_service' gem 'aca_entities', git: 'https://github.com/ideacrew/aca_entities.git', branch: 'trunk' -gem 'event_source', git: 'https://github.com/ideacrew/event_source.git', branch: 'trunk' +gem 'event_source', git: 'https://github.com/ideacrew/event_source.git', branch: 'wait_for_rails_start' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' gem 'rails', '~> 6.1.3' diff --git a/Gemfile.lock b/Gemfile.lock index 70836090..fd09a13e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -18,10 +18,10 @@ GIT GIT remote: https://github.com/ideacrew/event_source.git - revision: 29393ebb04df8f57ccb536da4635087c8c8bde0b - branch: trunk + revision: 1a876c5badb31ed05b7160e0d2a15343b96e9ba0 + branch: wait_for_rails_start specs: - event_source (0.5.5) + event_source (0.5.8) bunny (>= 2.14) deep_merge (~> 1.2.0) dry-events (~> 0.3) diff --git a/components/mitc_service/Gemfile b/components/mitc_service/Gemfile index b979c331..2e9afa21 100644 --- a/components/mitc_service/Gemfile +++ b/components/mitc_service/Gemfile @@ -10,7 +10,7 @@ gemspec # gem 'byebug', group: [:development, :test] gem 'aca_entities', git: 'https://github.com/ideacrew/aca_entities.git', branch: 'trunk' -gem 'event_source', git: 'https://github.com/ideacrew/event_source.git', branch: 'trunk' +gem 'event_source', git: 'https://github.com/ideacrew/event_source.git', branch: 'wait_for_rails_start' group :development, :test do gem "rspec-rails" diff --git a/components/mitc_service/Gemfile.lock b/components/mitc_service/Gemfile.lock index 86fe092a..b8f035ff 100644 --- a/components/mitc_service/Gemfile.lock +++ b/components/mitc_service/Gemfile.lock @@ -17,10 +17,10 @@ GIT GIT remote: https://github.com/ideacrew/event_source.git - revision: 29393ebb04df8f57ccb536da4635087c8c8bde0b - branch: trunk + revision: 1a876c5badb31ed05b7160e0d2a15343b96e9ba0 + branch: wait_for_rails_start specs: - event_source (0.5.5) + event_source (0.5.8) bunny (>= 2.14) deep_merge (~> 1.2.0) dry-events (~> 0.3) diff --git a/components/mitc_service/spec/dummy/config/initializers/event_source.rb b/components/mitc_service/spec/dummy/config/initializers/event_source.rb new file mode 100644 index 00000000..a2c4ee7d --- /dev/null +++ b/components/mitc_service/spec/dummy/config/initializers/event_source.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +EventSource.configure do |config| + config.protocols = %w[amqp http] +end diff --git a/config/initializers/event_source.rb b/config/initializers/event_source.rb index f4c32167..707aeafb 100644 --- a/config/initializers/event_source.rb +++ b/config/initializers/event_source.rb @@ -65,4 +65,4 @@ end end -EventSource.initialize! \ No newline at end of file +# EventSource.initialize! From b9ecd1eca67836c0dc574e3c3422da4694111996 Mon Sep 17 00:00:00 2001 From: vkghub Date: Mon, 16 Sep 2024 17:25:55 -0400 Subject: [PATCH 2/9] add loggers --- .../aptc_csr_credits/renewals/renewals_subscriber.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/event_source/subscribers/aptc_csr_credits/renewals/renewals_subscriber.rb b/app/event_source/subscribers/aptc_csr_credits/renewals/renewals_subscriber.rb index 2c3a31ce..1c5bb4e8 100644 --- a/app/event_source/subscribers/aptc_csr_credits/renewals/renewals_subscriber.rb +++ b/app/event_source/subscribers/aptc_csr_credits/renewals/renewals_subscriber.rb @@ -8,20 +8,28 @@ class RenewalsSubscriber include ::EventSource::Subscriber[amqp: 'enroll.applications.aptc_csr_credits.renewals'] subscribe(:on_enroll_applications_aptc_csr_credits_renewals) do |delivery_info, _metadata, response| + subscriber_logger = + Logger.new( + "#{Rails.root}/log/on_enroll_applications_aptc_csr_credits_renewals_mg_#{TimeKeeper.date_of_record.strftime('%Y_%m_%d')}.log" + ) + payload = JSON.parse(response, :symbolize_names => true) is_renewal = true result = ::Eligibilities::Medicaid::RequestDetermination.new.call(payload, is_renewal) if result.success? ack(delivery_info.delivery_tag) + subscriber_logger.info "renewal_subscriber_message, success: app_hbx_id: #{payload[:hbx_id]}" logger.debug "renewal_subscriber_message; acked" else errors = result.failure.errors.to_h ack(delivery_info.delivery_tag) + subscriber_logger.info "renewal_subscriber_message; acked (nacked) for app_hbx_id: #{payload[:hbx_id]}, due to #{errors}" logger.debug "renewal_subscriber_message; acked (nacked) due to:#{errors}" end rescue StandardError, SystemStackError => e ack(delivery_info.delivery_tag) + subscriber_logger.info "renewal_subscriber_message; for app_hbx_id: #{payload[:hbx_id]} | backtrace: #{e.backtrace}; acked (nacked)" logger.debug "renewal_subscriber_error: baacktrace: #{e.backtrace}; acked (nacked)" end end From 6086d7a1dcc4209986c2b07c470bcf3114789b48 Mon Sep 17 00:00:00 2001 From: vkghub Date: Tue, 17 Sep 2024 11:47:44 -0400 Subject: [PATCH 3/9] fix typo --- .../aptc_csr_credits/renewals/renewals_subscriber.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/event_source/subscribers/aptc_csr_credits/renewals/renewals_subscriber.rb b/app/event_source/subscribers/aptc_csr_credits/renewals/renewals_subscriber.rb index 1c5bb4e8..dd56b309 100644 --- a/app/event_source/subscribers/aptc_csr_credits/renewals/renewals_subscriber.rb +++ b/app/event_source/subscribers/aptc_csr_credits/renewals/renewals_subscriber.rb @@ -29,7 +29,7 @@ class RenewalsSubscriber end rescue StandardError, SystemStackError => e ack(delivery_info.delivery_tag) - subscriber_logger.info "renewal_subscriber_message; for app_hbx_id: #{payload[:hbx_id]} | backtrace: #{e.backtrace}; acked (nacked)" + subscriber_logger.info "renewal_subscriber_message | backtrace: #{e.backtrace}; acked (nacked)" logger.debug "renewal_subscriber_error: baacktrace: #{e.backtrace}; acked (nacked)" end end From 33b41bc00c23a6f5e2cde9a0e95b6c45c1fab0a5 Mon Sep 17 00:00:00 2001 From: vkghub Date: Tue, 17 Sep 2024 12:03:17 -0400 Subject: [PATCH 4/9] revert logger --- .../aptc_csr_credits/renewals/renewals_subscriber.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/event_source/subscribers/aptc_csr_credits/renewals/renewals_subscriber.rb b/app/event_source/subscribers/aptc_csr_credits/renewals/renewals_subscriber.rb index dd56b309..2c3a31ce 100644 --- a/app/event_source/subscribers/aptc_csr_credits/renewals/renewals_subscriber.rb +++ b/app/event_source/subscribers/aptc_csr_credits/renewals/renewals_subscriber.rb @@ -8,28 +8,20 @@ class RenewalsSubscriber include ::EventSource::Subscriber[amqp: 'enroll.applications.aptc_csr_credits.renewals'] subscribe(:on_enroll_applications_aptc_csr_credits_renewals) do |delivery_info, _metadata, response| - subscriber_logger = - Logger.new( - "#{Rails.root}/log/on_enroll_applications_aptc_csr_credits_renewals_mg_#{TimeKeeper.date_of_record.strftime('%Y_%m_%d')}.log" - ) - payload = JSON.parse(response, :symbolize_names => true) is_renewal = true result = ::Eligibilities::Medicaid::RequestDetermination.new.call(payload, is_renewal) if result.success? ack(delivery_info.delivery_tag) - subscriber_logger.info "renewal_subscriber_message, success: app_hbx_id: #{payload[:hbx_id]}" logger.debug "renewal_subscriber_message; acked" else errors = result.failure.errors.to_h ack(delivery_info.delivery_tag) - subscriber_logger.info "renewal_subscriber_message; acked (nacked) for app_hbx_id: #{payload[:hbx_id]}, due to #{errors}" logger.debug "renewal_subscriber_message; acked (nacked) due to:#{errors}" end rescue StandardError, SystemStackError => e ack(delivery_info.delivery_tag) - subscriber_logger.info "renewal_subscriber_message | backtrace: #{e.backtrace}; acked (nacked)" logger.debug "renewal_subscriber_error: baacktrace: #{e.backtrace}; acked (nacked)" end end From eddce8e83abf0d5a2ada7ee48a435fcde8d50453 Mon Sep 17 00:00:00 2001 From: Sai Kumar Kotagiri Date: Tue, 17 Sep 2024 14:36:56 -0400 Subject: [PATCH 5/9] adds additional logging --- .../subscribers/mitc_response_subscriber.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/event_source/subscribers/mitc_response_subscriber.rb b/app/event_source/subscribers/mitc_response_subscriber.rb index 00e607df..359dea57 100644 --- a/app/event_source/subscribers/mitc_response_subscriber.rb +++ b/app/event_source/subscribers/mitc_response_subscriber.rb @@ -13,17 +13,29 @@ class MitcResponseSubscriber # # @return [success/failure message] subscribe(:on_determinations_eval) do |body, status, headers| + @subscriber_logger = Logger.new( + File.join(Rails.root, 'log', "mitc_response_subscriber_#{Date.today.strftime('%Y_%m_%d')}.log") + ) + @subscriber_logger.info '-' * 100 + @subscriber_logger.info "MitcResponseSubscriber#on_determinations_eval body: #{body}, status: #{status}, headers: #{headers}" + logger.info "MitcResponseSubscriber#on_determinations_eval body: #{body}, status: #{status}, headers: #{headers}" correlation_id = headers["CorrelationID"] persist(body, correlation_id) + + end def self.persist(response, correlation_id) logger.info "MitcResponseSubscriber response: #{response}, response_class: #{response.class}" params = { medicaid_application_id: correlation_id, medicaid_response_payload: response } + @subscriber_logger.info "MitcResponseSubscriber#persist params: #{params}" + result = Eligibilities::DetermineFullEligibility.new.call(params.deep_symbolize_keys!) + @subscriber_logger.info "MitcResponseSubscriber#persist result: #{result.inspect}" + message = if result.success? result.success else From 905bb10920655ffd607efbb33c0b39015dbd1dca Mon Sep 17 00:00:00 2001 From: Sai Kumar Kotagiri Date: Tue, 17 Sep 2024 14:38:52 -0400 Subject: [PATCH 6/9] removes extra spaces --- app/event_source/subscribers/mitc_response_subscriber.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/event_source/subscribers/mitc_response_subscriber.rb b/app/event_source/subscribers/mitc_response_subscriber.rb index 359dea57..5f4bf2b7 100644 --- a/app/event_source/subscribers/mitc_response_subscriber.rb +++ b/app/event_source/subscribers/mitc_response_subscriber.rb @@ -22,8 +22,6 @@ class MitcResponseSubscriber logger.info "MitcResponseSubscriber#on_determinations_eval body: #{body}, status: #{status}, headers: #{headers}" correlation_id = headers["CorrelationID"] persist(body, correlation_id) - - end def self.persist(response, correlation_id) From 3d06b1e6c9b2f6ffa668ea53134e4582005bbf70 Mon Sep 17 00:00:00 2001 From: vkghub Date: Tue, 17 Sep 2024 16:17:04 -0400 Subject: [PATCH 7/9] update event source gemfile reference --- Gemfile.lock | 2 +- components/mitc_service/Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index fd09a13e..1cd0218d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -18,7 +18,7 @@ GIT GIT remote: https://github.com/ideacrew/event_source.git - revision: 1a876c5badb31ed05b7160e0d2a15343b96e9ba0 + revision: f5c47281b92bb5d1e5fbc270a2ebfee6c7eb1c69 branch: wait_for_rails_start specs: event_source (0.5.8) diff --git a/components/mitc_service/Gemfile.lock b/components/mitc_service/Gemfile.lock index b8f035ff..32b93ccb 100644 --- a/components/mitc_service/Gemfile.lock +++ b/components/mitc_service/Gemfile.lock @@ -17,7 +17,7 @@ GIT GIT remote: https://github.com/ideacrew/event_source.git - revision: 1a876c5badb31ed05b7160e0d2a15343b96e9ba0 + revision: f5c47281b92bb5d1e5fbc270a2ebfee6c7eb1c69 branch: wait_for_rails_start specs: event_source (0.5.8) From 9de8986d0e4651e2cae3026032175c53c8ed8f50 Mon Sep 17 00:00:00 2001 From: vkghub Date: Tue, 17 Sep 2024 17:19:18 -0400 Subject: [PATCH 8/9] update latest event source --- Gemfile.lock | 2 +- components/mitc_service/Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1cd0218d..38a84089 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -18,7 +18,7 @@ GIT GIT remote: https://github.com/ideacrew/event_source.git - revision: f5c47281b92bb5d1e5fbc270a2ebfee6c7eb1c69 + revision: 08fca58a20973d63eed78416614eae2ff1da4aa7 branch: wait_for_rails_start specs: event_source (0.5.8) diff --git a/components/mitc_service/Gemfile.lock b/components/mitc_service/Gemfile.lock index 32b93ccb..6535df63 100644 --- a/components/mitc_service/Gemfile.lock +++ b/components/mitc_service/Gemfile.lock @@ -17,7 +17,7 @@ GIT GIT remote: https://github.com/ideacrew/event_source.git - revision: f5c47281b92bb5d1e5fbc270a2ebfee6c7eb1c69 + revision: 08fca58a20973d63eed78416614eae2ff1da4aa7 branch: wait_for_rails_start specs: event_source (0.5.8) From 8b7ca82c4756d8ee172163e62f7dd67157d59a25 Mon Sep 17 00:00:00 2001 From: Sai Kumar Kotagiri Date: Wed, 18 Sep 2024 14:01:45 -0400 Subject: [PATCH 9/9] updates event source sha to the latest --- Gemfile.lock | 2 +- components/mitc_service/Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 38a84089..0ef05c60 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -18,7 +18,7 @@ GIT GIT remote: https://github.com/ideacrew/event_source.git - revision: 08fca58a20973d63eed78416614eae2ff1da4aa7 + revision: 3a159e0ace4889bb9652752cd62fade1d153275f branch: wait_for_rails_start specs: event_source (0.5.8) diff --git a/components/mitc_service/Gemfile.lock b/components/mitc_service/Gemfile.lock index 6535df63..c52a99ec 100644 --- a/components/mitc_service/Gemfile.lock +++ b/components/mitc_service/Gemfile.lock @@ -17,7 +17,7 @@ GIT GIT remote: https://github.com/ideacrew/event_source.git - revision: 08fca58a20973d63eed78416614eae2ff1da4aa7 + revision: 3a159e0ace4889bb9652752cd62fade1d153275f branch: wait_for_rails_start specs: event_source (0.5.8)