Skip to content
Browse files

Casting value

  • Loading branch information...
1 parent 7768c22 commit ef8662a206128dfc228ae10b72c7a307870016a2 @marksteele committed Jul 25, 2012
Showing with 14 additions and 8 deletions.
  1. +7 −5 lib/hope.rb
  2. +7 −3 lib/hope/engine.rb
View
12 lib/hope.rb
@@ -1,18 +1,17 @@
-require 'json'
-
require "rubygems"
require 'amqp'
-
require 'hope/jars/esper-4.5.0.jar'
+require 'hope/jars/ning.jar'
require 'hope/jars/commons-logging-1.1.1.jar'
require 'hope/jars/antlr-runtime-3.2.jar'
require 'hope/jars/cglib-nodep-2.2.jar'
require 'hope/jars/log4j-1.2.16.jar'
-
require "hope/version"
require "hope/pub"
require "hope/engine"
require "hope/config"
+require 'json'
+require 'snappy'
module Hope
include Java
@@ -34,7 +33,10 @@ def self.exchangeout
end
def self.queue
- @queue ||= amqp_channel.queue("", :exclusive => true, :auto_delete => true).bind(amqp_config.amqp[:exchange_input])
+ @queue ||= amqp_channel.queue("", :exclusive => true, :auto_delete => true).bind(amqp_config.amqp[:exchange_input],:routing_key =>'#')
end
+ def self.compress
+ @compress ||= amqp_config.amqp[:compress]
+ end
end
View
10 lib/hope/engine.rb
@@ -55,11 +55,15 @@ def initialize uri=nil, config_file=nil
@received = 0
end
- def handle_message(metadata, payload)
- payload.split("\n").each do |line|
+ def handle_message(metadata, payload)
+ if Hope.compress
+ payload = Snappy.inflate(payload)
+ end
+ payload.split("\n").each do |line|
@received += 1
event = JSON.parse(line)
- puts "[##{@received}]: #{event.inspect}"
+ event['value'] = event['value'].to_f
+ #puts "[##{@received}]: #{event.inspect}"
self.sendEvent(event, event['type'])
end
end # handle_message(metadata, payload)

0 comments on commit ef8662a

Please sign in to comment.
Something went wrong with that request. Please try again.