Sha256: a6c7ee0b8c806b3aee47a330d762b6cc8cff19171354aad4ef21622fb3745fc5
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
require 'timeout' require 'yaml' module ModernTimes module JMSRequestor class RequestHandle def initialize(requestor, message, start, timeout, &reconstruct_block) @requestor = requestor @reply_queue = requestor.reply_queue @message = message @start = start @timeout = timeout @reconstruct_block = reconstruct_block end def read_response response = nil opts = { :destination => @reply_queue, :selector => "JMSCorrelationID = '#{@message.jms_message_id}'" } #opts = { :destination => @reply_queue } #opts = {:queue_name => 'foobarzulu'} ModernTimes::JMS::Connection.session_pool.consumer(opts) do |session, consumer| leftover_timeout = ((@start + @timeout - Time.now) * 1000).to_i if leftover_timeout > 100 response = consumer.receive(leftover_timeout) else #response = consumer.receive_no_wait response = consumer.receive(100) end end raise Timeout::Error, "Timeout waiting for for response from message #{@message.jms_message_id} on queue #{@reply_queue}" unless response if error_yaml = response['Exception'] raise ModernTimes::RemoteException.from_hash(YAML.load(error_yaml)) end response = @requestor.marshaler.unmarshal(response.data) if @reconstruct_block response = @reconstruct_block.call(response) end return response end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
modern_times-0.2.6 | lib/modern_times/jms_requestor/request_handle.rb |
modern_times-0.2.5 | lib/modern_times/jms_requestor/request_handle.rb |