Class Bunny::Exchange09
In: lib/bunny/exchange09.rb
Parent: Object

Exchanges are the routing and distribution hub of AMQP. All messages that Bunny sends to an AMQP broker/server @have_to pass through an exchange in order to be routed to a destination queue. The AMQP specification defines the types of exchange that you can create.

At the time of writing there are four (4) types of exchange defined:

  • @:direct@
  • @:fanout@
  • @:topic@
  • @:headers@

AMQP-compliant brokers/servers are required to provide default exchanges for the @direct@ and @fanout@ exchange types. All default exchanges are prefixed with @’amq.’@, for example:

  • @amq.direct@
  • @amq.fanout@
  • @amq.topic@
  • @amq.match@ or @amq.headers@

If you want more information about exchanges, please consult the documentation for your target broker/server or visit the "AMQP website":www.amqp.org to find the version of the specification that applies to your target broker/server.

Methods

delete   new   publish  

Attributes

client  [R] 
key  [R] 
name  [R] 
opts  [R] 
type  [R] 

Public Class methods

Public Instance methods

Requests that an exchange is deleted from broker/server. Removes reference from exchanges if successful. If an error occurs raises {Bunny::ProtocolError}.

@option opts [Boolean] :if_unused (false)

  If set to @true@, the server will only delete the exchange if it has no queue bindings. If the exchange has queue bindings the server does not delete it but raises a channel exception instead.

@option opts [Boolean] :nowait (false)

  Ignored by Bunny, always @false@.

@return [Symbol] @:delete_ok@ if successful.

Publishes a message to a specific exchange. The message will be routed to queues as defined by the exchange configuration and distributed to any active consumers when the transaction, if any, is committed.

@option opts [String] :key

  Specifies the routing key for the message. The routing key is
  used for routing messages depending on the exchange configuration.

@option opts [String] :content_type

  Specifies the content type for the message.

@option opts [Boolean] :mandatory (false)

  Tells the server how to react if the message cannot be routed to a queue.
  If set to @true@, the server will return an unroutable message
  with a Return method. If this flag is zero, the server silently drops the message.

@option opts [Boolean] :immediate (false)

  Tells the server how to react if the message cannot be routed to a queue consumer
  immediately. If set to @true@, the server will return an undeliverable message with
  a Return method. If set to @false@, the server will queue the message, but with no
  guarantee that it will ever be consumed.

@option opts [Boolean] :persistent (false)

  Tells the server whether to persist the message. If set to @true@, the message will
  be persisted to disk and not lost if the server restarts. If set to @false@, the message
  will not be persisted across server restart. Setting to @true@ incurs a performance penalty
  as there is an extra cost associated with disk access.

@return [NilClass] nil

[Validate]