rubywmq 2.0.0.pre2 → 2.0.0.pre3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,10 +1,47 @@
1
1
  ## rubywmq
2
2
 
3
+ RubyWMQ is a high performance native Ruby interface into WebSphere MQ.
4
+
3
5
  * http://github.com/reidmorrison/rubywmq
4
6
 
5
- ### Description
7
+ ### Features
6
8
 
7
- RubyWMQ is a high performance native Ruby interface into WebSphere MQ.
9
+ The Ruby WMQ interface currently supports the following features:
10
+
11
+ * High performance
12
+ Able to read over 2000 messages per second from a Queue
13
+ (Non-persistent messages, < 4K each, MQ V6, running on Windows Laptop)
14
+
15
+ * Full support for the entire MQ Administration interface (MQAI)
16
+ Create Queues
17
+ Query Queue Depths
18
+ etc…
19
+
20
+ * Full support for all WebSphere MQ Headers
21
+ Rules and Format Header 2 (RFH2)
22
+ Rules and Format Header (RFH)
23
+ Name Value pairs returned as a Hash
24
+ Dead Letter Header
25
+ Transmission Queue Header
26
+ IMS, CICS, …..
27
+
28
+ * Conforms with the Ruby way. Implements:
29
+ each
30
+ Code blocks
31
+ etc..
32
+
33
+ * Relatively easy interface for reading or writing messages
34
+ MQ Headers made easy
35
+
36
+ * Single Ruby WMQ auto-detection library that concurrently supports:
37
+ WebSphere MQ Server Connection
38
+ WebSphere MQ Client Connection
39
+
40
+ * Includes latest client connection options such as SSL
41
+
42
+ * Tested with WebSphere MQ V5.3, V6, V7, and V7.5
43
+
44
+ * Is written in C to ensure easier portability and performance
8
45
 
9
46
  ### Compatibility
10
47
 
@@ -30,6 +67,69 @@ WebSphere MQ
30
67
  qmgr.put(:q_name=>'TEST.QUEUE', :data => 'Hello World')
31
68
  end
32
69
 
70
+ ## Documentation
71
+
72
+ Documentation for the RubyWMQ Gem is generated automatically when the gem is installed.
73
+ It is also available [online](http://rubywmq.rubyforge.org/doc/index.html)
74
+
75
+ ## Examples
76
+
77
+ There are many examples covering many of the ways that RubyWMQ can be used. The examples
78
+ are installed as part of the Gem under the 'examples' sub-directory. The examples can
79
+ also be be viewed at https://github.com/reidmorrison/rubywmq/tree/master/examples
80
+
81
+ Put one message to a Queue (Without opening the queue)
82
+
83
+ * put1_a.rb
84
+ * put1_b.rb
85
+ * put1_c.rb
86
+
87
+ Put messages to a Queue
88
+
89
+ * put_a.rb
90
+ * put_b.rb
91
+
92
+ Read one message from a queue
93
+
94
+ * get_a.rb
95
+
96
+ Reading Several messages from a Queue:
97
+
98
+ * each_a.rb
99
+ * each_b.rb
100
+ * each_header.rb
101
+
102
+ Connect using MQ Client connection
103
+
104
+ * get_client.rb
105
+
106
+ Put Messages to a Queue as a group
107
+
108
+ * put_group_a.rb
109
+ * put_group_b.rb
110
+
111
+ Put Messages to a Queue, including message headers
112
+
113
+ * put_dlh.rb
114
+ * put_dynamic_q.rb
115
+ * put_rfh.rb
116
+ * put_rfh2_a.rb
117
+ * put_rfh2_b.rb
118
+ * put_xmit_q.rb
119
+
120
+ Writing multiple files to a queue, where each file is a separate message:
121
+
122
+ * files_to_q.rb, files_to_q.cfg
123
+
124
+ Writing the contents of a queue to multiple files, where each message is a separate file:
125
+
126
+ * q_to_files.rb, q_to_files.cfg
127
+
128
+ Sample “client” and “server” side applications for sending or processing requests
129
+
130
+ * request.rb
131
+ * server.rb
132
+
33
133
  ## Installation
34
134
 
35
135
  ### Installing on UNIX/Linux
@@ -133,7 +233,7 @@ side channels.
133
233
  After following the steps above to compile the source code, add the following
134
234
  line to Gemfile
135
235
 
136
- gem 'rubywmq', :require => 'wmq'
236
+ gem 'rubywmq'
137
237
 
138
238
  ## Architecture
139
239
 
@@ -149,6 +249,107 @@ Instead of hard coding all the MQ C Structures and return codes into RubyWMQ, it
149
249
  parses the MQ 'C' header files at compile time to take advantage of all the latest
150
250
  features in new releases.
151
251
 
252
+ ## FAQ
253
+
254
+ ### Programs fail with: `require': no such file to load -- wmq (LoadError)
255
+
256
+ After successfully installing RubyWMQ using the command “gem install rubywmq”,
257
+ program fails with output similar to the following:
258
+
259
+ rubywmq-0.3.0/tests/test.rb:4:in `require': no such file to load -- wmq (LoadError)
260
+ from rubywmq-0.3.0/tests/test.rb:4
261
+
262
+ Answer: Add the following line to the top of your Ruby program
263
+
264
+ require 'rubygems'
265
+
266
+ ### Program fails to connect with MQRC2059, MQRC_Q_MGR_NOT_AVAILABLE
267
+
268
+ When connecting to either a local or remote WebSphere MQ Queue Manager, a very common
269
+ error returned is that the Queue Manager is not available. This error can occur
270
+ under any of the following circumstances:
271
+
272
+ * MQ Server Connections (Local Queue Manager)
273
+
274
+ ** Possible Configuration Issues:
275
+
276
+ *** Ensure that :connection_name is not being supplied to the connect method.
277
+ Even if it is supplied with a nul or empty value, it will cause a client connection attempt to be made.
278
+
279
+ ** Is the Queue Manager active?
280
+
281
+ *** Try running the following command on the machine running the Queue Manager
282
+ and check that the Queue Manager is marked as ‘Running’:
283
+
284
+ dspmq
285
+
286
+ Expected output:
287
+ QMNAME(REID) STATUS(Running)
288
+
289
+ *** Check that the :q_mgr_name supplied to QueueManager::connect matches the Queue Manager name above. Note: Queue Manager names are case-sensitive
290
+
291
+ * MQ Client Connections (Remote Queue Manager)
292
+
293
+ ** Possible Client Configuration Issues:
294
+
295
+ *** Incorrect host name
296
+
297
+ *** Incorrect port number
298
+
299
+ *** Incorrect Channel Name
300
+
301
+ **** For example, the channel being used does not exist on the remote Queue Manager.
302
+
303
+ **** Note: The channel name is case-sensitive
304
+
305
+ *** Incorrect Queue Manager Name
306
+
307
+ **** :q_mgr_name is optional for Client Connections. It does however ensure that the program connects to the expected Queue Manager.
308
+
309
+ **** For example when the wrong Queue Manager listener is now running on the expected port.
310
+
311
+ ** Is the MQ listener program running on the port supplied above?
312
+
313
+
314
+ *** On UNIX/Linux, try the following command on the machine running the Queue Manager:
315
+
316
+ ps -ef | grep runmqlsr
317
+
318
+
319
+ *** The Queue Mananger name and port number should be displayed
320
+
321
+ *** If no port number is specified on the command line for an instance of runmqlsr, it means that it is using port 1414.
322
+
323
+ ** Is the Queue Manager active?
324
+
325
+ *** Try running the following command on the machine running the Queue Manager and check that the Queue Manager is marked as ‘Running’:
326
+
327
+ dspmq
328
+
329
+ Expected output:
330
+ QMNAME(REID) STATUS(Running)
331
+
332
+ *** Check that the :q_mgr_name supplied to QueueManager::connect matches the Queue Manager name above. Note: Queue Manager names are case-sensitive
333
+
334
+ *** Check if the Channel being used is still defined on the Queue Manager
335
+
336
+ *** On the machine running the Queue Manager, run the following commands (may need to run them under the 'mqm' userid):
337
+
338
+ runmqsc queue_manager_name
339
+ dis channel(*) chltype(SVRCONN)
340
+
341
+ *** Replace queue_manager_name above with the actual name of the Queue Manager being connected to
342
+
343
+ *** Look for the channel name the application is using. Note: the channel name is case-sensitive.
344
+
345
+ ## Support
346
+
347
+ Ruby WMQ Community Support Mailing List:
348
+
349
+ http://rubyforge.org/mailman/listinfo/rubywmq-misc
350
+
351
+ Feature and Bug Reports: <http://github.com/reidmorrison/rubywmq/issues>
352
+
152
353
  ## Contributing
153
354
 
154
355
  Once you've made your great commits:
@@ -1,26 +1,10 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Sample : each() : Retrieve all messages from a queue
19
3
  # If no messages are on the queue, the program
20
4
  # completes without waiting
21
5
  #
22
6
  require 'rubygems'
23
- require 'wmq/wmq'
7
+ require 'wmq'
24
8
 
25
9
  WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
26
10
  qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:input) do |queue|
@@ -1,25 +1,9 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Sample : each() : Retrieve all messages from a queue that
19
3
  # have the same correlation id
20
4
  #
21
5
  require 'rubygems'
22
- require 'wmq/wmq'
6
+ require 'wmq'
23
7
 
24
8
  WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
25
9
  qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:input) do |queue|
@@ -1,35 +1,19 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Sample : each() : Retrieve all messages from a queue
19
3
  # If no messages are on the queue, the program
20
4
  # completes without waiting
21
5
  #
22
6
  require 'rubygems'
23
- require 'wmq/wmq'
7
+ require 'wmq'
24
8
 
25
9
  WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
26
10
  qmgr.open_queue(:q_name=>'TEST.DEAD', :mode=>:browse) do |queue|
27
11
  queue.each do |message|
28
12
  puts "Data Received: #{message.data}"
29
-
13
+
30
14
  puts "Message Descriptor:"
31
15
  p message.descriptor
32
-
16
+
33
17
  puts "Headers Received:"
34
18
  message.headers.each {|header| p header}
35
19
  end
@@ -1,19 +1,3 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Example : files_to_q : Place all files in a directory to a queue
19
3
  # Each file is written as a separate message
@@ -21,7 +5,7 @@
21
5
  require 'rubygems'
22
6
  require 'find'
23
7
  require 'yaml'
24
- require 'wmq/wmq'
8
+ require 'wmq'
25
9
 
26
10
  # Call program passing environment name as first parameter
27
11
  # The environment corresponds to an entry in the config file
@@ -1,25 +1,9 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Sample : get() : Retrieve a single message from a queue
19
3
  # If no messages are on the queue, message.data is nil
20
4
  #
21
5
  require 'rubygems'
22
- require 'wmq/wmq'
6
+ require 'wmq'
23
7
 
24
8
  WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
25
9
  qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:input) do |queue|
@@ -1,31 +1,15 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Sample : get() : Retrieve a single message from a queue
19
3
  # If no messages are on the queue, message.data is nil
20
4
  #
21
5
  # The Client connection is determined by the :connection_name parameter supplied
22
6
  # to QueueManager::connect or QueueManager::new
23
- #
7
+ #
24
8
  # If :connection_name is not present, a WebSphere MQ Server connection will be used
25
9
  # I.e. Local server connection
26
- #
10
+ #
27
11
  require 'rubygems'
28
- require 'wmq/wmq'
12
+ require 'wmq'
29
13
 
30
14
  WMQ::QueueManager.connect(
31
15
  :connection_name => 'localhost(1414)', # Use MQ Client Library
@@ -37,10 +21,10 @@ WMQ::QueueManager.connect(
37
21
  message = WMQ::Message.new
38
22
  if queue.get(:message => message)
39
23
  puts "Data Received: #{message.data}"
40
-
24
+
41
25
  puts "Message Descriptor:"
42
26
  p message.descriptor
43
-
27
+
44
28
  puts "Headers Received:"
45
29
  message.headers.each {|header| p header}
46
30
  else
@@ -1,24 +1,8 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Sample : put1() : Put a single message to a queue
19
3
  #
20
4
  require 'rubygems'
21
- require 'wmq/wmq'
5
+ require 'wmq'
22
6
 
23
7
  WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
24
8
  qmgr.put(:q_name=>'TEST.QUEUE', :data => 'Hello World')
@@ -1,26 +1,10 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Sample : put1() : Put a single message to a queue
19
3
  #
20
4
  # Set the correlation id to a text string
21
5
  #
22
6
  require 'rubygems'
23
- require 'wmq/wmq'
7
+ require 'wmq'
24
8
 
25
9
  WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
26
10
 
@@ -1,32 +1,16 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Sample : put() : Put a single request message to a queue
19
3
  #
20
4
  require 'rubygems'
21
- require 'wmq/wmq'
5
+ require 'wmq'
22
6
 
23
7
  WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
24
8
  message = WMQ::Message.new
25
9
  message.data = 'Hello World'
26
-
10
+
27
11
  message.descriptor = {
28
12
  :msg_type=> WMQ::MQMT_REQUEST,
29
13
  :reply_to_q=>'TEST.REPLY.QUEUE'}
30
-
14
+
31
15
  qmgr.put(:q_name=>'TEST.QUEUE', :message => message)
32
16
  end
@@ -1,25 +1,9 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Sample : put() : Put a single message to a queue
19
3
  # Open the queue so that multiple puts can be performed
20
4
  #
21
5
  require 'rubygems'
22
- require 'wmq/wmq'
6
+ require 'wmq'
23
7
 
24
8
  WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
25
9
  qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
@@ -1,26 +1,10 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Sample : put() : Put two Messages to a queue
19
3
  # Open the queue so that multiple puts can be performed
20
4
  # Ensure that all messages have the same correlation id
21
5
  #
22
6
  require 'rubygems'
23
- require 'wmq/wmq'
7
+ require 'wmq'
24
8
 
25
9
  WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
26
10
  qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
@@ -1,40 +1,24 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Sample : put() : Put a message to a queue with a dead letter header
19
3
  # Open the queue so that multiple puts can be performed
20
4
  #
21
5
  require 'rubygems'
22
- require 'wmq/wmq'
6
+ require 'wmq'
23
7
 
24
8
  WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
25
9
  qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
26
10
  message = WMQ::Message.new
27
11
  message.data = 'Hello World'
28
-
12
+
29
13
  message.headers = [
30
14
  {:header_type =>:dead_letter_header,
31
15
  :reason => WMQ::MQRC_UNKNOWN_REMOTE_Q_MGR,
32
16
  :dest_q_name =>'ORIGINAL_QUEUE_NAME',
33
17
  :dest_q_mgr_name =>'BAD_Q_MGR'}
34
18
  ]
35
-
19
+
36
20
  message.descriptor[:format] = WMQ::MQFMT_STRING
37
-
21
+
38
22
  queue.put(:message=>message)
39
23
  end
40
24
  end
@@ -1,19 +1,3 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Sample : put() : Put a single message to a queue
19
3
  # Create the queue if it does not already exist
@@ -26,7 +10,7 @@
26
10
  # In this sample the queue will disappear when this program terminates
27
11
  #
28
12
  require 'rubygems'
29
- require 'wmq/wmq'
13
+ require 'wmq'
30
14
 
31
15
  WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
32
16
  qmgr.open_queue(:q_name => 'SYSTEM.DEFAULT.MODEL.QUEUE',
@@ -1,19 +1,3 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Sample : put() : Put multiple Messages to a queue under the same group Id
19
3
  # Open the queue so that multiple puts can be performed
@@ -22,7 +6,7 @@
22
6
  # assign message sequence numbers for each message in the group
23
7
  #
24
8
  require 'rubygems'
25
- require 'wmq/wmq'
9
+ require 'wmq'
26
10
 
27
11
  # Put 5 messages in a single group onto the queue
28
12
  total = 5
@@ -1,19 +1,3 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Sample : put() : Put multiple Messages to a queue under the same group Id
19
3
  # Open the queue so that multiple puts can be performed
@@ -22,7 +6,7 @@
22
6
  # We also have to supply the message sequence number which starts at 1
23
7
  #
24
8
  require 'rubygems'
25
- require 'wmq/wmq'
9
+ require 'wmq'
26
10
 
27
11
  # Put 5 messages in a single group onto the queue
28
12
  total = 5
@@ -1,30 +1,14 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Sample : put() : Put a message to a queue with a Refernce header
19
3
  # Open the queue so that multiple puts can be performed
20
4
  #
21
5
  require 'rubygems'
22
- require 'wmq/wmq'
6
+ require 'wmq'
23
7
 
24
8
  # The Rules Format header (MQRFH) allows a list of name value pairs to be sent along
25
9
  # with a WMQ message. These name value pairs are represented as follows on the "wire":
26
10
  # Name1 Value1 Name2 Value2 Name3 Value3
27
- #
11
+ #
28
12
  # Ruby WMQ converts the above string of data into a Ruby hash by
29
13
  # using the name as the key, as follows:
30
14
  # data = {
@@ -32,9 +16,9 @@ require 'wmq/wmq'
32
16
  # 'Name2' => 'Value2',
33
17
  # 'Name3' => 'Value3'
34
18
  # }
35
- #
19
+ #
36
20
  # Since a name can consist of any character except null, it is stored as a String
37
- #
21
+ #
38
22
  # Note: It is possible to send or receive the same Name with multiple values using an array.
39
23
  # E.g. Name1 Value1 Name2 Value2 Name1 Value3
40
24
  # Becomes:
@@ -42,25 +26,25 @@ require 'wmq/wmq'
42
26
  # 'Name1' => ['Value1', 'Value3'],
43
27
  # 'Name2' => 'Value2'
44
28
  # }
45
- #
29
+ #
46
30
  # Note: Since a Hash does not preserve order, reading a Rules Format Header and then writing
47
31
  # it out immediately again could result in re-ordering of the name value pairs.
48
- #
32
+ #
49
33
 
50
34
  WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
51
35
  qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
52
36
  message = WMQ::Message.new
53
37
  message.data = 'Hello World'
54
-
38
+
55
39
  message.headers = [
56
40
  {:header_type =>:rf_header,
57
- :name_value => {'name1' => 'value1',
58
- 'name2' => 'value2',
59
- 'name3' => ['value 3a', 'value 3b']}
41
+ :name_value => {'name1' => 'value1',
42
+ 'name2' => 'value2',
43
+ 'name3' => ['value 3a', 'value 3b']}
60
44
  }]
61
-
45
+
62
46
  message.descriptor[:format] = WMQ::MQFMT_STRING
63
-
47
+
64
48
  queue.put(:message=>message)
65
49
  end
66
50
  end
@@ -1,42 +1,26 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Sample : put() : Put a message to a queue with a Refernce header
19
3
  # Open the queue so that multiple puts can be performed
20
4
  #
21
5
  require 'rubygems'
22
- require 'wmq/wmq'
6
+ require 'wmq'
23
7
 
24
8
  # The Rules Format header2 (MQRFH2) allows a an XML-like string to be passed as a header
25
9
  # to the data.
26
- #
10
+ #
27
11
 
28
12
  WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
29
13
  qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
30
14
  message = WMQ::Message.new
31
15
  message.data = 'Hello World'
32
-
16
+
33
17
  message.headers = [
34
18
  {:header_type =>:rf_header_2,
35
19
  :xml => '<hello>to the world</hello>'
36
20
  }]
37
-
21
+
38
22
  message.descriptor[:format] = WMQ::MQFMT_STRING
39
-
23
+
40
24
  queue.put(:message=>message)
41
25
  end
42
26
  end
@@ -1,42 +1,26 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Sample : put() : Put a message to a queue with a Refernce header
19
3
  # Open the queue so that multiple puts can be performed
20
4
  #
21
5
  require 'rubygems'
22
- require 'wmq/wmq'
6
+ require 'wmq'
23
7
 
24
8
  # The Rules Format header2 (MQRFH2) allows a an XML-like string to be passed as a header
25
9
  # to the data.
26
- #
10
+ #
27
11
 
28
12
  WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
29
13
  qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
30
14
  message = WMQ::Message.new
31
15
  message.data = 'Hello World'
32
-
16
+
33
17
  message.headers = [
34
18
  {:header_type =>:rf_header_2,
35
19
  :xml => ['<hello>to the world</hello>', '<another>xml like string</another>'],
36
20
  }]
37
-
21
+
38
22
  message.descriptor[:format] = WMQ::MQFMT_STRING
39
-
23
+
40
24
  queue.put(:message=>message)
41
25
  end
42
26
  end
@@ -1,24 +1,8 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Sample : put() : Put a message to a queue with a Transmission header
19
3
  #
20
4
  require 'rubygems'
21
- require 'wmq/wmq'
5
+ require 'wmq'
22
6
 
23
7
  WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
24
8
  qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
@@ -26,7 +10,7 @@ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
26
10
  message.data = "Test message from 'LOCALQMS1'"
27
11
  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}
28
12
  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}]
29
-
13
+
30
14
  queue.put(:message=>message)
31
15
  end
32
16
  end
@@ -1,26 +1,10 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Example: q_to_files: Copy all messages in a queue to separate files in a directory
19
3
  #
20
4
  require 'rubygems'
21
5
  require 'find'
22
6
  require 'yaml'
23
- require 'wmq/wmq'
7
+ require 'wmq'
24
8
  require 'fileutils'
25
9
 
26
10
  # Call program passing environment name as first parameter
@@ -1,25 +1,9 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Sample : request.rb
19
- #
3
+ #
20
4
  # Sample program that demonstrates how to send a request message
21
5
  # and then block until the response is received from the server.
22
- #
6
+ #
23
7
  # A temporary Dynamic Reply To Queue is used with non-persistent messaging
24
8
  #
25
9
  require 'rubygems'
@@ -32,22 +16,22 @@ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
32
16
  :dynamic_q_name=> 'REQUEST.*',
33
17
  :mode => :input
34
18
  ) do |reply_queue|
35
-
19
+
36
20
  message = WMQ::Message.new()
37
21
  message.descriptor = { :msg_type => WMQ::MQMT_REQUEST,
38
22
  :reply_to_q => reply_queue.name,
39
23
  :reply_to_q_mgr=> qmgr.name,
40
24
  :format => WMQ::MQFMT_STRING,
41
25
  :expiry => wait_seconds*10} # Measured in tenths of a second
42
- message.data = 'Hello World'
43
-
26
+ message.data = 'Hello World'
27
+
44
28
  # Send request message
45
29
  qmgr.put(:q_name=>'TEST.QUEUE', :message=>message)
46
-
30
+
47
31
  # Copy outgoing Message id to correlation id
48
32
  message.descriptor[:correl_id]=message.descriptor[:msg_id]
49
33
 
50
- # Wait for reply
34
+ # Wait for reply
51
35
  # Only get the message that matches the correlation id set above
52
36
  if reply_queue.get(:wait=>wait_seconds*1000, :message=>message, :match=>WMQ::MQMO_MATCH_CORREL_ID)
53
37
  puts "Received:"
@@ -1,19 +1,3 @@
1
- ################################################################################
2
- # Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
1
  #
18
2
  # Sample : Sample program to show how to write a server side application
19
3
  #
@@ -25,9 +9,9 @@
25
9
  # prevent messages being if the program terminates unexpectedly
26
10
  # or an error occurrs.
27
11
  # Uses: :sync=>true
28
- # - Queue#each will backout any message changes if an excecption is raised
12
+ # - Queue#each will backout any message changes if an excecption is raised
29
13
  # but not handled within the each block
30
- #
14
+ #
31
15
  # A "well-behaved" WebSphere MQ application should adhere to the following rules:
32
16
  # - Perform puts and gets under synchpoint where applicable
33
17
  # - Only send replies to Request messages. No reply for Datagrams
@@ -36,10 +20,10 @@
36
20
  # - Remaining Expiry (Ideally deduct any processing time since get)
37
21
  # - Same priority as received message
38
22
  # - Same persistence as received message
39
- # - Adhere to the Report options supplied for message and correlation id's
23
+ # - Adhere to the Report options supplied for message and correlation id's
40
24
  # in reply message
41
25
  # - All headers must be returned on reply messages
42
- # - This allows the calling application to store state information
26
+ # - This allows the calling application to store state information
43
27
  # in these headers
44
28
  # - Unless of course if the relevant header is input only and used
45
29
  # for completing the request
@@ -49,7 +33,7 @@
49
33
  # must be sent back to the requesting application
50
34
  # - If the reply fails, it must be put to the dead letter queue
51
35
  # with the relevant dead letter header and reason
52
- #
36
+ #
53
37
  # Note: - It is not recommended to run server side MQ applications over a client
54
38
  # connection.
55
39
  # - Client connections require substantially more error handling.
@@ -63,27 +47,27 @@
63
47
  # - etc....
64
48
  #
65
49
  require 'rubygems'
66
- require 'wmq/wmq'
50
+ require 'wmq'
67
51
 
68
52
  WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
69
53
  qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:input) do |queue|
70
54
  queue.each(:wait=>60000, :sync=>true, :convert=>true) do |request|
71
55
  puts "Data Received:"
72
56
  puts request.data
73
-
57
+
74
58
  begin
75
59
  reply = WMQ::Message.new
76
60
  reply.data = 'Echo back:'+request.data
77
-
61
+
78
62
  qmgr.put_to_reply_q(:message=>reply,
79
63
  :request_message=>request, # Only replies if message type is request
80
64
  :sync=>true)
81
-
65
+
82
66
  rescue WMQ::WMQException => exc
83
67
  # Failed to send reply, put message to the Dead Letter Queue and add a dead letter header
84
68
  p exc
85
69
  puts "Failed to reply to sender, Put to dead letter queue"
86
- qmgr.put_to_dead_letter_q(:message=>request,
70
+ qmgr.put_to_dead_letter_q(:message=>request,
87
71
  :reason=>WMQ::MQRC_UNKNOWN_REMOTE_Q_MGR,
88
72
  :q_name=>queue.name,
89
73
  :sync=>true)
@@ -0,0 +1 @@
1
+ require 'wmq'
@@ -1,3 +1,3 @@
1
1
  module WMQ #:nodoc
2
- VERSION = "2.0.0.pre2"
2
+ VERSION = "2.0.0.pre3"
3
3
  end
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 2
7
7
  - 0
8
8
  - 0
9
- - pre2
10
- version: 2.0.0.pre2
9
+ - pre3
10
+ version: 2.0.0.pre3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Reid Morrison
@@ -79,6 +79,7 @@ files:
79
79
  - ext/wmq_mq_load.c
80
80
  - ext/wmq_queue.c
81
81
  - ext/wmq_queue_manager.c
82
+ - lib/rubywmq.rb
82
83
  - lib/wmq/message.rb
83
84
  - lib/wmq/queue_manager.rb
84
85
  - lib/wmq/version.rb