lib/qsagi/queue.rb in qsagi-0.0.1 vs lib/qsagi/queue.rb in qsagi-0.0.2
- old
+ new
@@ -21,23 +21,25 @@
def disconnect
@client.send(:close_socket) unless @client.nil?
end
+ def length
+ @queue.status[:message_count]
+ end
+
def pop(options = {})
auto_ack = options.fetch(:auto_ack, true)
message = @queue.pop(:ack => !auto_ack)
unless message[:payload] == :queue_empty
self.class._message_class.new(message, self.class._serializer.deserialize(message[:payload]))
end
end
def push(message)
- #exchange = @client.exchange(self.class._exchange)
serialized_message = self.class._serializer.serialize(message)
- # @exchange.publish(serialized_message, :key => @queue.name, :persistent => true)
- @exchange.publish(serialized_message, :key => @queue.name, :persistent => true)
+ @exchange.publish(serialized_message, :key => @queue.name, :persistent => true, :mandatory => true)
end
def reconnect
disconnect
connect