lolitra 0.1.0c → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,6 @@ require 'log4r'
3
3
  require 'amqp'
4
4
  require 'amqp/utilities/event_loop_helper'
5
5
  require 'json'
6
- require 'fiber'
7
6
 
8
7
  module Lolitra
9
8
  include Log4r
@@ -201,10 +200,7 @@ module Lolitra
201
200
  end
202
201
 
203
202
  def initialize(hash={})
204
- hash.each { |key, value|
205
- method = "#{MessageHandler::Helpers.underscore(key)}="
206
- self.send(method, value) if self.respond_to?(method)
207
- }
203
+ hash.each { |key, value| self.send("#{MessageHandler::Helpers.underscore(key)}=", value) }
208
204
  end
209
205
 
210
206
  def to_hash
@@ -273,32 +269,11 @@ module Lolitra
273
269
  def create_queue(message_class, handler_class, options, queue_name)
274
270
  EM.next_tick do
275
271
  channel = AMQP::Channel.new(self.connection)
276
- channel.prefetch(1).queue(queue_name, options).bind(self.exchange, :routing_key => message_class.message_key).subscribe(:ack => true) do |info, payload|
277
- Fiber.new do
278
- current_fiber = Fiber.current
279
- for i in (0..5)
280
- begin
281
- Lolitra::logger.debug("Message recived: #{info.routing_key}")
282
- Lolitra::logger.debug("#{payload}")
283
- message_class_tmp = handler_class.handlers[info.routing_key][0]
284
- handler_class.handle(message_class_tmp.unmarshall(payload))
285
- info.ack
286
- Lolitra::logger.debug("Message processed")
287
- break
288
- rescue => e
289
- Lolitra::logger.error("Try #{i}: #{e.message}")
290
- if (i!=5)
291
- EventMachine.add_timer(5) do
292
- current_fiber.resume
293
- end
294
- Fiber.yield
295
- else
296
- Lolitra::logger.error(e.backtrace.join("\n\t"))
297
- info.reject(:requeue => false)
298
- end
299
- end
300
- end
301
- end.resume
272
+ channel.prefetch(1).queue(queue_name, options).bind(self.exchange, :routing_key => message_class.message_key).subscribe do |info, payload|
273
+ Lolitra::logger.debug("Message recived: #{info.routing_key}")
274
+ Lolitra::logger.debug("#{payload}")
275
+ message_class_tmp = handler_class.handlers[info.routing_key][0]
276
+ handler_class.handle(message_class_tmp.unmarshall(payload))
302
277
  end
303
278
  end
304
279
  end
@@ -1,3 +1,3 @@
1
1
  module Lolitra
2
- VERSION = "0.1.0c"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lolitra
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: true
4
+ prerelease: false
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0c
9
- version: 0.1.0c
8
+ - 0
9
+ version: 0.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Hugo Freire
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2014-06-17 00:00:00 +02:00
17
+ date: 2012-12-08 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -124,13 +124,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
124
  required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  none: false
126
126
  requirements:
127
- - - ">"
127
+ - - ">="
128
128
  - !ruby/object:Gem::Version
129
129
  segments:
130
- - 1
131
- - 3
132
- - 1
133
- version: 1.3.1
130
+ - 0
131
+ version: "0"
134
132
  requirements: []
135
133
 
136
134
  rubyforge_project: