thrift-amqp-ruby 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/thrift/amqp/amqp_rpc_client.rb +1 -1
- data/lib/thrift/amqp/amqp_rpc_service.rb +23 -33
- data/lib/thrift/amqp/ruby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a08eb85188e4dbe1d3d589d01e1751b574b1a030
|
4
|
+
data.tar.gz: a4f2f66643307e2d79fcfc94967dd9366cd0e3b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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, :
|
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
|
-
|
110
|
+
print_log "Request to process #{@queue_name}.#{properties.headers['operation']} in #{process_timeout}sec" if log_messages
|
114
111
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
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
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
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
|
-
|
128
|
-
|
129
|
-
|
124
|
+
#rewind the buffer for reading
|
125
|
+
if out.length > 0
|
126
|
+
out.rewind
|
130
127
|
|
131
|
-
|
128
|
+
print_log "Time to process request: #{processing_time}sec Response length: #{out.length}" if log_messages
|
132
129
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
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
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2015-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|