Sha256: e64000bdaff175aa7a5a92e10b32fc880db65d57935afd585b5e3c1009a1a916
Contents?: true
Size: 1.05 KB
Versions: 3
Compression:
Stored size: 1.05 KB
Contents
# # Example: q_to_files: Copy all messages in a queue to separate files in a directory # require 'find' require 'yaml' require 'wmq' require 'fileutils' # Call program passing environment name as first parameter # The environment corresponds to an entry in the config file env = ARGV[0] || raise("Command line argument 'environment' is required") config = YAML::load_file('q_to_files.cfg')[env] # Create supplied path if it does not exist path = config['target_directory'] FileUtils.mkdir_p(path) message = WMQ::Message.new message.descriptor = config['descriptor'] || {} tstart = Time.now counter = 0 WMQ::QueueManager.connect(config['qmgr_options']) do |qmgr| qmgr.open_queue(config['input_queue']) do |queue| queue.each do |message| counter = counter + 1 File.open(File.join(path, "message_%03d" % counter), 'w') { |file| file.write(message.data) } end end end duration = Time.now - tstart printf "Processed #{counter} messages in %.3f seconds. Average: %.3f messages/second\n", duration, counter/duration
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
ferocia-rubywmq-2.1.1 | examples/q_to_files.rb |
rubywmq-2.1.1 | examples/q_to_files.rb |
rubywmq-2.1.0 | examples/q_to_files.rb |