ruby-amqp / hutch

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

Starting `hutch` consumers fails within Rails Engine. #361

Open pacso opened 3 years ago

pacso commented 3 years ago

I'm building a Rails Engine gem, which provides shared application code required by a number of microservices within our application. We're replacing our REST APIs which previously were used for inter-service communications with RabbitMQ using Hutch.

We've hit a problem when developing the integration within our gem though. When you try to start the consumers using the hutch cli script, it fails to start correctly.

If I start it within the gem root directory, hutch starts OK but doesn't detect any consumers:

2021-03-09T10:05:00Z 12408 INFO -- hutch booted with pid 12408
2021-03-09T10:05:00Z 12408 INFO -- connecting to rabbitmq (amqp://guest@127.0.0.1:5672/)
2021-03-09T10:05:00Z 12408 INFO -- connected to RabbitMQ at 127.0.0.1 as guest
2021-03-09T10:05:00Z 12408 INFO -- opening rabbitmq channel with pool size 1, abort on exception false
2021-03-09T10:05:00Z 12408 INFO -- using topic exchange 'hutch'
2021-03-09T10:05:00Z 12408 INFO -- HTTP API use is enabled
2021-03-09T10:05:00Z 12408 INFO -- connecting to rabbitmq HTTP API (http://guest@127.0.0.1:15672/)
2021-03-09T10:05:00Z 12408 INFO -- tracing is disabled
2021-03-09T10:05:00Z 12408 WARN -- no consumer loaded, ensure there's no configuration issue
2021-03-09T10:05:00Z 12408 INFO -- setting up queues

However, if I start hutch from within the test/dummy directory where the test rails app sits, it fails to start:

2021-03-09T10:05:15Z 12500 INFO -- hutch booted with pid 12500
2021-03-09T10:05:15Z 12500 INFO -- found rails project (.), booting app in development environment
2021-03-09T10:05:15Z 12500 INFO -- Requiring /Users/jon/code/project/test/dummy/config/environment.rb
/Users/jon/code/project/test/dummy/Gemfile not found

Has anybody got experience running hutch within a Rails Engine? Am I doing something wrong?