All Projects → Nebo15 → rbmq

Nebo15 / rbmq

Licence: MIT License
Simple API for spawning RabbitMQ Producers and Consumers.

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to rbmq

cottontail
Capture all RabbitMQ messages being sent through a broker.
Stars: ✭ 23 (+15%)
Mutual labels:  rabbitmq, amqp
flask-rabbitmq
A simple Python Flask combined with RabbitMQ pika library
Stars: ✭ 52 (+160%)
Mutual labels:  rabbitmq, amqp
Carrot
Carrot is a .NET lightweight library that provides a couple of facilities over RabbitMQ.
Stars: ✭ 14 (-30%)
Mutual labels:  rabbitmq, amqp
postman
Reverse proxy for async microservice communication
Stars: ✭ 30 (+50%)
Mutual labels:  rabbitmq, amqp
amqpextra
Golang AMQP on steroids. Reliable connection. Publisher. Consumer.
Stars: ✭ 59 (+195%)
Mutual labels:  rabbitmq, amqp
nest-rabbit-tasks
nest-rabbit-worker is a TaskQueue based upon RabbitMQ for NestJS
Stars: ✭ 29 (+45%)
Mutual labels:  rabbitmq, amqp
docker-rabbitmq-node
🐳 A playground for Docker with RabbitMQ and Node.
Stars: ✭ 32 (+60%)
Mutual labels:  rabbitmq, amqp
rejected
rejected is a consumer framework for RabbitMQ
Stars: ✭ 56 (+180%)
Mutual labels:  rabbitmq, amqp
go-amqp-reconnect
auto reconnecting example for github.com/streadway/amqp Connection & Channel
Stars: ✭ 79 (+295%)
Mutual labels:  rabbitmq, amqp
http-proxy-amqp
an amqp connection pool implementation
Stars: ✭ 17 (-15%)
Mutual labels:  rabbitmq, amqp
nestjs-rmq
A custom library for NestJS microservice. It allows you to use RabbitMQ or AMQP.
Stars: ✭ 182 (+810%)
Mutual labels:  rabbitmq, amqp
spring-boot-rabbitMQ
Spring Boot集成rabbitMQ实现消息推送
Stars: ✭ 24 (+20%)
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 (+750%)
Mutual labels:  rabbitmq, amqp
go-mq
Declare AMQP entities like queues, producers, and consumers in a declarative way. Can be used to work with RabbitMQ.
Stars: ✭ 76 (+280%)
Mutual labels:  rabbitmq, amqp
roger-rabbit
A module that makes the process of consuming and publishing messages in message brokers easier
Stars: ✭ 12 (-40%)
Mutual labels:  rabbitmq, amqp
watermill-amqp
AMQP Pub/Sub for the Watermill project.
Stars: ✭ 27 (+35%)
Mutual labels:  rabbitmq, amqp
Coherence
Coherence is a full featured, configurable authentication system for Phoenix
Stars: ✭ 1,207 (+5935%)
Mutual labels:  hex, package
Ecto mnesia
Ecto adapter for Mnesia Erlang term database.
Stars: ✭ 223 (+1015%)
Mutual labels:  hex, package
nabbitmq
Node.js library for interacting with RabbitMQ based on RxJS streams
Stars: ✭ 20 (+0%)
Mutual labels:  rabbitmq, amqp
mom
Proof of concept for Message-Oriented-Middleware based architecture.
Stars: ✭ 39 (+95%)
Mutual labels:  rabbitmq, amqp

RBMQ

Simple and easy creation of producers and consumers for RabbitMQ. Written over AMQP

Installation

The package can be installed as:

  1. Add rbmq to your list of dependencies in mix.exs:
def deps do
  [{:rbmq, "~> 0.2.2"}]
end
  1. Ensure rbmq is started before your application:
def application do
  [applications: [:rbmq]]
end

Configuration

You can define connection configuration in your config.exs:

config :my_app, MyAMQPConnection,
  host: {:system, "AMQP_HOST", "localhost"},
  port: {:system, "AMQP_PORT", 5672},
  username: {:system, "AMQP_USER", "guest"},
  password: {:system, "AMQP_PASSWORD", "guest"},
  virtual_host: {:system, "AMQP_VHOST", "/"},
  connection_timeout: {:system, "AMQP_TIMEOUT", 15_000},

RBMQ support linking to runtime environment conflagration via {:system, "ENV_VAR_NAME", "default_value"} and {:system, "ENV_VAR_NAME"} tuples. But are free to set raw values whenever you need.

By default RBMQ read environment configuration to establish AMQP connection:

  • AMQP_HOST - host, default: localhost
  • AMQP_PORT - port, default: 5672
  • AMQP_USER - username, default: guest
  • AMQP_PASSWORD - password, default: guest
  • AMQP_VHOST - default vhost, default: /
  • AMQP_TIMEOUT - timeout, default: 15 sec.

Other connections settings can be found in AMQP client docs.

Usage

  1. Define your connection
defmodule MyAMQPConnection do
  use RBMQ.Connection,
    otp_app: :my_app
    # Optionally you can define queue params right here,
    # but it's better to do so in producer and consumer separately
end
  1. Define your Producer and/or Consumer
defmodule MyProducer do
  use RBMQ.Producer,
    connection: MyAMQPConnection,

    # Queue params
    queue: [
      name: "prodcer_queue",
      error_name: "prodcer_queue_errors",
      routing_key: "prodcer_queue",
      durable: false
    ],
    exchange: [
      name: "prodcer_queue_exchange",
      type: :direct,
      durable: false
    ]
end

defmodule MyConsumer do
  use RBMQ.Consumer,
    connection: MyAMQPConnection,

    # Queue params
    queue: [
      name: "consomer_queue",
      durable: false
    ],
    qos: [
      prefetch_count: 10
    ]

  def consume(_payload, [tag: tag, redelivered?: _redelivered]) do
    ack(tag)
  end
end

Pay attention to consume/2 method. Write your consuming logic there. We recommend to send async messages to GenServer that will consume them, so queue read wouldn't be blocked by a single thread.

If your queue required acknowledgements, use ack\1 and nack\1 methods.

  1. Add everything to your application supervisor:
defmodule MyApp do
  use Application

  # See http://elixir-lang.org/docs/stable/elixir/Application.html
  # for more information on OTP Applications
  def start(_type, _args) do
    import Supervisor.Spec, warn: false

    # Define workers and child supervisors to be supervised
    children = [
      # Start the AMQP connection
      supervisor(MyAMQPConnection, []),
      # Start producer and consumer
      worker(MyProducer, []),
      worker(MyConsumer, []),
    ]

    opts = [strategy: :one_for_one, name: AssetProcessor.API.Supervisor]
    Supervisor.start_link(children, opts)
  end
end
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].