lib/rack/amqp/client/manager.rb in rack-amqp-client-0.0.2 vs lib/rack/amqp/client/manager.rb in rack-amqp-client-0.0.3
- old
+ new
@@ -22,17 +22,21 @@
'Content-Length' => body.length
}.merge(options[:headers])
request = Request.new((@correlation_id += 1).to_s, http_method, uri, body, headers)
@mutex.synchronize { @incomplete_requests << request }
+
callback_queue = create_callback_queue
request.callback_queue = callback_queue
amqp_channel.direct('').publish(request.payload, request.publishing_options)
- response = request.reply_wait(timeout)
- response
+ if options[:async]
+ NullResponse.new
+ else
+ request.reply_wait(timeout)
+ end
end
private
def create_callback_queue
@@ -49,10 +53,10 @@
end
request.callback(di, meta, payload)
end
# bind to an exchange, maybe later
queue
- end
+ end
end
def connect!(broker_options)
self.amqp_client = Bunny.new(broker_options)
amqp_client.start