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

Make it possible to specify non-durable exchanges #262

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lukyanov
Copy link

Description

Currently it is not possible to declare exchanges as non-durable (durable: false). This PR adds an option to do this.
Non-durable exchanges (and queues for the same matter) is quite useful in development when restarting the RabbitMQ server clears everything.

Copy link
Collaborator

@vorce vorce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the contribution @lukyanov

Got an idea on how to make it easier to use all of amqp's options

end

def declare_exchange(chan, {:fanout, exchange}) do
Exchange.fanout(chan, exchange, durable: true)
def declare_exchange(chan, {:direct, exchange, durable}) do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we change the API for declare_exchange (in a backwards compatible way) so we can use all options supported by amqp. Maybe something like:

def declare_exchange(chan, exchange, type \\ :topic, options \\ [durable: true])

def declare_exchange(_chan, :default, _type, _opts), do: :ok

# For backwards compatibility
def declare_exchange(chan, {type, exchange}, _type, _opts) do
  declare_exchange(chan, exchange, type, durable: true)
end

def declare_exchange(chan, exchange, type, options) do
  Exchange.declare(chan, exchange, type, options)
end

what do you think about it @mkorszun @lukyanov ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants