Tochtli is a set of conventions and tools that simplifies the implementation of components communicating over the RabbitMQ broker. Internally it depends on bunny gem.
The communication between application and service looks like on the above picture. The application calls the client (regular object) methods which expose the service API. The request (a message) is created and sent by the client to the service queue (dedicated queue per service controller). RabbitMQ is used as a message broker and delivers the request to the service controller. The controller implements the actions that are performed on the request and may result in the response. The response message is published on the reply queue (private for a client connection). The client receives the response and returns the expected result to the application. The client methods can be implemented in the blocking and non-blocking (asynchronous) way.
The stable service interface really helps to reduce costs of a inevitable change that should only affect the internal implementation. In the proposed above layered structure the application interacts only with the public client class methods. It's not very hard to implement client methods in a such way that they will allow for future changes which won't cause compatibility issues. The expected resistance on the service API changes is a reason way application has no access to the messages definition. Only clients and service controllers operate on the message layer (the common layer). The bottom layer contains tools that allow for communication between the client and the server. There is an option for the message broker agnosticism in the future, because client and service implementation should not directly depend on the particular tool (ex. bunny).
Read more about Tochtli and go through the tutorial on Tochtli homepage.
Run rabbitmq using foreman (copy
Procfile before if needed):
bundle exec foreman start
In another shell run tests:
bundle exec rake test
- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don't break it in a future version unintentionally.
- Send me a pull request.
Released under the MIT license.