Skip to content

Instantly share code, notes, and snippets.

@Electron-libre
Created February 18, 2011 16:35
Show Gist options
  • Save Electron-libre/833935 to your computer and use it in GitHub Desktop.
Save Electron-libre/833935 to your computer and use it in GitHub Desktop.
The way I did it ...
@files = ARGV
@files.each_with_index do |file, index|
pid = fork {
require 'stomp'
client = Stomp::Client.open("", "", "localhost", 61613)
def send_message(server, message, queue)
server.send("/cdr/cdr#{queue}", message, {})
end
file = File.open(file, 'r')
while !file.eof? do
offset = file.read(2).unpack('S')[0].to_i
message = file.read(offset)
send_message(client, message, index)
end
}
instance_variable_set("@pid_#{index}".to_sym, pid)
Process.waitpid(instance_variable_get("@pid_#{index}".to_sym), Process::WNOHANG)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment