All Projects → renderedtext → Tackle

renderedtext / Tackle

💯 percent reliable microservice communication

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Tackle

Rabbus
A tiny wrapper over amqp exchanges and queues 🚌 ✨
Stars: ✭ 86 (+95.45%)
Mutual labels:  microservices, rabbitmq, amqp
Aiormq
Pure python AMQP 0.9.1 asynchronous client library
Stars: ✭ 112 (+154.55%)
Mutual labels:  asynchronous, rabbitmq, amqp
Remit
RabbitMQ-backed microservices supporting RPC, pubsub, automatic service discovery and scaling with no code changes.
Stars: ✭ 24 (-45.45%)
Mutual labels:  microservices, rabbitmq, amqp
Hippo
💨A well crafted go packages that help you build robust, reliable, maintainable microservices.
Stars: ✭ 134 (+204.55%)
Mutual labels:  microservices, asynchronous, rabbitmq
Servicebus
Simple service bus for sending events between processes using amqp.
Stars: ✭ 415 (+843.18%)
Mutual labels:  rabbitmq, amqp
Netcoremicroservicessample
Sample using micro services in .NET Core 3.1 Focusing on clean code
Stars: ✭ 403 (+815.91%)
Mutual labels:  microservices, rabbitmq
Flower
Real-time monitor and web admin for Celery distributed task queue
Stars: ✭ 5,036 (+11345.45%)
Mutual labels:  asynchronous, rabbitmq
Practical.cleanarchitecture
Asp.Net Core 5 Clean Architecture (Microservices, Modular Monolith, Monolith) samples (+Blazor, Angular 11, React 17, Vue 2.6), Domain-Driven Design, CQRS, Event Sourcing, SOLID, Asp.Net Core Identity Custom Storage, Identity Server 4 Admin UI, Entity Framework Core, Selenium E2E Testing, SignalR Notification, Hangfire Tasks Scheduling, Health Checks, Security Headers, ...
Stars: ✭ 639 (+1352.27%)
Mutual labels:  microservices, rabbitmq
Hexagon
Hexagon is a microservices toolkit written in Kotlin. Its purpose is to ease the building of services (Web applications, APIs or queue consumers) that run inside a cloud platform.
Stars: ✭ 336 (+663.64%)
Mutual labels:  microservices, rabbitmq
Machinery
Machinery is an asynchronous task queue/job queue based on distributed message passing.
Stars: ✭ 5,821 (+13129.55%)
Mutual labels:  rabbitmq, amqp
Node Celery
Celery client for Node.js
Stars: ✭ 648 (+1372.73%)
Mutual labels:  rabbitmq, amqp
Amqp
Go client for AMQP 0.9.1
Stars: ✭ 4,170 (+9377.27%)
Mutual labels:  rabbitmq, amqp
Php Amqplib
The most widely used PHP client for RabbitMQ
Stars: ✭ 3,950 (+8877.27%)
Mutual labels:  rabbitmq, amqp
Nestjs
A collection of badass modules and utilities to help you level up your NestJS applications 🚀
Stars: ✭ 475 (+979.55%)
Mutual labels:  microservices, rabbitmq
Atmosphere
Realtime Client Server Framework for the JVM, supporting WebSockets with Cross-Browser Fallbacks
Stars: ✭ 3,552 (+7972.73%)
Mutual labels:  microservices, asynchronous
Aio Pika
AMQP 0.9 client designed for asyncio and humans.
Stars: ✭ 611 (+1288.64%)
Mutual labels:  rabbitmq, amqp
Pitstop
This repo contains a sample application based on a Garage Management System for Pitstop - a fictitious garage. The primary goal of this sample is to demonstrate several software-architecture concepts like: Microservices, CQRS, Event Sourcing, Domain Driven Design (DDD), Eventual Consistency.
Stars: ✭ 708 (+1509.09%)
Mutual labels:  microservices, rabbitmq
Spring Boot Rabbitmq
Spring Boot集成rabbitMQ实现消息推送
Stars: ✭ 24 (-45.45%)
Mutual labels:  rabbitmq, amqp
Yii Queue
Queue extension for Yii 3.0
Stars: ✭ 38 (-13.64%)
Mutual labels:  rabbitmq, amqp
Springboot Guide
SpringBoot2.0+从入门到实战!
Stars: ✭ 4,142 (+9313.64%)
Mutual labels:  asynchronous, rabbitmq

Tackle

Build Status

Tackles the problem of processing asynchronous jobs in reliable manner by relying on RabbitMQ.

You should also take a look at Elixir Tackle.

Why should I use tackle?

  • It is ideal for fast microservice prototyping
  • It uses sane defaults for queue and exchange creation
  • It retries messages that fail to be processed
  • It stores unprocessed messages into a dead queue for later inspection

Installation

Add this line to your application's Gemfile:

gem "rt-tackle", :require => "tackle"

Publishing messages

With tackle, you can publish a message to an AMQP exchange. For example, to publish "Hello World!" do the following:

options = {
  :url => "amqp://localhost",
  :exchange => "test-exchange",
  :routing_key => "test-messages",
}

Tackle.publish("Hello World!", options)

Optionally, you can pass a dedicated logger to the publish method. This comes handy if you want to log the status of your publish action to a file.

options = {
  :url => "amqp://localhost",
  :exchange => "test-exchange",
  :routing_key => "test-messages",
  :logger => Logger.new("publish.log")
}

Tackle.publish("Hello World!", options)

Consume messages

Tackle enables you to connect to an AMQP exchange and consume messages from it.

Tackle consumer

require "tackle"

options = {
  :url => "amqp://localhost",
  :exchange => "users",
  :routing_key => "signed-up",
  :service => "user-mailer",
  :exception_handler => lambda { |ex, consumer| puts ex.message }
}

Tackle.consume(options) do |message|
  puts message
end

The above code snippet creates the following AMQP resources:

  1. A dedicated exchange for your service, in this example user-mailer.signed-up
  2. Connects your dedicated user-mailer.signed-up exchange to the remote exchange from which you want to consume messages, in this example users exchange
  3. Creates an AMQP queue user-mailer.signed-up and connects it to your local exchange
  4. Creates a delay queue user-mailer.signed-up.delay. If your service raises an exception while processing an incoming message, tackle will put it in this this queue, wait for a while, and then republish to the user-mailer.signed-up exchange.
  5. Creates a dead queue user-mailer.signed-up.dead. After several retries where your service can't consume the message, tackle will store them in a dedicated dead queue. You can consume this messages manually.

You can pass additional configuration to tackle in order to control the number of retries, and the delay between each retry.

require "tackle"

options = {
  :url => "amqp://localhost",
  :exchange => "users",
  :routing_key => "signed-up"
  :service => "user-mailer",
  :retry_limit => 8,
  :retry_delay => 30,
  :exception_handler => lambda { |ex, consumer| puts ex.message }
}

Tackle.consume(options) do |message|
  puts message
end

By default, tackle logs helpful information to the STDOUT. To redirect these messages to a file, pass a dedicated logger to tackle.

require "tackle"

options = {
  :url => "amqp://localhost",
  :exchange => "users",
  :routing_key => "signed-up"
  :service => "user-mailer",
  :retry_limit => 8,
  :retry_delay => 30,
  :logger => Logger.new("consumer.log"),
  :exception_handler => lambda { |ex, consumer| puts ex.message }
}

Tackle.consume(options) do |message|
  puts message
end

Manually ack-ing messages

By default, Tackle assumes that a message was successfully processed if no exceptions were raised in the consume block. This behaviour is well suited for handling unknown exceptions.

Sometimes however, we want to send a message to the retry queue without raising an exception (and polluting our exception tracker with false positives).

For this purpose, tackle can be configured to consume messages in a "manual ack" fashion. Pass :manual_ack => true to the consumer to activate the manual_ack mode.

require "tackle"

options = {
  :url => "amqp://localhost",
  :exchange => "users",
  :routing_key => "signed-up",
  :service => "user-mailer"
  :manual_ack => true
}

Tackle.consume(options) do |message|
  puts message

  Tackle::ACK
end

When Tackle consumes messages in the manual_ack mode, the return value of the consumer block must be either Tackle::ACK or Tackle::NACK. In case the response is Tackle::NACK the message is put on the retry queue.

require "tackle"

options = {
  :url => "amqp://localhost",
  :exchange => "numbers",
  :routing_key => "positive-numbers",
  :service => "number-processor",
  :manual_ack => true
}

Tackle.consume(options) do |message|
  # accept only positive numbers

  if message["value"].even?
    Tackle::ACK
  else
    Tackle::NACK
  end
end

If neither Tackle::ACK nor Tackle::NACK are returned, tackle assumes that the response is negative.

Test

To better performance in unit test put a instance mock of Bunny class in a connection key at options, for example, you could use a gem bunny-mock.

options = {
  :url => "amqp://localhost",
  ...
  :connection => BunnyMock.new
  ...
}

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake rspec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/renderedtext/tackle.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].