ruby-amqp / hutch

A system for processing messages from RabbitMQ.
https://gocardless.com/blog/hutch-inter-service-communication-with-rabbitmq/
MIT License
855 stars 137 forks source link

Can't find consumers in app/consumers when running with Rails 7 #381

Closed wheee closed 2 years ago

wheee commented 2 years ago

Using a fresh install of Rails 7, with the Hutch gem. Added a consumer script to app/consumers.

Ran hutch in the app root directory and got the following output: 2022-07-09T13:40:03Z 39168 INFO -- hutch booted with pid 39168 2022-07-09T13:40:03Z 39168 INFO -- found rails project (.), booting app in development environment 2022-07-09T13:40:04Z 39168 INFO -- connecting to rabbitmq (amqp://guest@127.0.0.1:5672/) 2022-07-09T13:40:04Z 39168 INFO -- connected to RabbitMQ at 127.0.0.1 as guest 2022-07-09T13:40:04Z 39168 INFO -- opening rabbitmq channel with pool size 1, abort on exception false 2022-07-09T13:40:04Z 39168 INFO -- using topic exchange 'hutch' 2022-07-09T13:40:04Z 39168 INFO -- HTTP API use is enabled 2022-07-09T13:40:04Z 39168 INFO -- connecting to rabbitmq HTTP API (http://guest@127.0.0.1:15672/) 2022-07-09T13:40:04Z 39168 INFO -- tracing is disabled 2022-07-09T13:40:04Z 39168 WARN -- no consumer loaded, ensure there's no configuration issue 2022-07-09T13:40:04Z 39168 INFO -- setting up queues

The documentation notes for Zeitwerk loading don't work, more specifically:

  1. ::Zeitwerk::Loader.eager_load_all doesn't do anything
  2. autoloader.preload doesn't exist in Rails 7

I also noted that the eager_load_paths correctly loads app/consumers but it's not preloading any of the rb files inside. If I require the rb file explicitly in the hutch.rb initializer then hutch will pick up the consumer. ie. require Rails.root.join("app/consumers/test_consumer.rb")

wheee commented 2 years ago

it's working all of a sudden - not sure why. Closing the issue until I can figure out what's going on.