This repository has been archived by the owner on Nov 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
113 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1 @@ | ||
# Changelog | ||
|
||
## [0.1.6] - 2018-03-02 | ||
### Added | ||
- Required project configuration to publish on [hex.pm](hex.pm) @mkorszun. | ||
|
||
## [0.1.5] - 2018-02-28 | ||
### Added | ||
- Possibility to control concurrency in consumer @mkorszun. | ||
- Possibility to make `app_id` configurable for publisher @mkorszun. | ||
- Better `ExDoc` documentation | ||
|
||
### Fixed | ||
- If `queue_ttl` specified it also applies to dead letter queue @mkorszun. | ||
- Default `routing_key` on publish | ||
|
||
## [0.1.4] - 2018-02-06 | ||
### Added | ||
- Possibility to specify queue ttl in consumer config @mkorszun. | ||
|
||
## [0.1.3] - 2018-01-31 | ||
### Added | ||
- Processor behaviour @mkorszun. | ||
### Removed | ||
- Unused test helper functions @mkorszun. | ||
|
||
[0.1.6]: https://github.com/meltwater/gen_amqp/compare/v0.1.5...v0.1.6 | ||
[0.1.5]: https://github.com/meltwater/gen_amqp/compare/v0.1.4...v0.1.5 | ||
[0.1.4]: https://github.com/meltwater/gen_amqp/compare/v0.1.3...v0.1.4 | ||
[0.1.3]: https://github.com/meltwater/gen_amqp/compare/v0.1.2...v0.1.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
[![Build Status](https://travis-ci.com/meltwater/gen_amqp.svg?token=JscQvnQYQz7Pr7TwvyZh&branch=master)](https://travis-ci.com/meltwater/gen_amqp) | ||
[![Build Status](https://travis-ci.org/meltwater/gen_rmq.svg?branch=master)](https://travis-ci.org/meltwater/gen_rmq) | ||
|
||
# GenAMQP | ||
# GenRMQ | ||
|
||
GenAMQP is a set of [behaviours](https://hexdocs.pm/elixir/behaviours.html) meant to be used to create RabbitMQ consumers and publishers. | ||
GenRMQ is a set of [behaviours](https://hexdocs.pm/elixir/behaviours.html) meant to be used to create RabbitMQ consumers and publishers. | ||
Internally it is using [AMQP](https://github.com/pma/amqp) elixir RabbitMQ client. The idea is to reduce boilerplate consumer / publisher | ||
code, which usually includes: | ||
|
||
|
@@ -12,25 +12,25 @@ code, which usually includes: | |
|
||
The project currently provides the following functionality: | ||
|
||
- `GenAMQP.Consumer` - a behaviour for implementing RabbitMQ consumers | ||
- `GenAMQP.Publisher` - a behaviour for implementing RabbitMQ publishers | ||
- `GenAMQP.Processor` - a behaviour for implementing RabbitMQ message processors | ||
- `GenAMQP.RabbitCase` - test utilities for RabbitMQ ([example usage](test/gen_amqp_publisher_test.exs)) | ||
- `GenRMQ.Consumer` - a behaviour for implementing RabbitMQ consumers | ||
- `GenRMQ.Publisher` - a behaviour for implementing RabbitMQ publishers | ||
- `GenRMQ.Processor` - a behaviour for implementing RabbitMQ message processors | ||
- `GenRMQ.RabbitCase` - test utilities for RabbitMQ ([example usage](test/gen_rmq_publisher_test.exs)) | ||
|
||
## Examples | ||
|
||
More thorough examples for using `GenAMQP.Consumer` and `GenAMQP.Publisher` can be found in the [examples](examples) directory. | ||
More thorough examples for using `GenRMQ.Consumer` and `GenRMQ.Publisher` can be found in the [examples](examples) directory. | ||
|
||
### Consumer | ||
|
||
~~~elixir | ||
defmodule Consumer do | ||
@behaviour GenAMQP.Consumer | ||
@behaviour GenRMQ.Consumer | ||
|
||
def init() do | ||
[ | ||
queue: "gen_amqp_in_queue", | ||
exchange: "gen_amqp_exchange", | ||
queue: "gen_rmq_in_queue", | ||
exchange: "gen_rmq_exchange", | ||
routing_key: "#", | ||
prefetch_count: "10", | ||
uri: "amqp://guest:guest@localhost:5672", | ||
|
@@ -49,48 +49,48 @@ end | |
~~~ | ||
|
||
~~~elixir | ||
GenAMQP.Consumer.start_link(Consumer, name: Consumer) | ||
GenRMQ.Consumer.start_link(Consumer, name: Consumer) | ||
~~~ | ||
|
||
This will result in: | ||
* durable `gen_amqp_exchange.deadletter` exchange created or redeclared | ||
* durable `gen_amqp_in_queue_error` queue created or redeclared. It will be bound to `gen_amqp_exchange.deadletter` | ||
* durable `gen_amqp_exchange` exchange created or redeclared | ||
* durable `gen_amqp_in_queue` queue created or redeclared. It will be bound to `gen_amqp_exchange` | ||
exchange and has a deadletter exchange set to `gen_amqp_exchange.deadletter` | ||
* on failed rabbitmq connection it will wait for a bit and then reconnect | ||
* durable `gen_rmq_exchange.deadletter` exchange created or redeclared | ||
* durable `gen_rmq_in_queue_error` queue created or redeclared. It will be bound to `gen_rmq_exchange.deadletter` | ||
* durable `gen_rmq_exchange` exchange created or redeclared | ||
* durable `gen_rmq_in_queue` queue created or redeclared. It will be bound to `gen_rmq_exchange` | ||
exchange and has a deadletter exchange set to `gen_rmq_exchange.deadletter` | ||
* every `handle_message` callback will executed in separate process. This can be disabled by setting `concurrency: false` in `init` callback | ||
* on failed rabbitmq connection it will wait for a bit and then reconnect | ||
|
||
For all available options please check [consumer documentation](lib/consumer.ex). | ||
|
||
### Publisher | ||
|
||
~~~elixir | ||
defmodule Publisher do | ||
@behaviour GenAMQP.Publisher | ||
@behaviour GenRMQ.Publisher | ||
|
||
def init() do | ||
[ | ||
exchange: "gen_amqp_exchange", | ||
exchange: "gen_rmq_exchange", | ||
uri: "amqp://guest:guest@localhost:5672" | ||
] | ||
end | ||
end | ||
~~~ | ||
|
||
~~~elixir | ||
GenAMQP.Publisher.start_link(Publisher, name: Publisher) | ||
GenAMQP.Publisher.publish(Publisher, Poison.encode!(%{msg: "msg"})) | ||
GenRMQ.Publisher.start_link(Publisher, name: Publisher) | ||
GenRMQ.Publisher.publish(Publisher, Poison.encode!(%{msg: "msg"})) | ||
~~~ | ||
|
||
## Installation | ||
~~~elixir | ||
def deps do | ||
[ | ||
{ | ||
:gen_amqp, | ||
git: "[email protected]:meltwater/gen_amqp.git", | ||
tag: "v0.1.6" | ||
:gen_rmq, | ||
git: "[email protected]:meltwater/gen_rmq.git", | ||
tag: "v0.1.7" | ||
} | ||
] | ||
end | ||
|
@@ -104,7 +104,7 @@ $ make test | |
|
||
## How to contribute | ||
We happily accept contributions in the form of [Github PRs](https://help.github.com/articles/about-pull-requests/) | ||
or in the form of bug reports, comments/suggestions or usage questions by creating a [github issue](https://github.com/meltwater/gen_amqp/issues). | ||
or in the form of bug reports, comments/suggestions or usage questions by creating a [github issue](https://github.com/meltwater/gen_rmq/issues). | ||
|
||
## Notes on project maturity | ||
This library was developed as a Meltwater internal project starting in January 2018. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
defmodule GenAMQP.Processor do | ||
defmodule GenRMQ.Processor do | ||
@moduledoc """ | ||
Defines functions to implement by any AMQP processor | ||
""" | ||
@callback process(message :: GenAMQP.Message.t()) :: :ok | {:error, Any.t()} | ||
@callback process(message :: GenRMQ.Message.t()) :: :ok | {:error, Any.t()} | ||
end |
Oops, something went wrong.