Sha256: eac17dabe82c4c6b443df9bf1f1006f39b0957ec0235f50d94cdbf6bebe0d9d0
Contents?: true
Size: 1.8 KB
Versions: 7
Compression:
Stored size: 1.8 KB
Contents
################################################################################ # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ # # Example: q_to_files: Copy all messages in a queue to separate files in a directory # require 'rubygems' require 'find' require 'yaml' require 'wmq/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
7 entries across 7 versions & 2 rubygems