Skip to content

Instantly share code, notes, and snippets.

@equinox79
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save equinox79/9131669 to your computer and use it in GitHub Desktop.
Save equinox79/9131669 to your computer and use it in GitHub Desktop.
def run_periodic
until @finished
begin
sleep @receive_interval
@queue.receive_message do |message|
record = {}
record[:body] = message.body.to_s
record[:handle] = message.handle.to_s
record[:id] = message.id.to_s
record[:md5] = message.md5.to_s
record[:url] = message.queue.url.to_s
record[:sender_id] = message.sender_id.to_s
//Engine.emit(@tag, Time.now, record) // これだとこける
Engine.emit(@tag, Time.now.to_i, record) // to_i をつけると動く
end
rescue
$log.error "failed to emit or receive", :error => $!.to_s, :error_class => $!.class.to_s
$log.warn_backtrace $!.backtrace
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment