Class: AMQ::Client::Channel
- Inherits:
-
Entity
- Object
- Entity
- AMQ::Client::Channel
- Defined in:
- lib/amq/client/amqp/channel.rb
Defined Under Namespace
Classes: ChannelOutOfBadError
Constant Summary
- DEFAULT_REPLY_TEXT =
"Goodbye".freeze
Constants included from StatusMixin
Instance Attribute Summary (collapse)
-
- (Object) exchanges_awaiting_declare_ok
readonly
Returns the value of attribute exchanges_awaiting_declare_ok.
-
- (Object) exchanges_awaiting_delete_ok
readonly
Returns the value of attribute exchanges_awaiting_delete_ok.
-
- (Object) id
readonly
Returns the value of attribute id.
-
- (Object) queues_awaiting_bind_ok
readonly
Returns the value of attribute queues_awaiting_bind_ok.
-
- (Object) queues_awaiting_cancel_ok
readonly
Returns the value of attribute queues_awaiting_cancel_ok.
-
- (Object) queues_awaiting_consume_ok
readonly
Returns the value of attribute queues_awaiting_consume_ok.
-
- (Object) queues_awaiting_declare_ok
readonly
Returns the value of attribute queues_awaiting_declare_ok.
-
- (Object) queues_awaiting_delete_ok
readonly
Returns the value of attribute queues_awaiting_delete_ok.
-
- (Object) queues_awaiting_purge_ok
readonly
Returns the value of attribute queues_awaiting_purge_ok.
-
- (Object) queues_awaiting_unbind_ok
readonly
Returns the value of attribute queues_awaiting_unbind_ok.
Attributes inherited from Entity
Attributes included from StatusMixin
Instance Method Summary (collapse)
- - (Object) close(reply_code = 200, reply_text = DEFAULT_REPLY_TEXT, class_id = 0, method_id = 0, &block)
-
- (Object) find_exchange(name)
register_exchange(exchange).
- - (Object) handle_close(method)
- - (Object) handle_close_ok
-
- (Object) handle_open_ok
Implementation.
-
- (Channel) initialize(client, id)
constructor
A new instance of Channel.
- - (Object) open(&block)
- - (Object) register_exchange(exchange)
- - (Object) reset_state!
Methods inherited from Entity
#error, #exec_callback, handle, handlers
Methods included from StatusMixin
#closed!, #closed?, #closing!, #closing?, #opened!, #opened?, #opening!, #opening?
Constructor Details
- (Channel) initialize(client, id)
A new instance of Channel
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/amq/client/amqp/channel.rb', line 31 def initialize(client, id) super(client) @id = id @exchanges = Hash.new reset_state! channel_max = client.connection.channel_max if channel_max != 0 && !(0..channel_max).include?(id) raise ChannelOutOfBadError.new(channel_max, id) end end |
Instance Attribute Details
- (Object) exchanges_awaiting_declare_ok (readonly)
Returns the value of attribute exchanges_awaiting_declare_ok
27 28 29 |
# File 'lib/amq/client/amqp/channel.rb', line 27 def exchanges_awaiting_declare_ok @exchanges_awaiting_declare_ok end |
- (Object) exchanges_awaiting_delete_ok (readonly)
Returns the value of attribute exchanges_awaiting_delete_ok
27 28 29 |
# File 'lib/amq/client/amqp/channel.rb', line 27 def exchanges_awaiting_delete_ok @exchanges_awaiting_delete_ok end |
- (Object) id (readonly)
Returns the value of attribute id
24 25 26 |
# File 'lib/amq/client/amqp/channel.rb', line 24 def id @id end |
- (Object) queues_awaiting_bind_ok (readonly)
Returns the value of attribute queues_awaiting_bind_ok
28 29 30 |
# File 'lib/amq/client/amqp/channel.rb', line 28 def queues_awaiting_bind_ok @queues_awaiting_bind_ok end |
- (Object) queues_awaiting_cancel_ok (readonly)
Returns the value of attribute queues_awaiting_cancel_ok
28 29 30 |
# File 'lib/amq/client/amqp/channel.rb', line 28 def queues_awaiting_cancel_ok @queues_awaiting_cancel_ok end |
- (Object) queues_awaiting_consume_ok (readonly)
Returns the value of attribute queues_awaiting_consume_ok
28 29 30 |
# File 'lib/amq/client/amqp/channel.rb', line 28 def queues_awaiting_consume_ok @queues_awaiting_consume_ok end |
- (Object) queues_awaiting_declare_ok (readonly)
Returns the value of attribute queues_awaiting_declare_ok
28 29 30 |
# File 'lib/amq/client/amqp/channel.rb', line 28 def queues_awaiting_declare_ok @queues_awaiting_declare_ok end |
- (Object) queues_awaiting_delete_ok (readonly)
Returns the value of attribute queues_awaiting_delete_ok
28 29 30 |
# File 'lib/amq/client/amqp/channel.rb', line 28 def queues_awaiting_delete_ok @queues_awaiting_delete_ok end |
- (Object) queues_awaiting_purge_ok (readonly)
Returns the value of attribute queues_awaiting_purge_ok
28 29 30 |
# File 'lib/amq/client/amqp/channel.rb', line 28 def queues_awaiting_purge_ok @queues_awaiting_purge_ok end |
- (Object) queues_awaiting_unbind_ok (readonly)
Returns the value of attribute queues_awaiting_unbind_ok
28 29 30 |
# File 'lib/amq/client/amqp/channel.rb', line 28 def queues_awaiting_unbind_ok @queues_awaiting_unbind_ok end |
Instance Method Details
- (Object) close(reply_code = 200, reply_text = DEFAULT_REPLY_TEXT, class_id = 0, method_id = 0, &block)
53 54 55 56 |
# File 'lib/amq/client/amqp/channel.rb', line 53 def close(reply_code = 200, reply_text = DEFAULT_REPLY_TEXT, class_id = 0, method_id = 0, &block) @client.send Protocol::Channel::Close.encode(@id, reply_code, reply_text, class_id, method_id) self.callbacks[:close] = block end |
- (Object) find_exchange(name)
register_exchange(exchange)
65 66 67 |
# File 'lib/amq/client/amqp/channel.rb', line 65 def find_exchange(name) @exchanges[name] end |
- (Object) handle_close(method)
100 101 102 |
# File 'lib/amq/client/amqp/channel.rb', line 100 def handle_close(method) p method end |
- (Object) handle_close_ok
95 96 97 98 |
# File 'lib/amq/client/amqp/channel.rb', line 95 def handle_close_ok self.status = :closed self.exec_callback(:close) end |
- (Object) handle_open_ok
Implementation
90 91 92 93 |
# File 'lib/amq/client/amqp/channel.rb', line 90 def handle_open_ok self.status = :opened self.exec_callback(:open) end |
- (Object) open(&block)
46 47 48 49 50 51 |
# File 'lib/amq/client/amqp/channel.rb', line 46 def open(&block) @client.send Protocol::Channel::Open.encode(@id, "") @client.connection.channels[@id] = self self.status = :opening self.callbacks[:open] = block end |
- (Object) register_exchange(exchange)
59 60 61 62 63 |
# File 'lib/amq/client/amqp/channel.rb', line 59 def register_exchange(exchange) raise ArgumentError, "argument is nil!" if exchange.nil? @exchanges[exchange.name] = exchange end |
- (Object) reset_state!
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/amq/client/amqp/channel.rb', line 70 def reset_state! @queues_awaiting_declare_ok = Array.new @exchanges_awaiting_declare_ok = Array.new @queues_awaiting_delete_ok = Array.new @exchanges_awaiting_delete_ok = Array.new @queues_awaiting_purge_ok = Array.new @queues_awaiting_bind_ok = Array.new @queues_awaiting_unbind_ok = Array.new @queues_awaiting_consume_ok = Array.new @queues_awaiting_cancel_ok = Array.new end |