Skip to content

Commit

Permalink
Casting value
Browse files Browse the repository at this point in the history
  • Loading branch information
marksteele committed Jul 25, 2012
1 parent 7768c22 commit ef8662a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
12 changes: 7 additions & 5 deletions 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
Expand All @@ -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
10 changes: 7 additions & 3 deletions lib/hope/engine.rb
Expand Up @@ -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)
Expand Down

0 comments on commit ef8662a

Please sign in to comment.