All Projects → furdarius → Rabbitroutine

furdarius / Rabbitroutine

Licence: mit
Lightweight library that handles RabbitMQ auto-reconnect and publishing retry routine for you.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Rabbitroutine

Laravel Queue Rabbitmq
RabbitMQ driver for Laravel Queue. Supports Laravel Horizon.
Stars: ✭ 1,175 (+1425.97%)
Mutual labels:  rabbitmq, amqp
Spring Boot Rabbitmq
Spring Boot集成rabbitMQ实现消息推送
Stars: ✭ 24 (-68.83%)
Mutual labels:  rabbitmq, amqp
Machinery
Machinery is an asynchronous task queue/job queue based on distributed message passing.
Stars: ✭ 5,821 (+7459.74%)
Mutual labels:  rabbitmq, amqp
Humusamqp
PHP 7 AMQP library
Stars: ✭ 70 (-9.09%)
Mutual labels:  rabbitmq, amqp
Yii Queue
Queue extension for Yii 3.0
Stars: ✭ 38 (-50.65%)
Mutual labels:  rabbitmq, amqp
Amqp
Go client for AMQP 0.9.1
Stars: ✭ 4,170 (+5315.58%)
Mutual labels:  rabbitmq, amqp
Node Celery
Celery client for Node.js
Stars: ✭ 648 (+741.56%)
Mutual labels:  rabbitmq, amqp
rbmq
Simple API for spawning RabbitMQ Producers and Consumers.
Stars: ✭ 20 (-74.03%)
Mutual labels:  rabbitmq, amqp
Rabbitmq Server
Open source RabbitMQ: core server and tier 1 (built-in) plugins
Stars: ✭ 9,064 (+11671.43%)
Mutual labels:  rabbitmq, amqp
Yii2 Queue
Yii2 Queue Extension. Supports DB, Redis, RabbitMQ, Beanstalk and Gearman
Stars: ✭ 977 (+1168.83%)
Mutual labels:  rabbitmq, amqp
Php Amqplib
The most widely used PHP client for RabbitMQ
Stars: ✭ 3,950 (+5029.87%)
Mutual labels:  rabbitmq, amqp
Yii2 Rabbitmq
RabbitMQ Extension for Yii2
Stars: ✭ 52 (-32.47%)
Mutual labels:  rabbitmq, amqp
Pg Amqp Bridge
Send messages to RabbitMQ from PostgreSQL
Stars: ✭ 334 (+333.77%)
Mutual labels:  rabbitmq, amqp
Servicebus
Simple service bus for sending events between processes using amqp.
Stars: ✭ 415 (+438.96%)
Mutual labels:  rabbitmq, amqp
Benthos
Fancy stream processing made operationally mundane
Stars: ✭ 3,705 (+4711.69%)
Mutual labels:  rabbitmq, amqp
Aio Pika
AMQP 0.9 client designed for asyncio and humans.
Stars: ✭ 611 (+693.51%)
Mutual labels:  rabbitmq, amqp
node-carotte-amqp
An amqplib wrapper for microservices
Stars: ✭ 27 (-64.94%)
Mutual labels:  rabbitmq, amqp
flask-rabbitmq
A simple Python Flask combined with RabbitMQ pika library
Stars: ✭ 52 (-32.47%)
Mutual labels:  rabbitmq, amqp
Remit
RabbitMQ-backed microservices supporting RPC, pubsub, automatic service discovery and scaling with no code changes.
Stars: ✭ 24 (-68.83%)
Mutual labels:  rabbitmq, amqp
Tackle
💯 percent reliable microservice communication
Stars: ✭ 44 (-42.86%)
Mutual labels:  rabbitmq, amqp

PkgGoDev Build Status Go Report Card

Rabbitmq Failover Routine

Lightweight library that handles RabbitMQ auto-reconnect and publishing retry routine for you. The library is designed to save the developer from the headache when working with RabbitMQ.

rabbitroutine solves your RabbitMQ reconnection problems:

Stop to do wrappers, do features!

Install

go get github.com/furdarius/rabbitroutine

Adding as dependency by "go dep"

$ dep ensure -add github.com/furdarius/rabbitroutine

Usage

Consuming

You need to implement Consumer and register it with StartConsumer or with StartMultipleConsumers. When connection is established (at first time or after reconnect) Declare method is called. It can be used to declare required RabbitMQ entities (consumer example).

Usage example:


// Consumer declares your own RabbitMQ consumer implementing rabbitroutine.Consumer interface.
type Consumer struct {}
func (c *Consumer) Declare(ctx context.Context, ch *amqp.Channel) error {}
func (c *Consumer) Consume(ctx context.Context, ch *amqp.Channel) error {}

url := "amqp://guest:[email protected]:5672/"

conn := rabbitroutine.NewConnector(rabbitroutine.Config{
    // How long to wait between reconnect
    Wait: 2 * time.Second,
})

ctx := context.Background()

go func() {
    err := conn.Dial(ctx, url)
    if err != nil {
    	log.Println(err)
    }
}()

consumer := &Consumer{}
go func() {
    err := conn.StartConsumer(ctx, consumer)
    if err != nil {
        log.Println(err)
    }
}()

Full example demonstrates messages consuming

Publishing

For publishing FireForgetPublisher and EnsurePublisher implemented. Both of them can be wrapped with RetryPublisher to repeat publishing on errors and mitigate short-term network problems.

Usage example:

ctx := context.Background()

url := "amqp://guest:[email protected]:5672/"

conn := rabbitroutine.NewConnector(rabbitroutine.Config{
    // How long wait between reconnect
    Wait: 2 * time.Second,
})

pool := rabbitroutine.NewPool(conn)
ensurePub := rabbitroutine.NewEnsurePublisher(pool)
pub := rabbitroutine.NewRetryPublisher(
    ensurePub,
    rabbitroutine.PublishMaxAttemptsSetup(16),
    rabbitroutine.PublishDelaySetup(rabbitroutine.LinearDelay(10*time.Millisecond)),
)

go conn.Dial(ctx, url)

err := pub.Publish(ctx, "myexch", "myqueue", amqp.Publishing{Body: []byte("message")})
if err != nil {
    log.Println("publish error:", err)
}

Full example demonstrates messages publishing

Contributing

Pull requests are very much welcomed. Create your pull request, make sure a test or example is included that covers your change and your commits represent coherent changes that include a reason for the change.

To run the integration tests, make sure you have RabbitMQ running on any host (e.g with docker run --net=host -it --rm rabbitmq), then export the environment variable AMQP_URL=amqp://host/ and run go test -tags integration. As example:

AMQP_URL=amqp://guest:[email protected]:5672/ go test -v -race -cpu=1,2 -tags integration -timeout 5s

Use golangci-lint to check code with linters:

golangci-lint run ./...

TravisCI will also run the integration tests and golangci-lint.

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].