lib/amqp/client/connection.rb in amqp-client-0.2.3 vs lib/amqp/client/connection.rb in amqp-client-0.3.0
- old
+ new
@@ -162,11 +162,12 @@
reply_text = buf.byteslice(14, reply_text_len).force_encoding("utf-8")
classid, methodid = buf.byteslice(14 + reply_text_len, 4).unpack("S> S>")
channel = @channels.delete(channel_id)
channel.closed!(reply_code, reply_text, classid, methodid)
when 41 # channel#close-ok
- @channels[channel_id].reply [:channel_close_ok]
+ channel = @channels.delete(channel_id)
+ channel.reply [:channel_close_ok]
else raise AMQP::Client::UnsupportedMethodFrame, class_id, method_id
end
when 40 # exchange
case method_id
when 11 # declare-ok
@@ -261,14 +262,11 @@
@channels[channel_id].reply [:basic_get_ok, delivery_tag, exchange, routing_key, message_count, redelivered]
when 72 # get-empty
@channels[channel_id].reply [:basic_get_empty]
when 80 # ack
delivery_tag, multiple = buf.unpack("@11 Q> C")
- @channels[channel_id].confirm [:ack, delivery_tag, multiple]
- when 90 # reject
- delivery_tag, requeue = buf.unpack("@11 Q> C")
- @channels[channel_id].confirm [:reject, delivery_tag, requeue == 1]
+ @channels[channel_id].confirm [:ack, delivery_tag, multiple == 1]
when 111 # recover-ok
@channels[channel_id].reply [:basic_recover_ok]
when 120 # nack
delivery_tag, multiple, requeue = buf.unpack("@11 Q> C C")
@channels[channel_id].confirm [:nack, delivery_tag, multiple == 1, requeue == 1]
@@ -332,10 +330,11 @@
when 10 # connection
raise AMQP::Client::Error, "Unexpected channel id #{channel_id} for Connection frame" if channel_id != 0
case method_id
when 10 # connection#start
- properties = CLIENT_PROPERTIES.merge({ connection_name: options[:connection_name] })
+ conn_name = options[:connection_name] || $PROGRAM_NAME
+ properties = CLIENT_PROPERTIES.merge({ connection_name: conn_name })
socket.write FrameBytes.connection_start_ok "\u0000#{user}\u0000#{password}", properties
when 30 # connection#tune
channel_max, frame_max, heartbeat = buf.unpack("@11 S> L> S>")
channel_max = [channel_max, 2048].min
frame_max = [frame_max, 131_072].min