thrift-amqp-ruby 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47b60f6d88a19c39352bd0173213c238299e01c6
4
- data.tar.gz: 96733bf92ae83b43a9da73b7a449f6c33c7e6aff
3
+ metadata.gz: a08eb85188e4dbe1d3d589d01e1751b574b1a030
4
+ data.tar.gz: a4f2f66643307e2d79fcfc94967dd9366cd0e3b2
5
5
  SHA512:
6
- metadata.gz: 6b76ebc19ab8fe491c572f6d95fca291ea1f7592474c596ae7e3dcbf58b74b378ff766a0a7d9fa8fb8eace1fe6389a46ce75b8bf47b761a6ce191475b5241742
7
- data.tar.gz: 651f7479ecc599907ded1610d25c8087281552ab747cb72601a637128c88f037b861eb83876e55d334e8fd582fe194869fc1a2ea4f2855bbd816f7a59ec84536
6
+ metadata.gz: e1025b4a46fa9cdd74dfe4eb0debe4f5551d053aa0703b4d4ce45423010f006c65894f7f1f9e5016970d3b3534178bc16f88ad3b8d463a20f31dfa10f1e2c760
7
+ data.tar.gz: 18809b8df1d68812b700c5076c1584eafd8bce4cad2ba21715563027eb4edd4381231c6fd42ab10343112c7f8dec0a13b029ea2dd4e8d38e81b1078a2c33edda
@@ -60,7 +60,7 @@ module Thrift
60
60
  @exchange = opts[:exchange] || nil
61
61
 
62
62
  @ch = @conn.create_channel
63
- @service_exchange = @exchange.nil? ? @ch.default_exchange : @ch.direct(@exchange, :durable => true)
63
+ @service_exchange = @exchange.nil? ? @ch.default_exchange : @ch.direct(@exchange, no_declare: true)
64
64
  @service_response_exchange = @ch.default_exchange
65
65
  @reply_queue = @ch.queue("", :exclusive => true)
66
66
  @is_opened = true
@@ -92,7 +92,6 @@ module Thrift
92
92
  end
93
93
 
94
94
  @request_queue.subscribe(:block => true) do |delivery_info, properties, payload|
95
-
96
95
  if log_messages
97
96
  Thread.current["correlation_id"] = properties.correlation_id
98
97
  print_log "---- Message received ----"
@@ -104,49 +103,40 @@ module Thrift
104
103
  response_channel = @conn.create_channel
105
104
  response_exchange = response_channel.default_exchange
106
105
 
107
- response_required = properties.headers.has_key?('response_required') ? properties.headers['response_required'] : true
106
+ response_required = (properties.headers && properties.headers.has_key?('response_required')) ? properties.headers['response_required'] : true
108
107
  process_timeout = response_timeout.to_i > properties.expiration.to_i ? response_timeout.to_i : properties.expiration.to_i
109
108
 
110
- #Binary content will imply thrift based message payload
111
- if properties.content_type == 'application/octet-stream'
112
109
 
113
- print_log "Request to process #{@queue_name}.#{properties.headers['operation']} in #{process_timeout}sec" if log_messages
110
+ print_log "Request to process #{@queue_name}.#{properties.headers['operation']} in #{process_timeout}sec" if log_messages
114
111
 
115
- input = StringIO.new payload
116
- out = StringIO.new
117
- transport = IOStreamTransport.new input, out
118
- protocol = @protocol_factory.new.get_protocol transport
112
+ input = StringIO.new payload
113
+ out = StringIO.new
114
+ transport = IOStreamTransport.new input, out
115
+ protocol = @protocol_factory.new.get_protocol transport
119
116
 
120
- begin
121
- start_time = Time.now
122
- Timeout.timeout(process_timeout, ProcessingTimeout) do
123
- @processor.process protocol, protocol
124
- end
125
- processing_time = Time.now - start_time
117
+ begin
118
+ start_time = Time.now
119
+ Timeout.timeout(process_timeout, ProcessingTimeout) do
120
+ @processor.process protocol, protocol
121
+ end
122
+ processing_time = Time.now - start_time
126
123
 
127
- #rewind the buffer for reading
128
- if out.length > 0
129
- out.rewind
124
+ #rewind the buffer for reading
125
+ if out.length > 0
126
+ out.rewind
130
127
 
131
- print_log "Time to process request: #{processing_time}sec Response length: #{out.length}" if log_messages
128
+ print_log "Time to process request: #{processing_time}sec Response length: #{out.length}" if log_messages
132
129
 
133
- if response_required
134
- response_exchange.publish(out.read(out.length),
135
- :routing_key => properties.reply_to,
136
- :correlation_id => properties.correlation_id,
137
- :content_type => 'application/octet-stream' )
138
- end
130
+ if response_required
131
+ response_exchange.publish(out.read(out.length),
132
+ :routing_key => properties.reply_to,
133
+ :correlation_id => properties.correlation_id,
134
+ :content_type => 'application/octet-stream' )
139
135
  end
140
-
141
- rescue ProcessingTimeout => ex
142
- print_log "A timeout has occurred (#{process_timeout}sec) trying to call #{@queue_name}.#{properties.headers['operation']}"
143
136
  end
144
137
 
145
- else
146
-
147
- print_log "Unable to process message content of type #{properties.content_type}. The message will be rejected"
148
- @request_channel.reject(delivery_info.delivery_tag, false)
149
-
138
+ rescue ProcessingTimeout => ex
139
+ print_log "A timeout has occurred (#{process_timeout}sec) trying to call #{@queue_name}.#{properties.headers['operation']}"
150
140
  end
151
141
 
152
142
  response_channel.close
@@ -1,7 +1,7 @@
1
1
  module Thrift
2
2
  module Amqp
3
3
  module Ruby
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.3"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thrift-amqp-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis Montagne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-27 00:00:00.000000000 Z
11
+ date: 2015-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler