Skip to content

Latest commit

History

112 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

MessageQueue

Usage

Configuration

# in config/config.exsconfig:message_queue,app_name: my_app,adapter: :rabbitmq,rpc_modules: [SampleModule]
  • app_name - name of your application
  • adapter - kind of adapter. Possible values: :rabbitmq, :sandbox
  • rpc_modules - modules are available for remote call

Using Adapters

An adapter is a set of instructions for how to communicate with a specific service.

MessageQueue provides adapters for use RabbitMQ and for testing. To use these adapters, declare them in the environment configuration.

You can create new adapters for any environment by implementing the MessageQueue.Adapters.Producer, MessageQueue.Adapters.Consumer, MessageQueue.Adapters.RPCServer, MessageQueue.Adapters.RPCCclient or MessageQueue.Adapters.Connection behaviour.

config:message_queue,adapter: MessageQueue.CustomLocalAdapter

In that case you must define module(s) for specific logic.

Follow the naming convention!

For example:

MessageQueue.CustomLocalAdapter.Producer
MessageQueue.CustomLocalAdapter.Consumer
MessageQueue.CustomLocalAdapter.RPCServer
MessageQueue.CustomLocalAdapter.RPCClient
MessageQueue.CustomLocalAdapter.Connection

Consumer

useMessageQueue.Consumerdefstart_link(_opts)doGenServer.start_link(__MODULE__,%{queue: "queue",prefetch_count: 1},name: __MODULE__)enddefhandle_message(payload,meta,state)do...end

Development

Running tests

The test suite mocks all AMQP modules, so no running RabbitMQ is required:

mix test --no-start

Running the benchmark

Requires a RabbitMQ instance (default on localhost:5672):

mix run --no-start bench/publish_vs_publish_all.exs

Override connection details or batch sizes via env vars:

RABBITMQ_HOST=my-host BATCH_SIZES=10,100,1000 mix run --no-start bench/publish_vs_publish_all.exs

Installation

If available in Hex, the package can be installed by adding message_queue to your list of dependencies in mix.exs:

defdepsdo[{:message_queue,github: "ChannexIO/message_queue"}]end

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

5 watching

Forks

Releases

Packages

Contributors

Languages