Skip to content
Browse files

Get working on Ruby 1.9, Windows 32 bit, WebSphere MQ 7.5, with DevKit

  • Loading branch information...
1 parent 4c2781a commit b6d34be560aa64ba2f265057455b826b80b5d925 @reidmorrison committed Sep 18, 2012
View
4 .document
@@ -1,8 +1,4 @@
-ext/lib/wmq_const.rb
ext/wmq.c
ext/wmq_queue_manager.c
ext/wmq_message.c
ext/wmq_queue.c
-ext/lib/wmq_const_admin.rb
-ext/lib/wmq_temp.rb
-README
View
11 .gitignore
@@ -1,9 +1,12 @@
+lib/wmq/constants.rb
+lib/wmq/constants_admin.rb
ext/wmq_structs.c
-ext/Makefile
-ext/lib/wmq_const.rb
-ext/lib/wmq_const_admin.rb
ext/wmq_reason.c
+ext/Makefile
ext/*.o
ext/wmq.so
nbproject/private/*
-rubywmq*.gem
+.DS_Store
+*.gem
+.idea/*
+Gemfile.lock
View
17 .project
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>rubywmq</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.rubypeople.rdt.core.rubybuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.rubypeople.rdt.core.rubynature</nature>
- </natures>
-</projectDescription>
View
13 LICENSE
@@ -1,13 +0,0 @@
-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.
View
201 LICENSE.txt
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2006 - 2012 J. Reid Morrison
+
+ 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.
View
20 Manifest.txt
@@ -1,20 +0,0 @@
-.document
-lib/wmq.rb
-ext/lib/wmq_temp.rb
-ext/decode_rfh.h
-ext/decode_rfh.c
-ext/wmq.h
-ext/wmq.c
-ext/wmq_message.c
-ext/wmq_mq_load.c
-ext/wmq_queue.c
-ext/wmq_queue_manager.c
-ext/extconf.rb
-ext/extconf_client.rb
-ext/build.bat
-ext/build.sh
-ext/generate/generate_const.rb
-ext/generate/generate_reason.rb
-ext/generate/generate_structs.rb
-ext/generate/wmq_structs.erb
-examples/files_to_q.cfg
View
73 README
@@ -1,73 +0,0 @@
-== Description
- rubywmq - RubyWMQ is a Ruby interface into WebSphere MQ, previously called MQSeries
-
-== Synopsis
- require 'wmq'
-
- WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
- qmgr.put(:q_name=>'TEST.QUEUE', :data => 'Hello World')
- end
-
-== Building Ruby WMQ
- Building Ruby WMQ on UNIX/Linux
- -------------------------------
- The following is required to build from source code
- * A 'C' compiler
- * The WebSphere MQ Software development toolkit
-
- Extracting the source code package:
- * unzip package.zip
- * tar -xvf package.tar
-
- cd ext/wmq
- Edit the file build.sh and edit the location of WebSphere MQ (if not in /opt/mqm)
- Also edit extconf.rb and extconf_client.rb with the location of WebSphere MQ (if not in /opt/mqm)
-
- Run build.sh
-
- For any questions, or to report build errors, submit a new Support Request:
- http://rubywmq.rubyforge.org
-
- Building Ruby WMQ on Windows
- ----------------------------
- The following is required to build from source code
- * The Visual C++ 6.0 compiler
- * The WebSphere MQ Software development toolkit
-
- cd ext\wmq
- Edit the file build.bat and edit the location of WebSphere MQ
- (if not in C:\Program Files\IBM\WebSphere MQ)
- and the location of Visual C++ 6 (if not C:\Program Files\Microsoft Visual Studio\VC98)
- Also edit extconf.rb and extconf_client.rb with the location of WebSphere MQ (if not in C:\Program Files\IBM\WebSphere MQ)
-
- Run build.bat
-
-== Support
- For any questions, or to report build errors, submit a new Support Request:
- http://rubywmq.rubyforge.org
-
-== Future Plans
- Add more formatting option contants and related methods.
-
-== License
- 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.
-
-== Copyright
- (C) 2006 J. Reid Morrison. Dimension Solutions, Inc.
- All Rights Reserved
-
-== Author
- Reid Morrison
- rubywmq at gmail dot com
View
192 README.md
@@ -0,0 +1,192 @@
+## rubywmq
+
+* http://github.com/reidmorrison/rubywmq
+
+### Description
+
+RubyWMQ is a high performance native Ruby interface into WebSphere MQ.
+
+### Compatibility
+
+Ruby
+
+* RubyWMQ only works on Ruby MRI on with Ruby 1.8.7, Ruby 1.9.3, or greater
+* For JRuby, see http://github.com/reidmorrison/jruby-jms
+
+WebSphere MQ
+
+* RubyWMQ parses the header files that come with WebSphere MQ so always
+ stays up to date with the latest structures and return codes
+* RubyWMQ has been tested against WebSphere MQ 5, 6, and 7.5
+
+## Example
+
+ require 'rubygems'
+ require 'wmq'
+
+ # Connect to a local queue manager called 'TEST' and put a single message
+ # on the queue 'TEST.QUEUE'
+ WMQ::QueueManager.connect(:q_mgr_name=>'TEST') do |qmgr|
+ qmgr.put(:q_name=>'TEST.QUEUE', :data => 'Hello World')
+ end
+
+## Installation
+
+### Installing on UNIX/Linux
+
+* Install a 'C' Compiler, GNU C++ is recommended
+* Install Ruby using the package manager for your platform
+* Also install RubyGems and ruby-dev or ruby-sdk packages if not already installed
+* Install the [WebSphere MQ Client and/or Server](http://www.ibm.com/developerworks/downloads/ws/wmq/)
+
+ Note: Install the Development Toolkit (SDK) and Client
+
+* Install RubyWMQ Gem
+
+ gem install rubywmq
+
+If no errors appear RubyWMQ is ready for use
+
+#### Installation Errors
+
+Use this command to find the directory in which the gem was installed
+
+ gem which rubywmq
+
+When WebSphere MQ is not installed in the default location, call the build
+command directly and supply the location explicitly:
+
+ ruby extconf.rb --with-mqm-include=/opt/mqm/inc --with-mqm-lib=/opt/mqm/lib
+ make
+
+For platforms such as AIX and HP-UX it may be necessary to statically link in
+the WebSphere MQ client library when the auto-detection build above does not work.
+This build option is a last resort since it will only work using a client connection
+
+ ruby extconf_client.rb --with-mqm-include=/opt/mqm/inc --with-mqm-lib=/opt/mqm/lib
+ make
+
+### Installing on Windows
+
+#### Install Ruby and DevKit
+
+* Download and install the Ruby installer from http://rubyinstaller.org/downloads/
+
+ Select "Add Ruby executables to your PATH" during the installation
+
+* Download and install the Development Kit from the same site
+
+ Extract files into c:\DevKit
+
+* Open a command prompt and run the commands below:
+
+ cd c:\DevKit
+ ruby dk.rb init
+
+If you experience any difficulties, see https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
+
+#### Install WebSphereMQ
+
+* Install the [WebSphere MQ Client and/or Server](http://www.ibm.com/developerworks/downloads/ws/wmq/)
+
+ Note: Install the Development Toolkit (SDK) and Client
+
+#### Install the RubyWMQ Gem
+
+ call "c:\DevKit\devkitvars.bat"
+  gem install rubywmq --platform=ruby
+
+#### Installation Errors
+
+Use this command to find the directory in which the gems are installed
+
+ gem env
+
+The path to the rubywmq gem will be something like
+
+ C:\Ruby193\lib\ruby\gems\1.9.1\gems\rubywmq-2.0.0\ext
+
+When WebSphere MQ is not installed in the default location, change to the directory
+above and call the build command directly while supplying the location explicitly:
+
+ call "C:\DevKit\devkitvars.bat"
+ ruby extconf.rb --with-mqm-include="C:\Program Files\IBM\WebSphere MQ\Tools\c\include"
+ nmake
+
+## Verifying the build
+
+### Verifying a local WebSphere MQ Server installation
+
+* Create a local Queue Manager called TEST. Select the option to create the server
+side channels.
+* Create a local queue called TEST.QUEUE
+* Run the following Ruby Code in an irb session:
+
+ require 'rubygems'
+ require 'wmq'
+ WMQ::QueueManager.connect(:q_mgr_name=>'TEST') do |qmgr|
+ qmgr.put(:q_name=>'TEST.QUEUE', :data => 'Hello World')
+ end
+
+## Rails Installation
+
+After following the steps above to compile the source code, add the following
+line to Gemfile
+
+ gem 'rubywmq', :require => 'wmq'
+
+## Architecture
+
+RubyWMQ uses an automatic detection library to figure out whether a Client or Server
+is installed locally. This prevents issues with having to statically link with
+both the client and server libraries and then having to select the "correct"
+one on startup.
+
+Additionally, this approach allows RubyWMQ to be simultaneously connect to both a local
+Queue Manager via server bindings and to a remote Queue Manager using Client bindings.
+
+Instead of hard coding all the MQ C Structures and return codes into RubyWMQ, it
+parses the MQ 'C' header files at compile time to take advantage of all the latest
+features in new releases.
+
+## Contributing
+
+Once you've made your great commits:
+
+1. [Fork](http://help.github.com/forking/) rubywmq
+2. Create a topic branch - `git checkout -b my_branch`
+3. Push to your branch - `git push origin my_branch`
+4. Create an [Issue](http://github.com/reidmorrison/rubywmq/issues) with a link to your branch
+5. That's it!
+
+## Meta
+
+* Code: `git clone git://github.com/reidmorrison/rubywmq.git`
+* Home: <http://github.com/reidmorrison/rubywmq>
+* Bugs: <http://github.com/reidmorrison/rubywmq/issues>
+* Gems: <http://rubygems.org/gems/rubywmq>
+
+This project uses [Semantic Versioning](http://semver.org/).
+
+## Author
+
+Reid Morrison :: reidmo@gmail.com :: @reidmorrison
+
+Special thanks to Edwin Fine for the RFH parsing code and for introducing me to
+the wonderful world of Ruby
+
+## License
+
+Copyright 2006 - 2012 J. Reid Morrison
+
+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.
View
87 Rakefile
@@ -0,0 +1,87 @@
+lib = File.expand_path('../lib/', __FILE__)
+$:.unshift lib unless $:.include?(lib)
+
+require 'rubygems'
+require 'rake/clean'
+require 'rake/testtask'
+require 'date'
+require 'wmq/version'
+
+desc "Build Ruby Source gem"
+task :gem do |t|
+ excludes = [
+ 'lib/wmq/constants.rb',
+ 'lib/wmq/constants_admin.rb',
+ 'ext/wmq_structs.c',
+ 'ext/wmq_reason.c',
+ 'ext/Makefile',
+ 'ext/*.o',
+ 'ext/wmq.so',
+ '*.gem',
+ 'nbproject'
+ ]
+
+ gemspec = Gem::Specification.new do |spec|
+ spec.name = 'rubywmq'
+ spec.version = WMQ::VERSION
+ spec.platform = Gem::Platform::RUBY
+ spec.authors = ['Reid Morrison', 'Edwin Fine']
+ spec.email = ['reidmo@gmail.com']
+ spec.homepage = 'https://github.com/reidmorrison/rubywmq'
+ spec.date = Date.today.to_s
+ spec.summary = "Native Ruby interface into WebSphere MQ"
+ spec.description = "RubyWMQ is a high performance native Ruby interface into WebSphere MQ."
+ spec.files = FileList["./**/*"].exclude(*excludes).map{|f| f.sub(/^\.\//, '')} +
+ ['.document']
+ spec.extensions << 'ext/extconf.rb'
+ spec.rubyforge_project = 'rubywmq'
+ spec.test_file = 'tests/test.rb'
+ spec.has_rdoc = true
+ spec.required_ruby_version = '>= 1.8.4'
+ spec.add_development_dependency 'shoulda'
+ spec.requirements << 'WebSphere MQ v5.3, v6 or v7 Client or Server with Development Kit'
+ end
+ Gem::Builder.new(gemspec).build
+end
+
+desc "Build a binary gem including pre-compiled binary files for re-distribution"
+task :binary do |t|
+ # Move compiled files into locations for repackaging as a binary gem
+ FileUtils.mkdir_p('lib/wmq')
+ Dir['ext/lib/*.rb'].each{|file| FileUtils.copy(file, File.join('lib/wmq', File.basename(file)))}
+ FileUtils.copy('ext/wmq.so', 'lib/wmq/wmq.so')
+
+ gemspec = Gem::Specification.new do |spec|
+ spec.name = 'rubywmq'
+ spec.version = WMQ::VERSION
+ spec.platform = Gem::Platform::CURRENT
+ spec.authors = ['Reid Morrison', 'Edwin Fine']
+ spec.email = ['reidmo@gmail.com']
+ spec.homepage = 'https://github.com/reidmorrison/rubywmq'
+ spec.date = Date.today.to_s
+ spec.summary = "Native Ruby interface into WebSphere MQ"
+ spec.description = "RubyWMQ is a high performance native Ruby interface into WebSphere MQ."
+ spec.files = Dir['examples/**/*.rb'] +
+ Dir['examples/**/*.cfg'] +
+ Dir['doc/**/*.*'] +
+ Dir['lib/**/*.rb'] +
+ ['lib/wmq/wmq.so', 'tests/test.rb', 'README', 'LICENSE']
+ spec.rubyforge_project = 'rubywmq'
+ spec.test_file = 'tests/test.rb'
+ spec.has_rdoc = false
+ spec.required_ruby_version = '>= 1.8.4'
+ spec.add_development_dependency 'shoulda'
+ spec.requirements << 'WebSphere MQ v5.3, v6 or v7 Client or Server with Development Kit'
+ end
+ Gem::Builder.new(gemspec).build
+end
+
+desc "Run Test Suite"
+task :test do
+ Rake::TestTask.new(:functional) do |t|
+ t.test_files = FileList['test/*_test.rb']
+ t.verbose = true
+ end
+
+ Rake::Task['functional'].invoke
+end
View
3 ext/build.bat
@@ -1,3 +0,0 @@
-call "C:\Program Files\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT"
-ruby extconf.rb --with-mqm-include="C:\Program Files\IBM\WebSphere MQ\Tools\c\include"
-nmake
View
6 ext/build.sh
@@ -1,6 +0,0 @@
-ruby extconf.rb --with-mqm-include=/opt/mqm/inc --with-mqm-lib=/opt/mqm/lib
-make
-# Uncomment the following lines for platforms other than Solaris, Windows and Linux
-#ruby extconf_client.rb --with-mqm-include=/opt/mqm/inc --with-mqm-lib=/opt/mqm/lib
-#make
-
View
28 ext/extconf.rb
@@ -1,27 +1,11 @@
-################################################################################
-# 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.
-################################################################################
-
require 'mkmf'
-require 'generate/generate_reason'
-require 'generate/generate_const'
-require 'generate/generate_structs'
+require File.join(File.dirname(__FILE__), 'generate', 'generate_reason')
+require File.join(File.dirname(__FILE__), 'generate', 'generate_const')
+require File.join(File.dirname(__FILE__), 'generate', 'generate_structs')
include_path = ''
-if RUBY_PLATFORM =~ /mswin32/
- include_path = 'C:\Program Files\IBM\WebSphere MQ\Tools\c\include'
+if RUBY_PLATFORM =~ /win|mingw/i
+ include_path = 'C:\Program Files\IBM\WebSphere MQ\tools\c\include'
dir_config('mqm', include_path, '.')
else
include_path = '/opt/mqm/inc'
@@ -37,7 +21,7 @@
# Generate Source Files
GenerateReason.generate(include_path+'/')
-GenerateConst.generate(include_path+'/', 'lib')
+GenerateConst.generate(include_path+'/', File.dirname(__FILE__) + '/../lib/wmq')
GenerateStructs.new(include_path+'/', 'generate').generate
# Generate Makefile
View
22 ext/extconf_client.rb
@@ -1,21 +1,5 @@
-################################################################################
-# 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.
-################################################################################
-
-#
-# NOTE: Do NOT use this file unless the platform being requested is not supported
+# NOTE: Do NOT use this file unless the platform being used is not supported
# directly by Ruby WMQ. Ruby WMQ already supports automatic dynamic loading on
# Windows, Solaris and Linux
#
@@ -29,12 +13,12 @@
include_path = '/opt/mqm/inc'
dir_config('mqm', include_path, '/opt/mqm/lib')
have_library('mqic')
-
+
# Generate Source Files # Could check if not already present
GenerateReason.generate(include_path+'/')
GenerateConst.generate(include_path+'/', '../../lib/wmq')
GenerateStructs.new(include_path+'/', '../../generate').generate
-
+
have_header('cmqc.h')
create_makefile('wmq_client')
end
View
59 ext/generate/generate_const.rb
@@ -1,6 +1,7 @@
+# Extract Constants from the WebSphere MQ header files
class GenerateConst
-
- #Extract Constants from Header files
+
+ # Extract Constants from Header files
def GenerateConst.extract_const(filename, const_prefix, start_exp=nil, end_exp=nil)
@constants = []
active = if start_exp then false else true end # Sure there is a better way
@@ -23,8 +24,8 @@ def GenerateConst.extract_const(filename, const_prefix, start_exp=nil, end_exp=n
end
@constants
end
-
- #Extract MQ Constants from Header files
+
+ # Extract MQ Constants from Header files
def GenerateConst.rb_const(filename, const_prefix, exclude_exp=nil)
str = ''
GenerateConst.extract_const(filename, const_prefix).each do |item|
@@ -42,7 +43,7 @@ def GenerateConst.rb_const(filename, const_prefix, exclude_exp=nil)
end
str
end
-
+
def GenerateConst.config(filename, prefix)
str = "# WMQ::QueueManager execute commands\n"
str << "execute_commands:\n"
@@ -55,24 +56,10 @@ def GenerateConst.config(filename, prefix)
end
str
end
-
+
def GenerateConst.wmq_const(path)
str = <<END_OF_STRING
################################################################################
-# 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.
-################################################################################
#
# WARNING: DO NOT MODIFY THIS FILE
#
@@ -81,18 +68,18 @@ def GenerateConst.wmq_const(path)
################################################################################
module WMQ
END_OF_STRING
- [ ['Connect Options','cmqc.h','MQCNO_',/(VERSION)|(CONN_TAG)|(HANDLE_SHARE)/],
+ [ ['Connect Options','cmqc.h','MQCNO_',/(VERSION)|(CONN_TAG)|(HANDLE_SHARE)|(_LENGTH)/],
['Open Options', 'cmqc.h','MQOO_' ],
['Close Options', 'cmqc.h','MQCO_'],
['Match Options', 'cmqc.h','MQMO_'],
['Message Format Options', 'cmqc.h','MQFMT_',/(_ARRAY)/],
- ['Get Message Options', 'cmqc.h','MQGMO_',/(VERSION)/],
+ ['Get Message Options', 'cmqc.h','MQGMO_',/(VERSION)|(LENGTH)|(MQGMO_BROWSE_HANDLE)|(MQGMO_BROWSE_CO_OP)/],
['Transport Types', 'cmqxc.h','MQXPT_'] ,
['Report Options', 'cmqc.h', 'MQRO_'],
['Message Types', 'cmqc.h', 'MQMT_'],
['Expiry', 'cmqc.h', 'MQEI_'],
['Feedback Values', 'cmqc.h', 'MQFB_'],
- ['Encoding Values', 'cmqc.h', 'MQENC_'],
+ ['Encoding Values', 'cmqc.h', 'MQENC_',/(MQENC_NORMAL)|(MQENC_REVERSED)|(MQENC_S390)|(MQENC_TNS)/],
['Coded Character Set Identifiers', 'cmqc.h', 'MQCCSI_'],
['Priority', 'cmqc.h', 'MQPRI_'],
['Persistence', 'cmqc.h', 'MQPER_'],
@@ -108,24 +95,10 @@ module WMQ
end
str << "end\n"
end
-
+
def GenerateConst.admin_consts(path)
str = <<END_OF_STRING
################################################################################
-# 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.
-################################################################################
#
# WARNING: DO NOT MODIFY THIS FILE
#
@@ -142,7 +115,7 @@ module WMQ
str << "\n# #{item[0]}\n"
str << GenerateConst.rb_const("#{path}/#{item[1]}", item[2], item[3])
end
- GenerateConst.extract_const(path+'cmqc.h', 'MQ', /Queue\sAttributes/, /typedef/).each do |item|
+ GenerateConst.extract_const(path+'cmqc.h', 'MQ', /Queue\s+Attributes/, /General\s+Constants/).each do |item|
str << " %-30s = #{item[1]}\n" % item[0]
end
str << "# Admin constants from cmqcfc.h\n"
@@ -151,14 +124,14 @@ module WMQ
end
str << "end\n"
end
-
+
def self.generate(path, target_path='')
- File.open(File.join(target_path,'wmq_const_admin.rb'), 'w') {|file| file.write(GenerateConst.admin_consts(path))}
+ File.open(File.join(target_path,'constants_admin.rb'), 'w') {|file| file.write(GenerateConst.admin_consts(path))}
puts 'Generated wmq_const_admin.rb'
- File.open(File.join(target_path,'wmq_const.rb'), 'w') {|file| file.write(GenerateConst.wmq_const(path))}
+ File.open(File.join(target_path,'constants.rb'), 'w') {|file| file.write(GenerateConst.wmq_const(path))}
puts 'Generated wmq_const.rb'
end
-end
+end
if $0 == __FILE__
path = ARGV[0] || raise("Mandatory parameter: 'WebSphere MQ Include path' is missing")
View
59 ext/generate/generate_reason.rb
@@ -1,6 +1,6 @@
class GenerateReason
- #Extract Error Code Constants from Header files
+ # Extract Error Code Constants from Header files
def GenerateReason.extract_const(filename, const_prefix)
@constants = []
File.open(filename) do |file|
@@ -16,8 +16,8 @@ def GenerateReason.extract_const(filename, const_prefix)
end
@constants
end
-
- #Extract Error Code Constants from Header files
+
+ # Extract Error Code Constants from Header files
# Uses lazy print to collect duplicate values
def GenerateReason.reason_case(filename, prefix)
last_rc = nil
@@ -36,8 +36,8 @@ def GenerateReason.reason_case(filename, prefix)
end
str
end
-
-# The WebSphere MQ header files have several duplicate values,
+
+# The WebSphere MQ header files have several duplicate values,
# so need to exclude duplicates.
def GenerateReason.selector_case(filename, prefix, excludes=nil, &block)
GenerateReason.extract_const(filename,prefix).each do |item|
@@ -46,24 +46,10 @@ def GenerateReason.selector_case(filename, prefix, excludes=nil, &block)
block.call item
end
end
-
+
def GenerateReason.wmq_reason(path)
str = <<END_OF_STRING
/* --------------------------------------------------------------------------
- * 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.
- * --------------------------------------------------------------------------
*
* WARNING: DO NOT MODIFY THIS FILE
*
@@ -97,9 +83,10 @@ def GenerateReason.wmq_reason(path)
[['cmqc.h', 'MQIA_'],
['cmqcfc.h', 'MQIACF_', ['MQIACF_ERROR_ID',
'MQIACF_QUIESCE']],
- ['cmqcfc.h', 'MQIACH_', ['MQIACH_CURRENT_SEQ_NUMBER',
- 'MQIACH_BYTES_RCVD',
- 'MQIACH_BUFFERS_RCVD']],
+ ['cmqcfc.h', 'MQIACH_', ['MQIACH_CURRENT_SEQ_NUMBER',
+ 'MQIACH_BYTES_RCVD',
+ 'MQIACH_BUFFERS_RCVD',
+ 'MQIACH_MSGS_RCVD']],
['cmqcfc.h', 'MQIAMO_'],
['cmqcfc.h', 'MQIAMO64_', ['MQIAMO64_AVG_Q_TIME',
'MQIAMO64_Q_TIME_AVG',
@@ -125,7 +112,7 @@ def GenerateReason.wmq_reason(path)
str_switch << " case %-30s: return ID_#{id};\n" % const[0]
str_id_init << " ID_%-25s = rb_intern(\"#{id}\");\n" % id
str << "static ID ID_#{id};\n"
- end
+ end
end
str << <<END_OF_STRING
@@ -156,8 +143,8 @@ def GenerateReason.wmq_reason(path)
[['cmqc.h', 'MQIA_'],
['cmqcfc.h', 'MQIACF_', ['MQIACF_ERROR_ID',
'MQIACF_QUIESCE']],
- ['cmqcfc.h', 'MQIACH_', ['MQIACH_CURRENT_SEQ_NUMBER',
- 'MQIACH_BYTES_RCVD',
+ ['cmqcfc.h', 'MQIACH_', ['MQIACH_CURRENT_SEQ_NUMBER',
+ 'MQIACH_BYTES_RCVD',
'MQIACH_BUFFERS_RCVD']],
['cmqcfc.h', 'MQIAMO_'],
['cmqcfc.h', 'MQIAMO64_', ['MQIAMO64_AVG_Q_TIME',
@@ -169,8 +156,8 @@ def GenerateReason.wmq_reason(path)
].each do |item|
str << " /* Consteants #{item[1]}* from #{item[0]} */\n"
GenerateReason.selector_case(path+item[0], item[1], item[2]) do |const|
- str << " if(selector_id == %-32s{ *selector = #{const[0]}; return;}\n" % "ID_#{const[0].gsub(item[1],'').downcase})"
- end
+ str << " if(selector_id == %-32s{ *selector = #{const[0]}; return;}\n" % "ID_#{const[0].gsub(item[1],'').downcase})"
+ end
end
str << "\n *selector_type = MQIT_STRING;\n\n"
# Character Selectors for Object Attributes
@@ -182,16 +169,16 @@ def GenerateReason.wmq_reason(path)
# ['cmqc.h', 'MQBA_'],
# ['cmqcfc.h', 'MQBACF_'],
# Group Selectors for Object Attributes
-# ['cmqcfc.h', 'MQGACF_']
+# ['cmqcfc.h', 'MQGACF_']
].each do |item|
str << " /* Constants #{item[1]}* from #{item[0]} */\n"
GenerateReason.selector_case(path+item[0], item[1], item[2]) do |const|
- str << " if(selector_id == %-32s{ *selector = #{const[0]}; return;}\n" % "ID_#{const[0].gsub(item[1],'').downcase})"
- end
+ str << " if(selector_id == %-32s{ *selector = #{const[0]}; return;}\n" % "ID_#{const[0].gsub(item[1],'').downcase})"
+ end
end
str << <<END_OF_STRING
-
+
rb_raise(rb_eArgError, "WMQ::QueueManager#execute [wmq_selector] Unknown selector supplied");
}
@@ -208,9 +195,9 @@ def GenerateReason.wmq_reason(path)
end
id = const[0].gsub('MQCMD_','').downcase
str_id_init << " ID_%-25s = rb_intern(\"#{id}\");\n" % id
- str_if << "if(command_id == %-28s{ command = #{const[0]}; }\n" % "ID_#{const[0].gsub('MQCMD_','').downcase})"
+ str_if << "if(command_id == %-28s{ command = #{const[0]}; }\n" % "ID_#{const[0].gsub('MQCMD_','').downcase})"
str << "static ID ID_#{id};\n"
- end
+ end
str << <<END_OF_STRING
void QueueManager_command_id_init()
@@ -221,7 +208,7 @@ def GenerateReason.wmq_reason(path)
MQLONG wmq_command_lookup(ID command_id)
{
MQLONG command = 0;
-#{str_if}
+#{str_if}
else
{
rb_raise(rb_eArgError, "WMQ::QueueManager#execute [wmq_command_lookup] Unknown command supplied");
@@ -232,7 +219,7 @@ def GenerateReason.wmq_reason(path)
END_OF_STRING
str
end
-
+
def self.generate(path)
File.open('wmq_reason.c', 'w') {|file| file.write(GenerateReason.wmq_reason(path))}
puts 'Generated wmq_reason.c'
View
29 ext/generate/generate_structs.rb
@@ -1,30 +1,15 @@
-################################################################################
-# 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.
-################################################################################
require 'erb'
class GenerateStructs
-
+
@@field_ignore_list = [ 'StrucId', 'Version' , 'StrucLength']
-
+
# Store path to WebSphere MQ Structures
def initialize(wmq_includepath, templates_path='.')
@path = wmq_includepath
@templates_path = templates_path
end
-
+
def extract_struct (filename, struct_name)
properties_list = []
line_number = 0
@@ -51,15 +36,15 @@ def extract_struct (filename, struct_name)
end
properties_list
end
-
+
def rubyize_name(name)
name.gsub(/::/, '/').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
tr("-", "_").
downcase
end
-
+
def self.test_rubyize_name
test = self.new
[['a', 'a'],
@@ -75,11 +60,11 @@ def self.test_rubyize_name
raise("rubyize_name('#{item[0]}') == #{str} != '#{item[1]})") if str != item[1]
end
end
-
+
def generate_structs(erb)
erb.result(binding)
end
-
+
def generate(target_filename = 'wmq_structs.c')
erb = nil
File.open(@templates_path+'/wmq_structs.erb') { |file| erb = ERB.new(file.read) }
View
86 ext/generate/wmq_structs.erb
@@ -1,20 +1,4 @@
-<%
-################################################################################
-# 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.
-################################################################################
-
+<%
symbols = {
'descriptor='=>nil,
'headers='=>nil,
@@ -68,7 +52,7 @@
# Transmission-queue header - Todo: Need to deal with MQMDE
{:file=>'cmqc.h', :struct=>'MQXQH', :header=>'xmit_q_header', :format=>'MsgDesc.Format'},
]
-
+
wmq_structs.each do |struct|
# Parse WebSphere MQ 'C' Header file and extract elements
elements = extract_struct(@path+'/'+struct[:file], struct[:struct])
@@ -84,20 +68,6 @@
end
%>
/* --------------------------------------------------------------------------
- * 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.
- * --------------------------------------------------------------------------
*
* WARNING: DO NOT MODIFY THIS FILE
*
@@ -110,24 +80,24 @@
/* --------------------------------------------------------------------------
* Static's to hold Symbols
* --------------------------------------------------------------------------*/
-<%
+<%
header_file = 'cmqc.h'
struct = 'MQMD'
# Define static variables to hold Ruby symbols
key_list = symbols.keys.sort
- key_list.each do |key, value|
+ key_list.each do |key, value|
%><%="static ID ID_#{key.sub('=', '_set')};\n" %><%
end
-
+
# initialize symbols
%>
/* --------------------------------------------------------------------------
* Initialize Symbols
* --------------------------------------------------------------------------*/
void wmq_structs_id_init()
{
-<% key_list.each do |key, value|
+<% key_list.each do |key, value|
%><%=" ID_%-20s = rb_intern(\"%s\");\n"% [key.sub('=', '_set'), key] %><%
end
%>}
@@ -145,44 +115,44 @@ void Message_from_<%=struct_name.downcase%>(VALUE hash, <%=struct_name%>* <%=var
{
VALUE str;
size_t size;
- size_t length;
+ size_t length;
size_t i;
char* pChar;
-
+
<%
elements.each do |item|
type = item[0]
name = item[1]
-
+
next if @@field_ignore_list.include?(name) ||
(name=='Format' && struct[:header])
-
+
match = /(MQ\D+)/.match(type)
type = "#{match[1]}S" if match[1] != type
%><%= if type == 'MQMDS'
" %-16s(hash, &#{variable}->%s);\n" % ['Message_from_mqmd1', name]
else
" %-16s(hash, %-30s #{variable}->%s)\n" % ["WMQ_#{type}2HASH", rubyize_name(name)+',',name]
end %><%
- end
+ end
%>}
static int Message_to_<%=struct_name.downcase%>_each (VALUE key, VALUE value, <%=struct_name%>* p<%=struct_name.downcase%>)
{
VALUE str;
size_t size;
- size_t length;
+ size_t length;
VALUE val;
ID id = rb_to_id(key);
-
+
<% contains = nil
elements.each do |item|
type = item[0]
name = item[1]
-
+
next if @@field_ignore_list.include?(name) ||
(name=='Format' && struct[:header])
-
+
match = /(MQ\D+)/.match(type)
type = "#{match[1]}S" if match[1] != type
%><%= if type == 'MQMDS'
@@ -198,9 +168,9 @@ static int Message_to_<%=struct_name.downcase%>_each (VALUE key, VALUE value, <%
else<% end
end
%><%=struct[:header]?" if(id != ID_header_type)":""%><%
- if contains
+ if contains
%> {
- Message_to_<%= contains%>_each(key, value, &pmqxqh->MsgDesc);
+ Message_to_<%= contains%>_each(key, value, &pmqxqh->MsgDesc);
}<%
else%>
{
@@ -215,7 +185,7 @@ void Message_to_<%=struct_name.downcase%>(VALUE hash, <%=struct_name%>* p<%=stru
{
rb_hash_foreach(hash, Message_to_<%=struct_name.downcase%>_each, (VALUE)p<%=struct_name.downcase%>);
}
-<% end # wmq_structs.each
+<% end # wmq_structs.each
%>
/* --------------------------------------------------------------------------
@@ -240,10 +210,10 @@ void Message_deblock(VALUE self, PMQMD pmqmd, PMQBYTE p_buffer, MQLONG total_len
{
VALUE hash = rb_hash_new();
P<%=struct[:struct]%> p_header = (P<%=struct[:struct]%>)p_data;
-
+
if(trace_level>2)
printf("WMQ::Message#deblock Found <%=struct[:header]%>\n");
-
+
if(memcmp(p_header->StrucId, <%=struct[:struct_id] || "#{struct[:struct].upcase}_STRUC_ID"%>, sizeof(p_header->StrucId)) != 0)
{
if(trace_level>1)
@@ -277,7 +247,7 @@ void Message_deblock(VALUE self, PMQMD pmqmd, PMQBYTE p_buffer, MQLONG total_len
else
<%
end
- end # wmq_structs.each
+ end # wmq_structs.each
%> {
break;
}
@@ -287,7 +257,7 @@ void Message_deblock(VALUE self, PMQMD pmqmd, PMQBYTE p_buffer, MQLONG total_len
{
strncpy(pmqmd->Format, p_format, MQ_FORMAT_LENGTH);
}
-
+
Message_from_mqmd(descriptor, pmqmd);
rb_funcall(self, ID_descriptor_set, 1, descriptor);
rb_funcall(self, ID_headers_set, 1, headers);
@@ -302,8 +272,8 @@ void Message_build_set_format(ID header_type, PMQBYTE p_format)
%> if(header_type == ID_<%=struct[:header]%>) { memcpy(p_format, MQFMT_<%=struct[:header].upcase%>, MQ_FORMAT_LENGTH); return;}
<%
end
- end # wmq_structs.each
-
+ end # wmq_structs.each
+
%>
rb_raise(rb_eArgError, "Invalid/Unknown header_type supplied in WMQ::Message#headers array");
}
@@ -332,7 +302,7 @@ int Message_build_header (VALUE hash, struct Message_build_header_arg* parg)
if(parg->trace_level>2)
printf ("WMQ::Message#build_header Found <%=struct[:header]%>\n");
-
+
p_data = Message_autogrow_data_buffer(parg, sizeof(<%=struct[:struct]%>));
memcpy(p_data, &<%=struct[:struct]%>_DEF, sizeof(<%=struct[:struct]%>));
@@ -351,13 +321,13 @@ int Message_build_header (VALUE hash, struct Message_build_header_arg* parg)
if(parg->trace_level>2)
printf ("WMQ::Message#build_header data offset:%ld\n", (long)(*(parg->p_data_offset)));
-<% end
+<% end
%> }
else
<%
end
- end # wmq_structs.each
-
+ end # wmq_structs.each
+
%> {
rb_raise(rb_eArgError, "Unknown :header_type supplied in WMQ::Message#headers array");
}
View
5 ext/wmq.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
+ * Copyright 2006 J. Reid Morrison
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -80,9 +80,6 @@ void Init_wmq() {
QueueManager_selector_id_init();
QueueManager_command_id_init();
wmq_structs_id_init();
-
- rb_require("wmq/wmq_temp");
- rb_require("wmq/wmq_const");
}
/*
View
6 ext/wmq.h
@@ -1,5 +1,5 @@
/* --------------------------------------------------------------------------
- * Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
+ * Copyright 2006 J. Reid Morrison
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +33,10 @@
#define rb_str_set_len(str, length) (RSTRING_LEN(str) = (length))
#endif
+#ifndef _int64
+ #define _int64 long long
+#endif
+
#include <cmqc.h>
#include <cmqxc.h>
View
2 ext/wmq_message.c
@@ -1,5 +1,5 @@
/* --------------------------------------------------------------------------
- * Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
+ * Copyright 2006 J. Reid Morrison
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
View
2 ext/wmq_mq_load.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
+ * Copyright 2006 J. Reid Morrison
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
View
2 ext/wmq_queue.c
@@ -1,5 +1,5 @@
/* --------------------------------------------------------------------------
- * Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
+ * Copyright 2006 J. Reid Morrison
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
View
2 ext/wmq_queue_manager.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
+ * Copyright 2006 J. Reid Morrison
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
View
29 lib/wmq.rb
@@ -1,23 +1,14 @@
-################################################################################
-# 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.
-################################################################################
+require 'wmq/version'
+require 'wmq/constants'
+require 'wmq/constants_admin'
+require 'wmq/queue_manager'
+require 'wmq/message'
-# Load wmq that uses auto-load library.
-#
-# If it fails, then it is likely due to this platform not being supported
-# by auto load facility in Ruby WMQ, so try to load client linked library
+# Load wmq using the auto-load library.
+#
+# If it fails, then it is most likely since this platform is not supported
+# by the auto load facility in Ruby WMQ, so try to load client linked library
+# For Example AIX does not support Autoload whereas Windows and Linux are supported
begin
require 'wmq/wmq'
rescue LoadError
View
70 lib/wmq/message.rb
@@ -0,0 +1,70 @@
+# Message Ruby methods
+module WMQ
+ # Message contains the message descriptor (MQMD), data
+ # and any headers.
+ #
+ # Note:
+ # * The format in the descriptor applies only to the format of the data portion,
+ # not the format of any included headers
+ # * The message format can ONLY be supplied in the descriptor.
+ # * I.e. It is the format of the data, Not the headers.
+ # * On the wire formats are determined automatically by the :header_type key for
+ # each header
+ # * Other WebSphere MQ interfaces require that the formats be "daisy-chained"
+ # * I.e. The MQMD.Format is actually the format of the first header
+ # * Ruby WMQ removes this tedious requirement and performs this
+ # requirement automatically under the covers
+ # * The format of any header should not be supplied in the descriptor or any header
+ #
+ # Message has the following attributes:
+ # * descriptor = {
+ # # WebSphere MQ Equivalent
+ # :format => WMQ::MQFMT_STRING, # MQMD.Format - Format of data only
+ # WMQ::MQFMT_NONE # Do not supply header formats here
+ # :original_length => Number # MQMD.OriginalLength
+ # :priority => 0 .. 9 # MQMD.Priority
+ # :put_time => String # MQMD.PutTime
+ # :msg_id => String ...
+ # :expiry => Number
+ # :persistence => Number
+ # :reply_to_q => String
+ # :correl_id => String
+ # :feedback => Number
+ # :offset => Number
+ # :report => Number
+ # :msg_flags => Number
+ # :reply_to_q_mgr => String
+ # :appl_identity_data => String
+ # :put_appl_name => String
+ # :user_identifier => String
+ # :msg_seq_number => Number
+ # :appl_origin_data => String
+ # :accounting_token => String
+ # :backout_count => Number
+ # :coded_char_set_id => Number
+ # :put_appl_type => Number
+ # :msg_type => Number
+ # :group_id => String
+ # :put_date => String
+ # :encoding => Number
+ # }
+ # * data => String
+ # * headers => Array of Hashes
+ # * Note: Do not supply the format of any header. Ruby WMQ does this for you.
+ #
+ # The following headers are supported:
+ # * Rules And Formatting Header (RFH)
+ # :header_type => :rf_header
+ # :....
+ # * Rules and Formatting V2 Header (RFH2)
+ # ....
+ # * Dead Letter Header
+ # * CICS Header
+ # * IMS Header
+ # * Transmission Queue Header
+ # * ...
+ class Message
+ attr_accessor :data, :descriptor, :headers
+ end
+
+end
View
109 ext/lib/wmq_temp.rb → lib/wmq/queue_manager.rb
@@ -1,35 +1,6 @@
-################################################################################
-# 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.
-################################################################################
-
+# QueueManager ruby methods
module WMQ
-
- # Temporary placeholder until the following code is moved to 'C'
-
- #
class QueueManager
- def method_missing(name, *args)
- if args.size == 1
- self.execute({:command=>name}.merge(args[0]))
- elsif args.size == 0
- self.execute({:command=>name})
- else
- raise("Invalid arguments supplied to QueueManager#:#{name}, args:#{args}")
- end
- end
-
# Execute any MQSC command against the queue manager
#
# Example
@@ -124,74 +95,16 @@ def put_to_dead_letter_q(parms)
return self.put(parms)
end
- end
+ # Expose Commands directly as Queue Manager methods
+ def method_missing(name, *args)
+ if args.size == 1
+ self.execute({:command=>name}.merge(args[0]))
+ elsif args.size == 0
+ self.execute({:command=>name})
+ else
+ raise("Invalid arguments supplied to QueueManager#:#{name}, args:#{args}")
+ end
+ end
- # Message contains the message descriptor (MQMD), data
- # and any headers.
- #
- # Note:
- # * The format in the descriptor applies only to the format of the data portion,
- # not the format of any included headers
- # * The message format can ONLY be supplied in the descriptor.
- # * I.e. It is the format of the data, Not the headers.
- # * On the wire formats are determined automatically by the :header_type key for
- # each header
- # * Other WebSphere MQ interfaces require that the formats be "daisy-chained"
- # * I.e. The MQMD.Format is actually the format of the first header
- # * Ruby WMQ removes this tedious requirement and performs this
- # requirement automatically under the covers
- # * The format of any header should not be supplied in the descriptor or any header
- #
- # Message has the following attributes:
- # * descriptor = {
- # # WebSphere MQ Equivalent
- # :format => WMQ::MQFMT_STRING, # MQMD.Format - Format of data only
- # WMQ::MQFMT_NONE # Do not supply header formats here
- # :original_length => Number # MQMD.OriginalLength
- # :priority => 0 .. 9 # MQMD.Priority
- # :put_time => String # MQMD.PutTime
- # :msg_id => String ...
- # :expiry => Number
- # :persistence => Number
- # :reply_to_q => String
- # :correl_id => String
- # :feedback => Number
- # :offset => Number
- # :report => Number
- # :msg_flags => Number
- # :reply_to_q_mgr => String
- # :appl_identity_data => String
- # :put_appl_name => String
- # :user_identifier => String
- # :msg_seq_number => Number
- # :appl_origin_data => String
- # :accounting_token => String
- # :backout_count => Number
- # :coded_char_set_id => Number
- # :put_appl_type => Number
- # :msg_type => Number
- # :group_id => String
- # :put_date => String
- # :encoding => Number
- # }
- # * data => String
- # * headers => Array of Hashes
- # * Note: Do not supply the format of any header. Ruby WMQ does this for you.
- #
- # The following headers are supported:
- # * Rules And Formatting Header (RFH)
- # :header_type => :rf_header
- # :....
- # * Rules and Formatting V2 Header (RFH2)
- # ....
- # * Dead Letter Header
- # * CICS Header
- # * IMS Header
- # * Transmission Queue Header
- # * ...
- class Message
- attr_reader :data, :descriptor, :headers
- attr_writer :data, :descriptor, :headers
end
-
end
View
3 lib/wmq/version.rb
@@ -0,0 +1,3 @@
+module WMQ #:nodoc
+ VERSION = "1.9.0"
+end
View
1 nbproject/project.properties
@@ -3,6 +3,7 @@ file.reference.trunk-examples=examples
file.reference.trunk-ext=ext
file.reference.trunk-lib=lib
file.reference.trunk-tests=tests
+javac.classpath=
lib.dir=${file.reference.trunk-lib}
main.file=
source.encoding=UTF-8
View
4 nbproject/project.xml
@@ -5,9 +5,9 @@
<data xmlns="http://www.netbeans.org/ns/ruby-project/1">
<name>rubywmq</name>
<source-roots>
- <root id="src.dir"/>
+ <root id="src.dir" name="ext"/>
<root id="examples.dir"/>
- <root id="lib.dir"/>
+ <root id="lib.dir" name="Source Files"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
View
32 rubywmq.binary.gemspec
@@ -1,32 +0,0 @@
-require 'fileutils'
-require 'rubygems'
-
-if $0 == __FILE__
- FileUtils.mkdir_p('lib/wmq')
- Dir['ext/lib/*.rb'].each{|file| FileUtils.copy(file, File.join('lib/wmq', File.basename(file)))}
- FileUtils.copy('ext/wmq.so', 'lib/wmq/wmq.so')
-end
-
-spec = Gem::Specification.new do |s|
- s.name = 'rubywmq'
- s.version = '1.1.0'
- s.author = 'Reid Morrison'
- s.email = 'rubywmq@gmail.com'
- s.homepage = 'http://www.reidmorrison.com/rubywmq'
- s.platform = Gem::Platform::CURRENT
- s.summary = 'Ruby interface into WebSphere MQ (MQSeries)'
- s.description = 'RubyWMQ is a Ruby interface into WebSphere MQ, previously called MQSeries'
- s.files = Dir['examples/**/*.rb'] +
- Dir['examples/**/*.cfg'] +
- Dir['doc/**/*.*'] +
- Dir['lib/**/*.rb'] +
- ['lib/wmq/wmq.so', 'tests/test.rb', 'README', 'LICENSE']
- s.rubyforge_project = 'rubywmq'
- s.test_file = 'tests/test.rb'
- s.has_rdoc = false
- s.required_ruby_version = '>= 1.8.3'
- s.requirements << 'WebSphere MQ v5.3, v6 or v7 Client or Server'
-end
-if $0 == __FILE__
- Gem::Builder.new(spec).build
-end
View
23 rubywmq.gemspec
@@ -1,23 +0,0 @@
-require 'rubygems'
-require 'date'
-spec = Gem::Specification.new do |s|
- s.name = 'rubywmq'
- s.version = '1.1.0'
- s.author = 'Reid Morrison'
- s.email = 'rubywmq@gmail.com'
- s.homepage = 'http://www.reidmorrison.com/rubywmq'
- s.platform = Gem::Platform::RUBY
- s.summary = 'Ruby interface into WebSphere MQ (MQSeries)'
- s.description = 'RubyWMQ is a Ruby interface into WebSphere MQ, previously called MQSeries'
- s.files = Dir['examples/**/*.rb'] + File.readlines('Manifest.txt').map { |l| l.chomp }
- s.rubyforge_project = 'rubywmq'
- s.extensions << 'ext/extconf.rb'
- s.test_file = 'tests/test.rb'
- s.has_rdoc = true
- s.required_ruby_version = '>= 1.8.3'
- s.extra_rdoc_files = ['README', 'LICENSE']
- s.requirements << 'WebSphere MQ v5.3, v6 or v7 Client or Server with MQ and Ruby SDK'
-end
-if $0 == __FILE__
- Gem::Builder.new(spec).build
-end
View
61 tests/test.rb
@@ -1,15 +1,14 @@
-# Shift include path to use locally built copy of rubywmq - For testing dev builds only
-#$:.unshift '../lib'
+# Allow test to be run in-place without requiring a gem install
+$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
require 'rubygems'
-require 'wmq/wmq'
-require 'wmq/wmq_const_admin'
+require 'wmq'
require 'test/unit'
class TestTest < Test::Unit::TestCase
def setup
puts '****** setup: start ******'
- @queue_manager = WMQ::QueueManager.new(:q_mgr_name => 'REID') #, :connection_name=>'localhost(1414)')
+ @queue_manager = WMQ::QueueManager.new(:q_mgr_name => 'TEST') #, :connection_name=>'localhost(1414)')
@queue_manager.connect
# Create Queue and clear any messages from the queue
@@ -161,7 +160,7 @@ def verify_multiple_headers(headers, format)
count = count + 1
end
end
-
+
def test_dlh
puts '****** test_dlh ******'
dlh = {:header_type =>:dead_letter_header,
@@ -205,7 +204,7 @@ def test_cics
}
verify_header(cics, WMQ::MQFMT_NONE)
end
-
+
def test_ims
puts '****** test_ims ******'
ims = {:header_type =>:ims,
@@ -214,7 +213,7 @@ def test_ims
}
verify_header(ims, WMQ::MQFMT_STRING)
end
-
+
def test_transmission_header
puts '****** test_transmission_header ******'
xqh = {:header_type =>:xmit_q_header,
@@ -225,45 +224,45 @@ def test_transmission_header
}
verify_header(xqh, WMQ::MQFMT_STRING)
end
-
+
def test_rf_header
puts '****** test_rf_header ******'
rfh = {:header_type =>:rf_header,
- :name_value => {' name s' => ' v a "l" u e 1 ',
- 'n a m e 2 ' => 'v a l u e 2',
+ :name_value => {' name s' => ' v a "l" u e 1 ',
+ 'n a m e 2 ' => 'v a l u e 2',
'' => ['"', '""', '"""', '""""', ''],
'name3'=>['"value3"', '', '"',' value 43"']},
}
verify_header(rfh, WMQ::MQFMT_STRING)
end
-
+
def test_rf_header_2
puts '****** test_rf_header_2 ******'
rfh2 = {:header_type =>:rf_header_2,
- :xml => ['<hello>to the world</hello>',
+ :xml => ['<hello>to the world</hello>',
'<another>xml like string</another>'],
}
verify_header(rfh2, WMQ::MQFMT_STRING)
end
-
+
def test_multiple_headers
puts '****** test_multiple_headers ******'
headers = [{:header_type => :rf_header_2,
- :xml => ['<hello>to the world</hello>',
+ :xml => ['<hello>to the world</hello>',
'<another>xml like string</another>'],},
-
+
{:header_type => :rf_header,
- :name_value => {' name s' => ' v a l u e 1 ',
- 'n a m e 2 ' => 'v a l u e 2',
+ :name_value => {' name s' => ' v a l u e 1 ',
+ 'n a m e 2 ' => 'v a l u e 2',
'name3'=>['value3', '', 'value 43']} },
-
+
{:header_type => :ims,
:l_term_override => 'LTERM',
:reply_to_format => WMQ::MQFMT_STRING},
-
+
{:header_type => :rf_header,
- :name_value => {' name s' => ' v a l u e 1 ',
- 'n a m e 2 ' => 'v a l u e 2',
+ :name_value => {' name s' => ' v a l u e 1 ',
+ 'n a m e 2 ' => 'v a l u e 2',
'name3'=>['value3', '', 'value 43']} },
{:header_type => :cics,
@@ -273,44 +272,44 @@ def test_multiple_headers
{:header_type => :rf_header_2,
:xml => ['<hello>to the world</hello>', '<another>xml like string</another>'],},
-
+
{:header_type => :xmit_q_header,
:remote_q_name => 'SOME_REMOTE_QUEUE',
:remote_q_mgr_name=> 'SOME_REMOTE_Q_MGR',
:msg_type => WMQ::MQMT_REQUEST,
:msg_id => 'my message Id'},
- ]
+ ]
verify_multiple_headers(headers, WMQ::MQFMT_STRING)
end
-
+
def test_xmit_multiple_headers
puts '****** test_xmit_q_header with ims header ******'
headers = [{:header_type => :xmit_q_header,
:remote_q_name => 'SOME_REMOTE_QUEUE',
:remote_q_mgr_name=> 'SOME_REMOTE_Q_MGR',
:msg_type => WMQ::MQMT_REQUEST,
:msg_id => 'my message Id'},
-
+
{:header_type => :ims,
:l_term_override => 'LTERM',
:reply_to_format => WMQ::MQFMT_STRING},
]
verify_multiple_headers(headers, WMQ::MQFMT_STRING)
end
-
+
def test_message_grouping
puts '****** test_message_grouping ******'
# Clear out queue of any messages
@in_queue.each { |message| }
-
+
msg = WMQ::Message.new
msg.data = 'First'
msg.descriptor[:msg_flags] = WMQ::MQMF_MSG_IN_GROUP
assert_equal(@out_queue.put(:message=>msg, :options => WMQ::MQPMO_LOGICAL_ORDER), true)
-
+
msg.data = 'Second'
assert_equal(@out_queue.put(:message=>msg, :options => WMQ::MQPMO_LOGICAL_ORDER), true)
-
+
msg.data = 'Last'
msg.descriptor[:msg_flags] = WMQ::MQMF_LAST_MSG_IN_GROUP
assert_equal(@out_queue.put(:message=>msg, :options => WMQ::MQPMO_LOGICAL_ORDER), true)
@@ -324,5 +323,5 @@ def test_message_grouping
assert_equal(str, message.data)
end
end
-
+
end

0 comments on commit b6d34be

Please sign in to comment.
Something went wrong with that request. Please try again.