lib/hornetq/client/server_pattern.rb in jruby-hornetq-0.4.0 vs lib/hornetq/client/server_pattern.rb in jruby-hornetq-0.5.0.alpha

- old
+ new

@@ -1,23 +1,23 @@ module HornetQ::Client - # Create a Server following the ServerPattern for receiving requests and + # Create a Server following the ServerPattern for receiving requests and # replying to arbitrary queues # Create an instance of this class per thread class ServerPattern def initialize(session, request_queue, timeout) @session = session @consumer = session.create_consumer(request_queue) @producer = session.create_producer @timeout = timeout end - + def run(&block) while request_message = @consumer.receive(@timeout) # Block should return a message reply object, pass in request # TODO: ensure.. reply_message = block.call(request_message) - + # Send a reply? reply(request_message, reply_message) if request_message.request? request_message.acknowledge end end @@ -40,10 +40,10 @@ @producer.send(request_message.reply_to_address, reply_message) #puts "Sent reply to #{reply_to.to_s}: #{reply_message.inspect}" end request_message.acknowledge end - + # Close out resources def close @consumer.close if @consumer @producer.close if @producer end \ No newline at end of file