Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Casting value

  • Loading branch information...
commit ef8662a206128dfc228ae10b72c7a307870016a2 1 parent 7768c22
Mark Steele authored

Showing 2 changed files with 14 additions and 8 deletions. Show diff stats Hide diff stats

  1. +7 5 lib/hope.rb
  2. +7 3 lib/hope/engine.rb
12 lib/hope.rb
... ... @@ -1,18 +1,17 @@
1   -require 'json'
2   -
3 1 require "rubygems"
4 2 require 'amqp'
5   -
6 3 require 'hope/jars/esper-4.5.0.jar'
  4 +require 'hope/jars/ning.jar'
7 5 require 'hope/jars/commons-logging-1.1.1.jar'
8 6 require 'hope/jars/antlr-runtime-3.2.jar'
9 7 require 'hope/jars/cglib-nodep-2.2.jar'
10 8 require 'hope/jars/log4j-1.2.16.jar'
11   -
12 9 require "hope/version"
13 10 require "hope/pub"
14 11 require "hope/engine"
15 12 require "hope/config"
  13 +require 'json'
  14 +require 'snappy'
16 15
17 16 module Hope
18 17 include Java
@@ -34,7 +33,10 @@ def self.exchangeout
34 33 end
35 34
36 35 def self.queue
37   - @queue ||= amqp_channel.queue("", :exclusive => true, :auto_delete => true).bind(amqp_config.amqp[:exchange_input])
  36 + @queue ||= amqp_channel.queue("", :exclusive => true, :auto_delete => true).bind(amqp_config.amqp[:exchange_input],:routing_key =>'#')
38 37 end
39 38
  39 + def self.compress
  40 + @compress ||= amqp_config.amqp[:compress]
  41 + end
40 42 end
10 lib/hope/engine.rb
@@ -55,11 +55,15 @@ def initialize uri=nil, config_file=nil
55 55 @received = 0
56 56 end
57 57
58   - def handle_message(metadata, payload)
59   - payload.split("\n").each do |line|
  58 + def handle_message(metadata, payload)
  59 + if Hope.compress
  60 + payload = Snappy.inflate(payload)
  61 + end
  62 + payload.split("\n").each do |line|
60 63 @received += 1
61 64 event = JSON.parse(line)
62   - puts "[##{@received}]: #{event.inspect}"
  65 + event['value'] = event['value'].to_f
  66 + #puts "[##{@received}]: #{event.inspect}"
63 67 self.sendEvent(event, event['type'])
64 68 end
65 69 end # handle_message(metadata, payload)

0 comments on commit ef8662a

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