Class: AMQP::Client::Exchange
- Inherits:
-
Object
- Object
- AMQP::Client::Exchange
- Defined in:
- lib/amqp/client/exchange.rb
Overview
High level representation of an exchange
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#bind(source, binding_key: "", arguments: {}) ⇒ Exchange
Bind to another exchange.
-
#delete ⇒ nil
Delete the exchange.
-
#initialize(client, name) ⇒ Exchange
constructor
private
Should only be initialized from the Client.
-
#publish(body, routing_key: "", **properties) ⇒ Exchange
Publish to the exchange, wait for confirm.
-
#publish_and_forget(body, routing_key: "", **properties) ⇒ Exchange
Publish to the exchange, without waiting for confirm.
-
#unbind(source, binding_key: "", arguments: {}) ⇒ Exchange
Unbind from another exchange.
Constructor Details
#initialize(client, name) ⇒ Exchange
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Should only be initialized from the Client
11 12 13 14 |
# File 'lib/amqp/client/exchange.rb', line 11 def initialize(client, name) @client = client @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/amqp/client/exchange.rb', line 7 def name @name end |
Instance Method Details
#bind(source, binding_key: "", arguments: {}) ⇒ Exchange
Bind to another exchange
43 44 45 46 47 |
# File 'lib/amqp/client/exchange.rb', line 43 def bind(source, binding_key: "", arguments: {}) source = source.name unless source.is_a?(String) @client.exchange_bind(source:, destination: @name, binding_key:, arguments:) self end |
#delete ⇒ nil
Delete the exchange
62 63 64 65 |
# File 'lib/amqp/client/exchange.rb', line 62 def delete @client.delete_exchange(@name) nil end |
#publish(body, routing_key: "", **properties) ⇒ Exchange
Publish to the exchange, wait for confirm
23 24 25 26 |
# File 'lib/amqp/client/exchange.rb', line 23 def publish(body, routing_key: "", **properties) @client.publish(body, exchange: @name, routing_key:, **properties) self end |
#publish_and_forget(body, routing_key: "", **properties) ⇒ Exchange
Publish to the exchange, without waiting for confirm
33 34 35 36 |
# File 'lib/amqp/client/exchange.rb', line 33 def publish_and_forget(body, routing_key: "", **properties) @client.publish_and_forget(body, exchange: @name, routing_key:, **properties) self end |
#unbind(source, binding_key: "", arguments: {}) ⇒ Exchange
Unbind from another exchange
54 55 56 57 58 |
# File 'lib/amqp/client/exchange.rb', line 54 def unbind(source, binding_key: "", arguments: {}) source = source.name unless source.is_a?(String) @client.exchange_unbind(source:, destination: @name, binding_key:, arguments:) self end |