Wes Chang
05/16/2023, 8:28 PMorder_finalized event is emitted however, it appears that our event handler is being ignored. Our current setup is a simple 1 line event handler that invokes an ActiveJob which then performs the POST request. We followed the Solidus docs on “Subscribing to Events” and took inspiration from the solidus_subscriptions gem. Our app is hosted on Google Cloud Run with CPU always allocated. In our GCP logs, we do see evidence of other event handlers being executed, such as SolidusSubscriptions::CreateSubscriptionJob which is executed on order_finalized, however, zero logs appear for ours. Initially, we thought that it might be the serverless environment that is preventing the event handler from executing but seeing SolidusSubscriptions::CreateSubscriptionJob running and succeeding, I don’t believe this is the case. Any insight or suggestions would be greatly appreciated. Here are some snippets:
/config/initializers/omnes.rb
Rails.application.config.to_prepare do
  TestStore::OrderFinalized.new.subscribe_to(Spree::Bus)
end
/app/subscribers/test_store/order_finalized.rb
module TestStore
  class OrderFinalized
    include Omnes::Subscriber
    handle :order_finalized,
            with: :notify_order_completed,
            id: :solidus_prod_func_order_completed
    def notify_order_completed(event, context) 
      TestStore::NotifyOrderCompletedJob.perform_later(event.payload[:order])
    end
  end
end
/app/jobs/test_store/notify_order_completed_job.rb
module TestStore
  class NotifyOrderCompletedJob < ApplicationJob
    queue_as :default
    def perform(order)
      handler = "API URL"
      options = {
        body: {
          order: order.to_json
        }
      }
      puts "Sending order to #{handler}"
      <http://HTTParty.post|HTTParty.post>(handler, options)
    end
  end
endjakemumu
05/18/2023, 9:00 PM