Created
February 18, 2011 16:35
-
-
Save Electron-libre/833935 to your computer and use it in GitHub Desktop.
The way I did it ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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