rubywmq 0.3.0-i386-mswin32-mq5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/LICENSE +13 -0
  2. data/README +73 -0
  3. data/doc/classes/WMQ/Message.html +376 -0
  4. data/doc/classes/WMQ/Message.src/M000001.html +77 -0
  5. data/doc/classes/WMQ/Message.src/M000002.html +27 -0
  6. data/doc/classes/WMQ/Queue.html +1459 -0
  7. data/doc/classes/WMQ/Queue.src/M000003.html +205 -0
  8. data/doc/classes/WMQ/Queue.src/M000004.html +107 -0
  9. data/doc/classes/WMQ/Queue.src/M000005.html +198 -0
  10. data/doc/classes/WMQ/Queue.src/M000006.html +66 -0
  11. data/doc/classes/WMQ/Queue.src/M000007.html +203 -0
  12. data/doc/classes/WMQ/Queue.src/M000008.html +265 -0
  13. data/doc/classes/WMQ/Queue.src/M000009.html +120 -0
  14. data/doc/classes/WMQ/Queue.src/M000010.html +28 -0
  15. data/doc/classes/WMQ/Queue.src/M000011.html +30 -0
  16. data/doc/classes/WMQ/Queue.src/M000012.html +31 -0
  17. data/doc/classes/WMQ/Queue.src/M000013.html +31 -0
  18. data/doc/classes/WMQ/Queue.src/M000014.html +31 -0
  19. data/doc/classes/WMQ/QueueManager.html +1529 -0
  20. data/doc/classes/WMQ/QueueManager.src/M000015.html +182 -0
  21. data/doc/classes/WMQ/QueueManager.src/M000016.html +194 -0
  22. data/doc/classes/WMQ/QueueManager.src/M000017.html +92 -0
  23. data/doc/classes/WMQ/QueueManager.src/M000018.html +70 -0
  24. data/doc/classes/WMQ/QueueManager.src/M000019.html +49 -0
  25. data/doc/classes/WMQ/QueueManager.src/M000020.html +49 -0
  26. data/doc/classes/WMQ/QueueManager.src/M000021.html +63 -0
  27. data/doc/classes/WMQ/QueueManager.src/M000022.html +61 -0
  28. data/doc/classes/WMQ/QueueManager.src/M000023.html +65 -0
  29. data/doc/classes/WMQ/QueueManager.src/M000024.html +232 -0
  30. data/doc/classes/WMQ/QueueManager.src/M000025.html +30 -0
  31. data/doc/classes/WMQ/QueueManager.src/M000026.html +31 -0
  32. data/doc/classes/WMQ/QueueManager.src/M000027.html +31 -0
  33. data/doc/classes/WMQ/QueueManager.src/M000028.html +38 -0
  34. data/doc/classes/WMQ/QueueManager.src/M000029.html +33 -0
  35. data/doc/classes/WMQ/QueueManager.src/M000030.html +21 -0
  36. data/doc/classes/WMQ/QueueManager.src/M000031.html +284 -0
  37. data/doc/classes/WMQ/QueueManager.src/M000032.html +24 -0
  38. data/doc/classes/WMQ/QueueManager.src/M000033.html +18 -0
  39. data/doc/classes/WMQ/QueueManager.src/M000034.html +46 -0
  40. data/doc/classes/WMQ/QueueManager.src/M000035.html +27 -0
  41. data/doc/classes/WMQ/WMQException.html +111 -0
  42. data/doc/classes/WMQ.html +6300 -0
  43. data/doc/created.rid +1 -0
  44. data/doc/files/ext/lib/wmq_const_admin_rb.html +128 -0
  45. data/doc/files/ext/lib/wmq_const_rb.html +128 -0
  46. data/doc/files/ext/lib/wmq_temp_rb.html +122 -0
  47. data/doc/files/ext/wmq_c.html +101 -0
  48. data/doc/files/ext/wmq_message_c.html +101 -0
  49. data/doc/files/ext/wmq_queue_c.html +101 -0
  50. data/doc/files/ext/wmq_queue_manager_c.html +101 -0
  51. data/doc/fr_class_index.html +31 -0
  52. data/doc/fr_file_index.html +33 -0
  53. data/doc/fr_method_index.html +61 -0
  54. data/doc/index.html +24 -0
  55. data/doc/rdoc-style.css +208 -0
  56. data/examples/each_a.rb +31 -0
  57. data/examples/each_b.rb +40 -0
  58. data/examples/each_header.rb +37 -0
  59. data/examples/files_to_q.cfg +24 -0
  60. data/examples/files_to_q.rb +46 -0
  61. data/examples/get_a.rb +34 -0
  62. data/examples/get_client.rb +50 -0
  63. data/examples/put1_a.rb +24 -0
  64. data/examples/put1_b.rb +32 -0
  65. data/examples/put1_c.rb +31 -0
  66. data/examples/put_a.rb +34 -0
  67. data/examples/put_b.rb +42 -0
  68. data/examples/put_dlh.rb +40 -0
  69. data/examples/put_dynamic_q.rb +37 -0
  70. data/examples/put_rfh.rb +66 -0
  71. data/examples/put_rfh2_a.rb +42 -0
  72. data/examples/put_rfh2_b.rb +42 -0
  73. data/examples/put_xmit_q.rb +32 -0
  74. data/examples/q_to_files.cfg +17 -0
  75. data/examples/q_to_files.rb +47 -0
  76. data/examples/request.rb +59 -0
  77. data/examples/server.rb +96 -0
  78. data/lib/wmq/wmq.so +0 -0
  79. data/lib/wmq/wmq_const.rb +697 -0
  80. data/lib/wmq/wmq_const_admin.rb +273 -0
  81. data/lib/wmq/wmq_temp.rb +197 -0
  82. data/lib/wmq.rb +25 -0
  83. data/tests/test.rb +299 -0
  84. metadata +131 -0
@@ -0,0 +1,50 @@
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
+ #
18
+ # Sample : get() : Retrieve a single message from a queue
19
+ # If no messages are on the queue, message.data is nil
20
+ #
21
+ # The Client connection is determined by the :connection_name parameter supplied
22
+ # to QueueManager::connect or QueueManager::new
23
+ #
24
+ # If :connection_name is not present, a WebSphere MQ Server connection will be used
25
+ # I.e. Local server connection
26
+ #
27
+ require 'wmq/wmq'
28
+
29
+ WMQ::QueueManager.connect(
30
+ :connection_name => 'localhost(1414)', # Use MQ Client Library
31
+ :channel_name => 'SYSTEM.DEF.SVRCONN', # Optional, since this is the default value
32
+ :transport_type => WMQ::MQXPT_TCP # Optional, since this is the default value
33
+ ) do |qmgr|
34
+ qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:input) do |queue|
35
+
36
+ message = WMQ::Message.new
37
+ if queue.get(:message => message)
38
+ puts "Data Received: #{message.data}"
39
+
40
+ puts "Message Descriptor:"
41
+ p message.descriptor
42
+
43
+ puts "Headers Received:"
44
+ message.headers.each {|header| p header}
45
+ else
46
+ puts 'No message available'
47
+ end
48
+ end
49
+ end
50
+
@@ -0,0 +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
+ #
18
+ # Sample : put1() : Put a single message to a queue
19
+ #
20
+ require 'wmq/wmq'
21
+
22
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
23
+ qmgr.put(:q_name=>'TEST.QUEUE', :data => 'Hello World')
24
+ end
@@ -0,0 +1,32 @@
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
+ #
18
+ # Sample : put1() : Put a single message to a queue
19
+ #
20
+ # Set the correlation id to a text string
21
+ #
22
+ require 'wmq/wmq'
23
+
24
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
25
+
26
+ message = WMQ::Message.new
27
+ message.data = 'Hello World'
28
+ message.descriptor[:correl_id] = 'My first message'
29
+
30
+ qmgr.put(:q_name=>'TEST.QUEUE', :message=>message)
31
+ end
32
+
@@ -0,0 +1,31 @@
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
+ #
18
+ # Sample : put() : Put a single request message to a queue
19
+ #
20
+ require 'wmq/wmq'
21
+
22
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
23
+ message = WMQ::Message.new
24
+ message.data = 'Hello World'
25
+
26
+ message.descriptor = {
27
+ :msg_type=> WMQ::MQMT_REQUEST,
28
+ :reply_to_q=>'TEST.REPLY.QUEUE'}
29
+
30
+ qmgr.put(:q_name=>'TEST.QUEUE', :message => message)
31
+ end
data/examples/put_a.rb ADDED
@@ -0,0 +1,34 @@
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
+ #
18
+ # Sample : put() : Put a single message to a queue
19
+ # Open the queue so that multiple puts can be performed
20
+ #
21
+ require 'wmq/wmq'
22
+
23
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
24
+ qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
25
+
26
+ # First message
27
+ queue.put(:data => 'Hello World')
28
+
29
+ # Second message
30
+ # This message will have new message and correlation id's
31
+ queue.put(:data => 'Hello Again')
32
+ end
33
+ end
34
+
data/examples/put_b.rb ADDED
@@ -0,0 +1,42 @@
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
+ #
18
+ # Sample : put() : Put two Messages to a queue
19
+ # Open the queue so that multiple puts can be performed
20
+ # Ensure that all messages have the same correlation id
21
+ #
22
+ require 'wmq/wmq'
23
+
24
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
25
+ qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
26
+
27
+ message = WMQ::Message.new
28
+
29
+ # First message
30
+ # Results in a WMQ generated msg_id and empty correl_id
31
+ message.data = 'Hello World'
32
+ queue.put(:message => message)
33
+
34
+ # Second message
35
+ # new_msg_id will cause the second message to have a new message id
36
+ # otherwise both messages will have the same message and correlation id's
37
+ # This message will have the same correlation id as the first message (empty)
38
+ message.data = 'Hello Again'
39
+ p message.descriptor
40
+ queue.put(:message => message, :new_msg_id => true)
41
+ end
42
+ end
@@ -0,0 +1,40 @@
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
+ #
18
+ # Sample : put() : Put a message to a queue with a dead letter header
19
+ # Open the queue so that multiple puts can be performed
20
+ #
21
+ require 'wmq/wmq'
22
+
23
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
24
+ qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
25
+ message = WMQ::Message.new
26
+ message.data = 'Hello World'
27
+
28
+ message.headers = [
29
+ {:header_type =>:dead_letter_header,
30
+ :reason => WMQ::MQRC_UNKNOWN_REMOTE_Q_MGR,
31
+ :dest_q_name =>'ORIGINAL_QUEUE_NAME',
32
+ :dest_q_mgr_name =>'BAD_Q_MGR'}
33
+ ]
34
+
35
+ message.descriptor[:format] = WMQ::MQFMT_STRING
36
+
37
+ queue.put(:message=>message)
38
+ end
39
+ end
40
+
@@ -0,0 +1,37 @@
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
+ #
18
+ # Sample : put() : Put a single message to a queue
19
+ # Create the queue if it does not already exist
20
+ #
21
+ # Note : The queue name is that of the model queue
22
+ # The dynamic_q_name is the actual queue name
23
+ #
24
+ # This sample is more usefull if the model queue was a Permanent Dynamic one.
25
+ # That way the queue would remain after termination of this code.
26
+ # In this sample the queue will disappear when this program terminates
27
+ #
28
+ require 'wmq/wmq'
29
+
30
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
31
+ qmgr.open_queue(:q_name => 'SYSTEM.DEFAULT.MODEL.QUEUE',
32
+ :dynamic_q_name => 'TEST.QUEUE.SAMPLE',
33
+ :mode => :output
34
+ ) do |queue|
35
+ queue.put(:data => 'Hello World')
36
+ end
37
+ end
@@ -0,0 +1,66 @@
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
+ #
18
+ # Sample : put() : Put a message to a queue with a Refernce header
19
+ # Open the queue so that multiple puts can be performed
20
+ #
21
+ require 'wmq/wmq'
22
+
23
+ # The Rules Format header (MQRFH) allows a list of name value pairs to be sent along
24
+ # with a WMQ message. These name value pairs are represented as follows on the "wire":
25
+ # Name1 Value1 Name2 Value2 Name3 Value3
26
+ #
27
+ # Ruby WMQ converts the above string of data into a Ruby hash by
28
+ # using the name as the key, as follows:
29
+ # data = {
30
+ # 'Name1' => 'Value1',
31
+ # 'Name2' => 'Value2',
32
+ # 'Name3' => 'Value3'
33
+ # }
34
+ #
35
+ # Since a name can consist of any character except null, it is stored as a String
36
+ #
37
+ # Note: It is possible to send or receive the same Name with multiple values using an array.
38
+ # E.g. Name1 Value1 Name2 Value2 Name1 Value3
39
+ # Becomes:
40
+ # data = {
41
+ # 'Name1' => ['Value1', 'Value3'],
42
+ # 'Name2' => 'Value2'
43
+ # }
44
+ #
45
+ # Note: Since a Hash does not preserve order, reading a Rules Format Header and then writing
46
+ # it out immediately again could result in re-ordering of the name value pairs.
47
+ #
48
+
49
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
50
+ qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
51
+ message = WMQ::Message.new
52
+ message.data = 'Hello World'
53
+
54
+ message.headers = [
55
+ {:header_type =>:rf_header,
56
+ :name_value => {'name1' => 'value1',
57
+ 'name2' => 'value2',
58
+ 'name3' => ['value 3a', 'value 3b']}
59
+ }]
60
+
61
+ message.descriptor[:format] = WMQ::MQFMT_STRING
62
+
63
+ queue.put(:message=>message)
64
+ end
65
+ end
66
+
@@ -0,0 +1,42 @@
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
+ #
18
+ # Sample : put() : Put a message to a queue with a Refernce header
19
+ # Open the queue so that multiple puts can be performed
20
+ #
21
+ require 'wmq/wmq'
22
+
23
+ # The Rules Format header2 (MQRFH2) allows a an XML-like string to be passed as a header
24
+ # to the data.
25
+ #
26
+
27
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
28
+ qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
29
+ message = WMQ::Message.new
30
+ message.data = 'Hello World'
31
+
32
+ message.headers = [
33
+ {:header_type =>:rf_header_2,
34
+ :xml => '<hello>to the world</hello>'
35
+ }]
36
+
37
+ message.descriptor[:format] = WMQ::MQFMT_STRING
38
+
39
+ queue.put(:message=>message)
40
+ end
41
+ end
42
+
@@ -0,0 +1,42 @@
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
+ #
18
+ # Sample : put() : Put a message to a queue with a Refernce header
19
+ # Open the queue so that multiple puts can be performed
20
+ #
21
+ require 'wmq/wmq'
22
+
23
+ # The Rules Format header2 (MQRFH2) allows a an XML-like string to be passed as a header
24
+ # to the data.
25
+ #
26
+
27
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
28
+ qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
29
+ message = WMQ::Message.new
30
+ message.data = 'Hello World'
31
+
32
+ message.headers = [
33
+ {:header_type =>:rf_header_2,
34
+ :xml => ['<hello>to the world</hello>', '<another>xml like string</another>'],
35
+ }]
36
+
37
+ message.descriptor[:format] = WMQ::MQFMT_STRING
38
+
39
+ queue.put(:message=>message)
40
+ end
41
+ end
42
+
@@ -0,0 +1,32 @@
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
+ #
18
+ # Sample : put() : Put a message to a queue with a Transmission header
19
+ #
20
+ require 'wmq/wmq'
21
+
22
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
23
+ qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
24
+ message = WMQ::Message.new
25
+ message.data = "Test message from 'LOCALQMS1'"
26
+ 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}
27
+ 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}]
28
+
29
+ queue.put(:message=>message)
30
+ end
31
+ end
32
+
@@ -0,0 +1,17 @@
1
+ dev:
2
+ qmgr_options:
3
+ :q_mgr_name: REID
4
+ input_queue:
5
+ :mode: :browse
6
+ :q_name: TEST.QUEUE
7
+ target_directory: messages
8
+
9
+ test:
10
+ qmgr_options:
11
+ :q_mgr_name: TEST.QMGR
12
+ :channel_name: SYSTEM.DEF.SVRCONN
13
+ :connection_name: remotehost(1414)
14
+ input_queue:
15
+ :mode: :browse
16
+ :q_name: TEST.QUEUE
17
+ target_directory: messages
@@ -0,0 +1,47 @@
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
+ #
18
+ # Example: q_to_files: Copy all messages in a queue to separate files in a directory
19
+ #
20
+ require 'find'
21
+ require 'yaml'
22
+ require 'wmq/wmq'
23
+ require 'fileutils'
24
+
25
+ # Call program passing environment name as first parameter
26
+ # The environment corresponds to an entry in the config file
27
+ env = ARGV[0] || raise("Command line argument 'environment' is required")
28
+ config = YAML::load_file('q_to_files.cfg')[env]
29
+
30
+ # Create supplied path if it does not exist
31
+ path = config['target_directory']
32
+ FileUtils.mkdir_p(path)
33
+
34
+ message = WMQ::Message.new
35
+ message.descriptor = config['descriptor'] || {}
36
+ tstart = Time.now
37
+ counter = 0
38
+ WMQ::QueueManager.connect(config['qmgr_options']) do |qmgr|
39
+ qmgr.open_queue(config['input_queue']) do |queue|
40
+ queue.each do |message|
41
+ counter = counter + 1
42
+ File.open(File.join(path, "message_%03d" % counter), 'w') {|file| file.write(message.data) }
43
+ end
44
+ end
45
+ end
46
+ duration = Time.now - tstart
47
+ printf "Processed #{counter} messages in %.3f seconds. Average: %.3f messages/second\n", duration, counter/duration
@@ -0,0 +1,59 @@
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
+ #
18
+ # Sample : request.rb
19
+ #
20
+ # Sample program that demonstrates how to send a request message
21
+ # and then block until the response is received from the server.
22
+ #
23
+ # A temporary Dynamic Reply To Queue is used with non-persistent messaging
24
+ #
25
+ require 'wmq'
26
+
27
+ wait_seconds = 30
28
+
29
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
30
+ qmgr.open_queue(:q_name => 'SYSTEM.DEFAULT.MODEL.QUEUE',
31
+ :dynamic_q_name=> 'REQUEST.*',
32
+ :mode => :input
33
+ ) do |reply_queue|
34
+
35
+ message = WMQ::Message.new()
36
+ message.descriptor = { :msg_type => WMQ::MQMT_REQUEST,
37
+ :reply_to_q => reply_queue.name,
38
+ :reply_to_q_mgr=> qmgr.name,
39
+ :format => WMQ::MQFMT_STRING,
40
+ :expiry => wait_seconds*10} # Measured in tenths of a second
41
+ message.data = 'Hello World'
42
+
43
+ # Send request message
44
+ qmgr.put(:q_name=>'TEST.QUEUE', :message=>message)
45
+
46
+ # Copy outgoing Message id to correlation id
47
+ message.descriptor[:correl_id]=message.descriptor[:msg_id]
48
+
49
+ # Wait for reply
50
+ # Only get the message that matches the correlation id set above
51
+ if reply_queue.get(:wait=>wait_seconds*1000, :message=>message, :match=>WMQ::MQMO_MATCH_CORREL_ID)
52
+ puts "Received:"
53
+ puts message.data
54
+ else
55
+ # get returns false when no message received. Also: message.data = nil
56
+ puts "Timed Out waiting for a reply from the server"
57
+ end
58
+ end
59
+ end