Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use require 'wmq' in examples, update documentation and improve extco…

…nf.rb to avoid working directory path issues
  • Loading branch information...
commit 5d0709fecb7771b8381e32130032629600ab8f41 1 parent b6d34be
@reidmorrison authored
View
207 README.md
@@ -1,10 +1,47 @@
## rubywmq
+RubyWMQ is a high performance native Ruby interface into WebSphere MQ.
+
* http://github.com/reidmorrison/rubywmq
-### Description
+### Features
-RubyWMQ is a high performance native Ruby interface into WebSphere MQ.
+The Ruby WMQ interface currently supports the following features:
+
+* High performance
+ Able to read over 2000 messages per second from a Queue
+ (Non-persistent messages, < 4K each, MQ V6, running on Windows Laptop)
+
+* Full support for the entire MQ Administration interface (MQAI)
+ Create Queues
+ Query Queue Depths
+ etc…
+
+* Full support for all WebSphere MQ Headers
+ Rules and Format Header 2 (RFH2)
+ Rules and Format Header (RFH)
+ Name Value pairs returned as a Hash
+ Dead Letter Header
+ Transmission Queue Header
+ IMS, CICS, …..
+
+* Conforms with the Ruby way. Implements:
+ each
+ Code blocks
+ etc..
+
+* Relatively easy interface for reading or writing messages
+ MQ Headers made easy
+
+* Single Ruby WMQ auto-detection library that concurrently supports:
+ WebSphere MQ Server Connection
+ WebSphere MQ Client Connection
+
+* Includes latest client connection options such as SSL
+
+* Tested with WebSphere MQ V5.3, V6, V7, and V7.5
+
+* Is written in C to ensure easier portability and performance
### Compatibility
@@ -30,6 +67,69 @@ WebSphere MQ
qmgr.put(:q_name=>'TEST.QUEUE', :data => 'Hello World')
end
+## Documentation
+
+Documentation for the RubyWMQ Gem is generated automatically when the gem is installed.
+It is also available [online](http://rubywmq.rubyforge.org/doc/index.html)
+
+## Examples
+
+There are many examples covering many of the ways that RubyWMQ can be used. The examples
+are installed as part of the Gem under the 'examples' sub-directory. The examples can
+also be be viewed at https://github.com/reidmorrison/rubywmq/tree/master/examples
+
+Put one message to a Queue (Without opening the queue)
+
+* put1_a.rb
+* put1_b.rb
+* put1_c.rb
+
+Put messages to a Queue
+
+* put_a.rb
+* put_b.rb
+
+Read one message from a queue
+
+* get_a.rb
+
+Reading Several messages from a Queue:
+
+* each_a.rb
+* each_b.rb
+* each_header.rb
+
+Connect using MQ Client connection
+
+* get_client.rb
+
+Put Messages to a Queue as a group
+
+* put_group_a.rb
+* put_group_b.rb
+
+Put Messages to a Queue, including message headers
+
+* put_dlh.rb
+* put_dynamic_q.rb
+* put_rfh.rb
+* put_rfh2_a.rb
+* put_rfh2_b.rb
+* put_xmit_q.rb
+
+Writing multiple files to a queue, where each file is a separate message:
+
+* files_to_q.rb, files_to_q.cfg
+
+Writing the contents of a queue to multiple files, where each message is a separate file:
+
+* q_to_files.rb, q_to_files.cfg
+
+Sample “client” and “server” side applications for sending or processing requests
+
+* request.rb
+* server.rb
+
## Installation
### Installing on UNIX/Linux
@@ -133,7 +233,7 @@ side channels.
After following the steps above to compile the source code, add the following
line to Gemfile
- gem 'rubywmq', :require => 'wmq'
+ gem 'rubywmq'
## Architecture
@@ -149,6 +249,107 @@ 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.
+## FAQ
+
+### Programs fail with: `require': no such file to load -- wmq (LoadError)
+
+After successfully installing RubyWMQ using the command “gem install rubywmq”,
+program fails with output similar to the following:
+
+ rubywmq-0.3.0/tests/test.rb:4:in `require': no such file to load -- wmq (LoadError)
+ from rubywmq-0.3.0/tests/test.rb:4
+
+Answer: Add the following line to the top of your Ruby program
+
+ require 'rubygems'
+
+### Program fails to connect with MQRC2059, MQRC_Q_MGR_NOT_AVAILABLE
+
+When connecting to either a local or remote WebSphere MQ Queue Manager, a very common
+error returned is that the Queue Manager is not available. This error can occur
+under any of the following circumstances:
+
+* MQ Server Connections (Local Queue Manager)
+
+** Possible Configuration Issues:
+
+*** Ensure that :connection_name is not being supplied to the connect method.
+Even if it is supplied with a nul or empty value, it will cause a client connection attempt to be made.
+
+** Is the Queue Manager active?
+
+*** Try running the following command on the machine running the Queue Manager
+and check that the Queue Manager is marked as ‘Running’:
+
+ dspmq
+
+ Expected output:
+ QMNAME(REID) STATUS(Running)
+
+*** Check that the :q_mgr_name supplied to QueueManager::connect matches the Queue Manager name above. Note: Queue Manager names are case-sensitive
+
+* MQ Client Connections (Remote Queue Manager)
+
+** Possible Client Configuration Issues:
+
+*** Incorrect host name
+
+*** Incorrect port number
+
+*** Incorrect Channel Name
+
+**** For example, the channel being used does not exist on the remote Queue Manager.
+
+**** Note: The channel name is case-sensitive
+
+*** Incorrect Queue Manager Name
+
+**** :q_mgr_name is optional for Client Connections. It does however ensure that the program connects to the expected Queue Manager.
+
+**** For example when the wrong Queue Manager listener is now running on the expected port.
+
+** Is the MQ listener program running on the port supplied above?
+
+
+*** On UNIX/Linux, try the following command on the machine running the Queue Manager:
+
+ ps -ef | grep runmqlsr
+
+
+*** The Queue Mananger name and port number should be displayed
+
+*** If no port number is specified on the command line for an instance of runmqlsr, it means that it is using port 1414.
+
+** Is the Queue Manager active?
+
+*** Try running the following command on the machine running the Queue Manager and check that the Queue Manager is marked as ‘Running’:
+
+ dspmq
+
+ Expected output:
+ QMNAME(REID) STATUS(Running)
+
+*** Check that the :q_mgr_name supplied to QueueManager::connect matches the Queue Manager name above. Note: Queue Manager names are case-sensitive
+
+*** Check if the Channel being used is still defined on the Queue Manager
+
+*** On the machine running the Queue Manager, run the following commands (may need to run them under the 'mqm' userid):
+
+ runmqsc queue_manager_name
+ dis channel(*) chltype(SVRCONN)
+
+*** Replace queue_manager_name above with the actual name of the Queue Manager being connected to
+
+*** Look for the channel name the application is using. Note: the channel name is case-sensitive.
+
+## Support
+
+Ruby WMQ Community Support Mailing List:
+
+ http://rubyforge.org/mailman/listinfo/rubywmq-misc
+
+Feature and Bug Reports: <http://github.com/reidmorrison/rubywmq/issues>
+
## Contributing
Once you've made your great commits:
View
18 examples/each_a.rb
@@ -1,26 +1,10 @@
-################################################################################
-# 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.
-################################################################################
-
#
# Sample : each() : Retrieve all messages from a queue
# If no messages are on the queue, the program
# completes without waiting
#
require 'rubygems'
-require 'wmq/wmq'
+require 'wmq'
WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:input) do |queue|
View
18 examples/each_b.rb
@@ -1,25 +1,9 @@
-################################################################################
-# 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.
-################################################################################
-
#
# Sample : each() : Retrieve all messages from a queue that
# have the same correlation id
#
require 'rubygems'
-require 'wmq/wmq'
+require 'wmq'
WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:input) do |queue|
View
22 examples/each_header.rb
@@ -1,35 +1,19 @@
-################################################################################
-# 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.
-################################################################################
-
#
# Sample : each() : Retrieve all messages from a queue
# If no messages are on the queue, the program
# completes without waiting
#
require 'rubygems'
-require 'wmq/wmq'
+require 'wmq'
WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
qmgr.open_queue(:q_name=>'TEST.DEAD', :mode=>:browse) do |queue|
queue.each do |message|
puts "Data Received: #{message.data}"
-
+
puts "Message Descriptor:"
p message.descriptor
-
+
puts "Headers Received:"
message.headers.each {|header| p header}
end
View
18 examples/files_to_q.rb
@@ -1,19 +1,3 @@
-################################################################################
-# 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 : files_to_q : Place all files in a directory to a queue
# Each file is written as a separate message
@@ -21,7 +5,7 @@
require 'rubygems'
require 'find'
require 'yaml'
-require 'wmq/wmq'
+require 'wmq'
# Call program passing environment name as first parameter
# The environment corresponds to an entry in the config file
View
18 examples/get_a.rb
@@ -1,25 +1,9 @@
-################################################################################
-# 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.
-################################################################################
-
#
# Sample : get() : Retrieve a single message from a queue
# If no messages are on the queue, message.data is nil
#
require 'rubygems'
-require 'wmq/wmq'
+require 'wmq'
WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:input) do |queue|
View
26 examples/get_client.rb
@@ -1,31 +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.
-################################################################################
-
#
# Sample : get() : Retrieve a single message from a queue
# If no messages are on the queue, message.data is nil
#
# The Client connection is determined by the :connection_name parameter supplied
# to QueueManager::connect or QueueManager::new
-#
+#
# If :connection_name is not present, a WebSphere MQ Server connection will be used
# I.e. Local server connection
-#
+#
require 'rubygems'
-require 'wmq/wmq'
+require 'wmq'
WMQ::QueueManager.connect(
:connection_name => 'localhost(1414)', # Use MQ Client Library
@@ -37,10 +21,10 @@
message = WMQ::Message.new
if queue.get(:message => message)
puts "Data Received: #{message.data}"
-
+
puts "Message Descriptor:"
p message.descriptor
-
+
puts "Headers Received:"
message.headers.each {|header| p header}
else
View
18 examples/put1_a.rb
@@ -1,24 +1,8 @@
-################################################################################
-# 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.
-################################################################################
-
#
# Sample : put1() : Put a single message to a queue
#
require 'rubygems'
-require 'wmq/wmq'
+require 'wmq'
WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
qmgr.put(:q_name=>'TEST.QUEUE', :data => 'Hello World')
View
18 examples/put1_b.rb
@@ -1,26 +1,10 @@
-################################################################################
-# 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.
-################################################################################
-
#
# Sample : put1() : Put a single message to a queue
#
# Set the correlation id to a text string
#
require 'rubygems'
-require 'wmq/wmq'
+require 'wmq'
WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
View
22 examples/put1_c.rb
@@ -1,32 +1,16 @@
-################################################################################
-# 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.
-################################################################################
-
#
# Sample : put() : Put a single request message to a queue
#
require 'rubygems'
-require 'wmq/wmq'
+require 'wmq'
WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
message = WMQ::Message.new
message.data = 'Hello World'
-
+
message.descriptor = {
:msg_type=> WMQ::MQMT_REQUEST,
:reply_to_q=>'TEST.REPLY.QUEUE'}
-
+
qmgr.put(:q_name=>'TEST.QUEUE', :message => message)
end
View
18 examples/put_a.rb
@@ -1,25 +1,9 @@
-################################################################################
-# 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.
-################################################################################
-
#
# Sample : put() : Put a single message to a queue
# Open the queue so that multiple puts can be performed
#
require 'rubygems'
-require 'wmq/wmq'
+require 'wmq'
WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
View
18 examples/put_b.rb
@@ -1,26 +1,10 @@
-################################################################################
-# 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.
-################################################################################
-
#
# Sample : put() : Put two Messages to a queue
# Open the queue so that multiple puts can be performed
# Ensure that all messages have the same correlation id
#
require 'rubygems'
-require 'wmq/wmq'
+require 'wmq'
WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
View
24 examples/put_dlh.rb
@@ -1,40 +1,24 @@
-################################################################################
-# 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.
-################################################################################
-
#
# Sample : put() : Put a message to a queue with a dead letter header
# Open the queue so that multiple puts can be performed
#
require 'rubygems'
-require 'wmq/wmq'
+require 'wmq'
WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
message = WMQ::Message.new
message.data = 'Hello World'
-
+
message.headers = [
{:header_type =>:dead_letter_header,
:reason => WMQ::MQRC_UNKNOWN_REMOTE_Q_MGR,
:dest_q_name =>'ORIGINAL_QUEUE_NAME',
:dest_q_mgr_name =>'BAD_Q_MGR'}
]
-
+
message.descriptor[:format] = WMQ::MQFMT_STRING
-
+
queue.put(:message=>message)
end
end
View
18 examples/put_dynamic_q.rb
@@ -1,19 +1,3 @@
-################################################################################
-# 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.
-################################################################################
-
#
# Sample : put() : Put a single message to a queue
# Create the queue if it does not already exist
@@ -26,7 +10,7 @@
# In this sample the queue will disappear when this program terminates
#
require 'rubygems'
-require 'wmq/wmq'
+require 'wmq'
WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
qmgr.open_queue(:q_name => 'SYSTEM.DEFAULT.MODEL.QUEUE',
View
18 examples/put_group_a.rb
@@ -1,19 +1,3 @@
-################################################################################
-# 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.
-################################################################################
-
#
# Sample : put() : Put multiple Messages to a queue under the same group Id
# Open the queue so that multiple puts can be performed
@@ -22,7 +6,7 @@
# assign message sequence numbers for each message in the group
#
require 'rubygems'
-require 'wmq/wmq'
+require 'wmq'
# Put 5 messages in a single group onto the queue
total = 5
View
18 examples/put_group_b.rb
@@ -1,19 +1,3 @@
-################################################################################
-# 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.
-################################################################################
-
#
# Sample : put() : Put multiple Messages to a queue under the same group Id
# Open the queue so that multiple puts can be performed
@@ -22,7 +6,7 @@
# We also have to supply the message sequence number which starts at 1
#
require 'rubygems'
-require 'wmq/wmq'
+require 'wmq'
# Put 5 messages in a single group onto the queue
total = 5
View
40 examples/put_rfh.rb
@@ -1,30 +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.
-################################################################################
-
#
# Sample : put() : Put a message to a queue with a Refernce header
# Open the queue so that multiple puts can be performed
#
require 'rubygems'
-require 'wmq/wmq'
+require 'wmq'
# The Rules Format header (MQRFH) allows a list of name value pairs to be sent along
# with a WMQ message. These name value pairs are represented as follows on the "wire":
# Name1 Value1 Name2 Value2 Name3 Value3
-#
+#
# Ruby WMQ converts the above string of data into a Ruby hash by
# using the name as the key, as follows:
# data = {
@@ -32,9 +16,9 @@
# 'Name2' => 'Value2',
# 'Name3' => 'Value3'
# }
-#
+#
# Since a name can consist of any character except null, it is stored as a String
-#
+#
# Note: It is possible to send or receive the same Name with multiple values using an array.
# E.g. Name1 Value1 Name2 Value2 Name1 Value3
# Becomes:
@@ -42,25 +26,25 @@
# 'Name1' => ['Value1', 'Value3'],
# 'Name2' => 'Value2'
# }
-#
+#
# Note: Since a Hash does not preserve order, reading a Rules Format Header and then writing
# it out immediately again could result in re-ordering of the name value pairs.
-#
+#
WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
message = WMQ::Message.new
message.data = 'Hello World'
-
+
message.headers = [
{:header_type =>:rf_header,
- :name_value => {'name1' => 'value1',
- 'name2' => 'value2',
- 'name3' => ['value 3a', 'value 3b']}
+ :name_value => {'name1' => 'value1',
+ 'name2' => 'value2',
+ 'name3' => ['value 3a', 'value 3b']}
}]
-
+
message.descriptor[:format] = WMQ::MQFMT_STRING
-
+
queue.put(:message=>message)
end
end
View
26 examples/put_rfh2_a.rb
@@ -1,42 +1,26 @@
-################################################################################
-# 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.
-################################################################################
-
#
# Sample : put() : Put a message to a queue with a Refernce header
# Open the queue so that multiple puts can be performed
#
require 'rubygems'
-require 'wmq/wmq'
+require 'wmq'
# The Rules Format header2 (MQRFH2) allows a an XML-like string to be passed as a header
# to the data.
-#
+#
WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
message = WMQ::Message.new
message.data = 'Hello World'
-
+
message.headers = [
{:header_type =>:rf_header_2,
:xml => '<hello>to the world</hello>'
}]
-
+
message.descriptor[:format] = WMQ::MQFMT_STRING
-
+
queue.put(:message=>message)
end
end
View
26 examples/put_rfh2_b.rb
@@ -1,42 +1,26 @@
-################################################################################
-# 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.
-################################################################################
-
#
# Sample : put() : Put a message to a queue with a Refernce header
# Open the queue so that multiple puts can be performed
#
require 'rubygems'
-require 'wmq/wmq'
+require 'wmq'
# The Rules Format header2 (MQRFH2) allows a an XML-like string to be passed as a header
# to the data.
-#
+#
WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
message = WMQ::Message.new
message.data = 'Hello World'
-
+
message.headers = [
{:header_type =>:rf_header_2,
:xml => ['<hello>to the world</hello>', '<another>xml like string</another>'],
}]
-
+
message.descriptor[:format] = WMQ::MQFMT_STRING
-
+
queue.put(:message=>message)
end
end
View
20 examples/put_xmit_q.rb
@@ -1,24 +1,8 @@
-################################################################################
-# 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.
-################################################################################
-
#
# Sample : put() : Put a message to a queue with a Transmission header
#
require 'rubygems'
-require 'wmq/wmq'
+require 'wmq'
WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
@@ -26,7 +10,7 @@
message.data = "Test message from 'LOCALQMS1'"
message.descriptor = {:original_length=>-1, :priority=>0, :put_time=>"18510170", :msg_id=>"AMQ LOCALQMS1 E\233\001\237 \000\003\005", :expiry=>-1, :persistence=>0, :reply_to_q=>"MQMON", :correl_id=>"AMQ LOCALQMS1 E\233\001\237 \000\003\004", :feedback=>0, :offset=>0, :report=>0, :msg_flags=>0, :reply_to_q_mgr=>"LOCALQMS1", :appl_identity_data=>"", :put_appl_name=>"LOCALQMS1", :user_identifier=>"mqm", :msg_seq_number=>1, :appl_origin_data=>"", :accounting_token=>"\026\001\005\025\000\000\000\271U\305\002\261\022\362\321\021D\3206\357\003\000\000\000\000\000\000\000\000\000\000\v", :backout_count=>0, :coded_char_set_id=>437, :put_appl_type=>7, :msg_type=>8, :group_id=>"", :put_date=>"20070109", :format=>"MQSTR", :encoding=>546}
message.headers = [{:priority=>0, :remote_q_mgr_name=>"OTHER.QMGR", :put_time=>"18510170", :msg_id=>"AMQ LOCALQMS1 E\233\001\237 \000\003\004", :expiry=>-1, :persistence=>0, :remote_q_name=>"OTHER.Q", :header_type=>:xmit_q_header, :reply_to_q=>"MQMON", :correl_id=>"", :feedback=>0, :report=>0, :reply_to_q_mgr=>"LOCALQMS1", :appl_identity_data=>"", :put_appl_name=>"uments\\MQ\\MQMon\\mqmonntp.exe", :user_identifier=>"mqm", :appl_origin_data=>"", :accounting_token=>"\026\001\005\025\000\000\000\271U\305\002\261\022\362\321\021D\3206\357\003\000\000\000\000\000\000\000\000\000\000\v", :backout_count=>0, :coded_char_set_id=>437, :put_appl_type=>11, :msg_type=>8, :put_date=>"20070109", :encoding=>546}]
-
+
queue.put(:message=>message)
end
end
View
18 examples/q_to_files.rb
@@ -1,26 +1,10 @@
-################################################################################
-# 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 'wmq'
require 'fileutils'
# Call program passing environment name as first parameter
View
30 examples/request.rb
@@ -1,25 +1,9 @@
-################################################################################
-# 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.
-################################################################################
-
#
# Sample : request.rb
-#
+#
# Sample program that demonstrates how to send a request message
# and then block until the response is received from the server.
-#
+#
# A temporary Dynamic Reply To Queue is used with non-persistent messaging
#
require 'rubygems'
@@ -32,22 +16,22 @@
:dynamic_q_name=> 'REQUEST.*',
:mode => :input
) do |reply_queue|
-
+
message = WMQ::Message.new()
message.descriptor = { :msg_type => WMQ::MQMT_REQUEST,
:reply_to_q => reply_queue.name,
:reply_to_q_mgr=> qmgr.name,
:format => WMQ::MQFMT_STRING,
:expiry => wait_seconds*10} # Measured in tenths of a second
- message.data = 'Hello World'
-
+ message.data = 'Hello World'
+
# Send request message
qmgr.put(:q_name=>'TEST.QUEUE', :message=>message)
-
+
# Copy outgoing Message id to correlation id
message.descriptor[:correl_id]=message.descriptor[:msg_id]
- # Wait for reply
+ # Wait for reply
# Only get the message that matches the correlation id set above
if reply_queue.get(:wait=>wait_seconds*1000, :message=>message, :match=>WMQ::MQMO_MATCH_CORREL_ID)
puts "Received:"
View
36 examples/server.rb
@@ -1,19 +1,3 @@
-################################################################################
-# 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.
-################################################################################
-
#
# Sample : Sample program to show how to write a server side application
#
@@ -25,9 +9,9 @@
# prevent messages being if the program terminates unexpectedly
# or an error occurrs.
# Uses: :sync=>true
-# - Queue#each will backout any message changes if an excecption is raised
+# - Queue#each will backout any message changes if an excecption is raised
# but not handled within the each block
-#
+#
# A "well-behaved" WebSphere MQ application should adhere to the following rules:
# - Perform puts and gets under synchpoint where applicable
# - Only send replies to Request messages. No reply for Datagrams
@@ -36,10 +20,10 @@
# - Remaining Expiry (Ideally deduct any processing time since get)
# - Same priority as received message
# - Same persistence as received message
-# - Adhere to the Report options supplied for message and correlation id's
+# - Adhere to the Report options supplied for message and correlation id's
# in reply message
# - All headers must be returned on reply messages
-# - This allows the calling application to store state information
+# - This allows the calling application to store state information
# in these headers
# - Unless of course if the relevant header is input only and used
# for completing the request
@@ -49,7 +33,7 @@
# must be sent back to the requesting application
# - If the reply fails, it must be put to the dead letter queue
# with the relevant dead letter header and reason
-#
+#
# Note: - It is not recommended to run server side MQ applications over a client
# connection.
# - Client connections require substantially more error handling.
@@ -63,27 +47,27 @@
# - etc....
#
require 'rubygems'
-require 'wmq/wmq'
+require 'wmq'
WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:input) do |queue|
queue.each(:wait=>60000, :sync=>true, :convert=>true) do |request|
puts "Data Received:"
puts request.data
-
+
begin
reply = WMQ::Message.new
reply.data = 'Echo back:'+request.data
-
+
qmgr.put_to_reply_q(:message=>reply,
:request_message=>request, # Only replies if message type is request
:sync=>true)
-
+
rescue WMQ::WMQException => exc
# Failed to send reply, put message to the Dead Letter Queue and add a dead letter header
p exc
puts "Failed to reply to sender, Put to dead letter queue"
- qmgr.put_to_dead_letter_q(:message=>request,
+ qmgr.put_to_dead_letter_q(:message=>request,
:reason=>WMQ::MQRC_UNKNOWN_REMOTE_Q_MGR,
:q_name=>queue.name,
:sync=>true)
View
10 ext/extconf.rb
@@ -1,7 +1,9 @@
require 'mkmf'
-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')
+generate_sources_path = File.join(File.dirname(__FILE__), 'generate')
+$LOAD_PATH.unshift generate_sources_path
+require 'generate_reason'
+require 'generate_const'
+require 'generate_structs'
include_path = ''
if RUBY_PLATFORM =~ /win|mingw/i
@@ -22,7 +24,7 @@
# Generate Source Files
GenerateReason.generate(include_path+'/')
GenerateConst.generate(include_path+'/', File.dirname(__FILE__) + '/../lib/wmq')
-GenerateStructs.new(include_path+'/', 'generate').generate
+GenerateStructs.new(include_path+'/', generate_sources_path).generate
# Generate Makefile
create_makefile('wmq/wmq')
View
1  lib/rubywmq.rb
@@ -0,0 +1 @@
+require 'wmq'
View
2  lib/wmq/version.rb
@@ -1,3 +1,3 @@
module WMQ #:nodoc
- VERSION = "1.9.0"
+ VERSION = "2.0.0.pre3"
end
View
9 tests/test.rb
@@ -313,15 +313,6 @@ def test_message_grouping
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)
-
- # Now retrieve the messages destructively
- message = WMQ::Message.new
- test_sizes.each do |size|
- assert_equal(true, @in_queue.get(:message=>message, :match=>WMQ::MQMO_NONE))
- assert_equal(size, message.data.length)
- str = '0123456789ABCDEF' * (size/16) + '0123456789ABCDEF'[0,size%16]
- assert_equal(str, message.data)
- end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.