Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
Add guide
Browse files Browse the repository at this point in the history
  • Loading branch information
mkorszun committed Oct 9, 2020
1 parent 498fe2e commit d62e8eb
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions documentation/guides/publisher/with_default_exchange.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Publisher with default exchange
===============================

> [The default exchange](https://www.rabbitmq.com/tutorials/amqp-concepts.html#exchange-default) is a direct exchange with no name (empty string) pre-declared by the broker. It has one special property that makes it very useful for simple applications: every queue that is created is automatically bound to it with a routing key which is the same as the queue name.
# Example

~~~elixir
defmodule WithDefaultExchange do
@behaviour GenRMQ.Publisher

def start_link() do
GenRMQ.Publisher.start_link(__MODULE__, name: __MODULE__)
end

def publish_message(message, routing_key) do
Logger.info("Publishing message #{inspect(message)}")
GenRMQ.Publisher.publish(__MODULE__, message, routing_key)
end

def init() do
[
exchange: :default,
connection: "amqp://guest:guest@localhost:5672"
]
end
end
~~~

0 comments on commit d62e8eb

Please sign in to comment.