All Projects → cheshir → go-mq

cheshir / go-mq

Licence: Apache-2.0 license
Declare AMQP entities like queues, producers, and consumers in a declarative way. Can be used to work with RabbitMQ.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to go-mq

nestjs-rmq
A custom library for NestJS microservice. It allows you to use RabbitMQ or AMQP.
Stars: ✭ 182 (+139.47%)
Mutual labels:  rabbitmq, amqp
tomodachi
💻 Microservice library / framework using Python's asyncio event loop with full support for HTTP + WebSockets, AWS SNS+SQS, RabbitMQ / AMQP, middleware, etc. Extendable for GraphQL, protobuf, gRPC, among other technologies.
Stars: ✭ 170 (+123.68%)
Mutual labels:  rabbitmq, amqp
Spring Boot Amqp Messaging
This is a simple spring-boot app that shows how to configure easily RabbitMQ with AMQP for producing and consuming messages in default format and JSON.
Stars: ✭ 142 (+86.84%)
Mutual labels:  rabbitmq, amqp
postman
Reverse proxy for async microservice communication
Stars: ✭ 30 (-60.53%)
Mutual labels:  rabbitmq, amqp
Enqueue Bundle
[READ-ONLY] Message queue bundle for Symfony. RabbitMQ, Amazon SQS, Redis, Service bus, Async events, RPC over MQ and a lot more
Stars: ✭ 233 (+206.58%)
Mutual labels:  rabbitmq, amqp
Amqpstorm
Thread-safe Python RabbitMQ Client & Management library
Stars: ✭ 130 (+71.05%)
Mutual labels:  rabbitmq, amqp
Garagemq
AMQP message broker implemented with golang
Stars: ✭ 153 (+101.32%)
Mutual labels:  rabbitmq, amqp
Aiormq
Pure python AMQP 0.9.1 asynchronous client library
Stars: ✭ 112 (+47.37%)
Mutual labels:  rabbitmq, amqp
Rabtap
RabbitMQ wire tap and swiss army knife
Stars: ✭ 171 (+125%)
Mutual labels:  rabbitmq, amqp
Cony
Simple AMQP wrapper around github.com/streadway/amqp
Stars: ✭ 158 (+107.89%)
Mutual labels:  rabbitmq, amqp
Bitnami Docker Rabbitmq
Bitnami Docker Image for RabbitMQ
Stars: ✭ 120 (+57.89%)
Mutual labels:  rabbitmq, amqp
roger-rabbit
A module that makes the process of consuming and publishing messages in message brokers easier
Stars: ✭ 12 (-84.21%)
Mutual labels:  rabbitmq, amqp
Amqproxy
An intelligent AMQP proxy, with connection and channel pooling/reusing
Stars: ✭ 115 (+51.32%)
Mutual labels:  rabbitmq, amqp
Rabbitmq Dump Queue
Dump messages from a RabbitMQ queue to files, without affecting the queue.
Stars: ✭ 139 (+82.89%)
Mutual labels:  rabbitmq, amqp
Rabbitmq Mock
Mock for RabbitMQ Java amqp-client
Stars: ✭ 114 (+50%)
Mutual labels:  rabbitmq, amqp
Gen rmq
Elixir AMQP consumer and publisher behaviours
Stars: ✭ 146 (+92.11%)
Mutual labels:  rabbitmq, amqp
Rabbus
A tiny wrapper over amqp exchanges and queues 🚌 ✨
Stars: ✭ 86 (+13.16%)
Mutual labels:  rabbitmq, amqp
Amiquip
Pure Rust RabbitMQ client
Stars: ✭ 88 (+15.79%)
Mutual labels:  rabbitmq, amqp
Enqueue Dev
Message Queue, Job Queue, Broadcasting, WebSockets packages for PHP, Symfony, Laravel, Magento. DEVELOPMENT REPOSITORY - provided by Forma-Pro
Stars: ✭ 1,977 (+2501.32%)
Mutual labels:  rabbitmq, amqp
rejected
rejected is a consumer framework for RabbitMQ
Stars: ✭ 56 (-26.32%)
Mutual labels:  rabbitmq, amqp

Build Status codecov Go Report Card Quality Gate Status Sourcegraph GoDoc License

About

This package provides an ability to encapsulate creation and configuration of RabbitMQ([AMQP])(https://www.amqp.org) entities like queues, exchanges, producers and consumers in a declarative way with a single config.

Exchanges, queues and producers are going to be initialized in the background.

go-mq supports both sync and async producers.

go-mq has auto reconnects on closed connection or network error. You can configure delay between each connect try using reconnect_delay option.

Install

go get -u github.com/cheshir/go-mq

API

Visit godoc to get information about library API.

For those of us who preferred learn something new on practice there is working examples in example directory.

Configuration

You can configure mq using mq.Config struct directly or by filling it from config file.

Supported configuration tags:

  • yaml
  • json
  • mapstructure

Available options:

dsn: "amqp://login:password@host:port/virtual_host" # Use comma separated list for cluster connection
reconnect_delay: 5s                     # Interval between connection tries. Check https://golang.org/pkg/time/#ParseDuration for details.
test_mode: false                        # Switches library to use mocked broker. Defaults to false.
exchanges:
  - name: "exchange_name"
    type: "direct"
    options:
      # Available options with default values:
      auto_delete: false
      durable: false
      internal: false
      no_wait: false
queues:
  - name: "queue_name"
    exchange: "exchange_name"
    routing_key: "route"
    # A set of arguments for the binding.
    # The syntax and semantics of these arguments depend on the exchange class.
    binding_options:
      no_wait: false
    # Available options with default values:
    options:
      auto_delete: false
      durable: false
      exclusive: false
      no_wait: false
producers:
  - name: "producer_name"
    buffer_size: 10                      # Declare how many messages we can buffer during fat messages publishing.
    exchange: "exchange_name"
    routing_key: "route"
    sync: false                          # Specify whether producer will worked in sync or async mode.
    # Available options with default values:
    options:
      content_type:  "application/json"
      delivery_mode: 2                   # 1 - non persistent, 2 - persistent.
consumers:
  - name: "consumer_name"
    queue: "queue_name"
    workers: 1                           # Workers count. Defaults to 1.
    prefetch_count: 0                    # Prefetch message count per worker.
    prefetch_size: 0                     # Prefetch message size per worker.
    # Available options with default values:
    options:
      no_ack: false
      no_local: false
      no_wait: false
      exclusive: false

Error handling

All errors are accessible via exported channel:

package main

import (
	"log"

	"github.com/cheshir/go-mq"
)

func main() {
	config := mq.Config{} // Set your configuration.
	queue, _ := mq.New(config)
	// ...

	go handleMQErrors(queue.Error())
	
	// Other logic.
}

func handleMQErrors(errors <-chan error) {
	for err := range errors {
		log.Println(err)
	}
}

If channel is full – new errors will be dropped.

Errors from sync producer won't be accessible from error channel because they returned directly.

Tests

There are some cases that can only be tested with real broker and some cases that can only be tested with mocked broker.

If you are able to run tests with a real broker run them with:

go test -mock-broker=0

Otherwise mock will be used.

Changelog

Check releases page.

How to upgrade

From version 0.x to 1.x

  • GetConsumer() method was renamed to Consumer(). This is done to follow go guideline.

  • GetProducer() method was removed. Use instead AsyncProducer() or SyncProducer() if you want to catch net error by yourself.

Epilogue

Feel free to create issues with bug reports or your wishes.

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