ferocia-rubywmq 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/.document +8 -0
  2. data/LICENSE +13 -0
  3. data/Manifest.txt +20 -0
  4. data/README +73 -0
  5. data/examples/each_a.rb +32 -0
  6. data/examples/each_b.rb +41 -0
  7. data/examples/each_header.rb +38 -0
  8. data/examples/files_to_q.cfg +24 -0
  9. data/examples/files_to_q.rb +47 -0
  10. data/examples/get_a.rb +35 -0
  11. data/examples/get_client.rb +51 -0
  12. data/examples/put1_a.rb +25 -0
  13. data/examples/put1_b.rb +33 -0
  14. data/examples/put1_c.rb +32 -0
  15. data/examples/put_a.rb +35 -0
  16. data/examples/put_b.rb +43 -0
  17. data/examples/put_dlh.rb +41 -0
  18. data/examples/put_dynamic_q.rb +38 -0
  19. data/examples/put_group_a.rb +51 -0
  20. data/examples/put_group_b.rb +53 -0
  21. data/examples/put_rfh.rb +67 -0
  22. data/examples/put_rfh2_a.rb +43 -0
  23. data/examples/put_rfh2_b.rb +43 -0
  24. data/examples/put_xmit_q.rb +33 -0
  25. data/examples/q_to_files.cfg +17 -0
  26. data/examples/q_to_files.rb +48 -0
  27. data/examples/request.rb +60 -0
  28. data/examples/server.rb +97 -0
  29. data/ext/build.bat +3 -0
  30. data/ext/build.sh +6 -0
  31. data/ext/decode_rfh.c +348 -0
  32. data/ext/decode_rfh.h +45 -0
  33. data/ext/extconf.rb +44 -0
  34. data/ext/extconf_client.rb +40 -0
  35. data/ext/generate/generate_const.rb +167 -0
  36. data/ext/generate/generate_reason.rb +246 -0
  37. data/ext/generate/generate_structs.rb +97 -0
  38. data/ext/generate/wmq_structs.erb +371 -0
  39. data/ext/lib/wmq_temp.rb +197 -0
  40. data/ext/wmq.c +93 -0
  41. data/ext/wmq.h +367 -0
  42. data/ext/wmq_message.c +671 -0
  43. data/ext/wmq_mq_load.c +217 -0
  44. data/ext/wmq_queue.c +1411 -0
  45. data/ext/wmq_queue_manager.c +1587 -0
  46. data/lib/wmq.rb +25 -0
  47. data/rubywmq.binary.gemspec +32 -0
  48. data/rubywmq.gemspec +33 -0
  49. data/tests/test.rb +328 -0
  50. metadata +124 -0
data/.document ADDED
@@ -0,0 +1,8 @@
1
+ ext/lib/wmq_const.rb
2
+ ext/wmq.c
3
+ ext/wmq_queue_manager.c
4
+ ext/wmq_message.c
5
+ ext/wmq_queue.c
6
+ ext/lib/wmq_const_admin.rb
7
+ ext/lib/wmq_temp.rb
8
+ README
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/Manifest.txt ADDED
@@ -0,0 +1,20 @@
1
+ .document
2
+ lib/wmq.rb
3
+ ext/lib/wmq_temp.rb
4
+ ext/decode_rfh.h
5
+ ext/decode_rfh.c
6
+ ext/wmq.h
7
+ ext/wmq.c
8
+ ext/wmq_message.c
9
+ ext/wmq_mq_load.c
10
+ ext/wmq_queue.c
11
+ ext/wmq_queue_manager.c
12
+ ext/extconf.rb
13
+ ext/extconf_client.rb
14
+ ext/build.bat
15
+ ext/build.sh
16
+ ext/generate/generate_const.rb
17
+ ext/generate/generate_reason.rb
18
+ ext/generate/generate_structs.rb
19
+ ext/generate/wmq_structs.erb
20
+ examples/files_to_q.cfg
data/README ADDED
@@ -0,0 +1,73 @@
1
+ == Description
2
+ rubywmq - RubyWMQ is a Ruby interface into WebSphere MQ, previously called MQSeries
3
+
4
+ == Synopsis
5
+ require 'wmq'
6
+
7
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
8
+ qmgr.put(:q_name=>'TEST.QUEUE', :data => 'Hello World')
9
+ end
10
+
11
+ == Building Ruby WMQ
12
+ Building Ruby WMQ on UNIX/Linux
13
+ -------------------------------
14
+ The following is required to build from source code
15
+ * A 'C' compiler
16
+ * The WebSphere MQ Software development toolkit
17
+
18
+ Extracting the source code package:
19
+ * unzip package.zip
20
+ * tar -xvf package.tar
21
+
22
+ cd ext/wmq
23
+ Edit the file build.sh and edit the location of WebSphere MQ (if not in /opt/mqm)
24
+ Also edit extconf.rb and extconf_client.rb with the location of WebSphere MQ (if not in /opt/mqm)
25
+
26
+ Run build.sh
27
+
28
+ For any questions, or to report build errors, submit a new Support Request:
29
+ http://rubywmq.rubyforge.org
30
+
31
+ Building Ruby WMQ on Windows
32
+ ----------------------------
33
+ The following is required to build from source code
34
+ * The Visual C++ 6.0 compiler
35
+ * The WebSphere MQ Software development toolkit
36
+
37
+ cd ext\wmq
38
+ Edit the file build.bat and edit the location of WebSphere MQ
39
+ (if not in C:\Program Files\IBM\WebSphere MQ)
40
+ and the location of Visual C++ 6 (if not C:\Program Files\Microsoft Visual Studio\VC98)
41
+ Also edit extconf.rb and extconf_client.rb with the location of WebSphere MQ (if not in C:\Program Files\IBM\WebSphere MQ)
42
+
43
+ Run build.bat
44
+
45
+ == Support
46
+ For any questions, or to report build errors, submit a new Support Request:
47
+ http://rubywmq.rubyforge.org
48
+
49
+ == Future Plans
50
+ Add more formatting option contants and related methods.
51
+
52
+ == License
53
+ Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
54
+
55
+ Licensed under the Apache License, Version 2.0 (the "License");
56
+ you may not use this file except in compliance with the License.
57
+ You may obtain a copy of the License at
58
+
59
+ http://www.apache.org/licenses/LICENSE-2.0
60
+
61
+ Unless required by applicable law or agreed to in writing, software
62
+ distributed under the License is distributed on an "AS IS" BASIS,
63
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
64
+ See the License for the specific language governing permissions and
65
+ limitations under the License.
66
+
67
+ == Copyright
68
+ (C) 2006 J. Reid Morrison. Dimension Solutions, Inc.
69
+ All Rights Reserved
70
+
71
+ == Author
72
+ Reid Morrison
73
+ rubywmq at gmail dot com
@@ -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 : each() : Retrieve all messages from a queue
19
+ # If no messages are on the queue, the program
20
+ # completes without waiting
21
+ #
22
+ require 'rubygems'
23
+ require 'wmq/wmq'
24
+
25
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
26
+ qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:input) do |queue|
27
+ queue.each do |message|
28
+ puts "Data Received: #{message.data}"
29
+ end
30
+ end
31
+ puts 'Completed.'
32
+ end
@@ -0,0 +1,41 @@
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 : each() : Retrieve all messages from a queue that
19
+ # have the same correlation id
20
+ #
21
+ require 'rubygems'
22
+ require 'wmq/wmq'
23
+
24
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
25
+ qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:input) do |queue|
26
+ message = WMQ::Message.new
27
+
28
+ # Retrieve First message
29
+ if queue.get(:message=>message)
30
+ puts "Data Received: #{message.data}"
31
+
32
+ #Retrieve all subsequent messages that have the same correlation id
33
+ queue.each(:message=>message, :match=>WMQ::MQMO_MATCH_CORREL_ID) do |msg|
34
+ puts "Matching Data Received: #{msg.data}"
35
+ end
36
+ else
37
+ puts 'No message available'
38
+ end
39
+ end
40
+ puts 'Completed.'
41
+ end
@@ -0,0 +1,38 @@
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 : each() : Retrieve all messages from a queue
19
+ # If no messages are on the queue, the program
20
+ # completes without waiting
21
+ #
22
+ require 'rubygems'
23
+ require 'wmq/wmq'
24
+
25
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
26
+ qmgr.open_queue(:q_name=>'TEST.DEAD', :mode=>:browse) do |queue|
27
+ queue.each do |message|
28
+ puts "Data Received: #{message.data}"
29
+
30
+ puts "Message Descriptor:"
31
+ p message.descriptor
32
+
33
+ puts "Headers Received:"
34
+ message.headers.each {|header| p header}
35
+ end
36
+ end
37
+ puts 'Completed.'
38
+ end
@@ -0,0 +1,24 @@
1
+ dev:
2
+ qmgr_options:
3
+ :q_mgr_name: REID
4
+ output_queue:
5
+ :q_name: TEST.QUEUE
6
+ put_options:
7
+ :new_msg_id: true
8
+ descriptor:
9
+ :format: MQSTR
10
+ source_directory: messages
11
+
12
+ test:
13
+ qmgr_options:
14
+ :q_mgr_name: TEST.QMGR
15
+ :channel_name: SYSTEM.DEF.SVRCONN
16
+ :connection_name: remotehost(1414)
17
+ output_queue:
18
+ :q_name: TEST.QUEUE
19
+ put_options:
20
+ :new_msg_id: true
21
+ descriptor:
22
+ :format: MQSTR
23
+ source_directory: messages
24
+
@@ -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 : files_to_q : Place all files in a directory to a queue
19
+ # Each file is written as a separate message
20
+ #
21
+ require 'rubygems'
22
+ require 'find'
23
+ require 'yaml'
24
+ require 'wmq/wmq'
25
+
26
+ # Call program passing environment name as first parameter
27
+ # The environment corresponds to an entry in the config file
28
+ env = ARGV[0] || raise("Command line argument 'environment' is required")
29
+ config = YAML::load_file('files_to_q.cfg')[env]
30
+
31
+ message = WMQ::Message.new
32
+ message.descriptor = config['descriptor'] || {}
33
+ tstart = Time.now
34
+ counter = 0
35
+ WMQ::QueueManager.connect(config['qmgr_options']) do |qmgr|
36
+ qmgr.open_queue({:mode=>:output}.merge(config['output_queue'])) do |queue|
37
+ Find.find(config['source_directory']) do |path|
38
+ unless FileTest.directory?(path)
39
+ printf("%5d: #{path}\n",counter = counter + 1)
40
+ message.data = File.read(path)
41
+ queue.put({:message => message}.merge(config['put_options']))
42
+ end
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
data/examples/get_a.rb ADDED
@@ -0,0 +1,35 @@
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
+ require 'rubygems'
22
+ require 'wmq/wmq'
23
+
24
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
25
+ qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:input) do |queue|
26
+
27
+ message = WMQ::Message.new
28
+ if queue.get(:message => message)
29
+ puts "Data Received: #{message.data}"
30
+ else
31
+ puts 'No message available'
32
+ end
33
+ end
34
+ end
35
+
@@ -0,0 +1,51 @@
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 'rubygems'
28
+ require 'wmq/wmq'
29
+
30
+ WMQ::QueueManager.connect(
31
+ :connection_name => 'localhost(1414)', # Use MQ Client Library
32
+ :channel_name => 'SYSTEM.DEF.SVRCONN', # Optional, since this is the default value
33
+ :transport_type => WMQ::MQXPT_TCP # Optional, since this is the default value
34
+ ) do |qmgr|
35
+ qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:input) do |queue|
36
+
37
+ message = WMQ::Message.new
38
+ if queue.get(:message => message)
39
+ puts "Data Received: #{message.data}"
40
+
41
+ puts "Message Descriptor:"
42
+ p message.descriptor
43
+
44
+ puts "Headers Received:"
45
+ message.headers.each {|header| p header}
46
+ else
47
+ puts 'No message available'
48
+ end
49
+ end
50
+ end
51
+
@@ -0,0 +1,25 @@
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 'rubygems'
21
+ require 'wmq/wmq'
22
+
23
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
24
+ qmgr.put(:q_name=>'TEST.QUEUE', :data => 'Hello World')
25
+ end
@@ -0,0 +1,33 @@
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 'rubygems'
23
+ require 'wmq/wmq'
24
+
25
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
26
+
27
+ message = WMQ::Message.new
28
+ message.data = 'Hello World'
29
+ message.descriptor[:correl_id] = 'My first message'
30
+
31
+ qmgr.put(:q_name=>'TEST.QUEUE', :message=>message)
32
+ end
33
+
@@ -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 single request message to a queue
19
+ #
20
+ require 'rubygems'
21
+ require 'wmq/wmq'
22
+
23
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
24
+ message = WMQ::Message.new
25
+ message.data = 'Hello World'
26
+
27
+ message.descriptor = {
28
+ :msg_type=> WMQ::MQMT_REQUEST,
29
+ :reply_to_q=>'TEST.REPLY.QUEUE'}
30
+
31
+ qmgr.put(:q_name=>'TEST.QUEUE', :message => message)
32
+ end
data/examples/put_a.rb ADDED
@@ -0,0 +1,35 @@
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 'rubygems'
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
+ # First message
28
+ queue.put(:data => 'Hello World')
29
+
30
+ # Second message
31
+ # This message will have new message and correlation id's
32
+ queue.put(:data => 'Hello Again')
33
+ end
34
+ end
35
+
data/examples/put_b.rb ADDED
@@ -0,0 +1,43 @@
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 'rubygems'
23
+ require 'wmq/wmq'
24
+
25
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
26
+ qmgr.open_queue(:q_name=>'TEST.QUEUE', :mode=>:output) do |queue|
27
+
28
+ message = WMQ::Message.new
29
+
30
+ # First message
31
+ # Results in a WMQ generated msg_id and empty correl_id
32
+ message.data = 'Hello World'
33
+ queue.put(:message => message)
34
+
35
+ # Second message
36
+ # new_msg_id will cause the second message to have a new message id
37
+ # otherwise both messages will have the same message and correlation id's
38
+ # This message will have the same correlation id as the first message (empty)
39
+ message.data = 'Hello Again'
40
+ p message.descriptor
41
+ queue.put(:message => message, :new_msg_id => true)
42
+ end
43
+ end
@@ -0,0 +1,41 @@
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 'rubygems'
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
+ message = WMQ::Message.new
27
+ message.data = 'Hello World'
28
+
29
+ message.headers = [
30
+ {:header_type =>:dead_letter_header,
31
+ :reason => WMQ::MQRC_UNKNOWN_REMOTE_Q_MGR,
32
+ :dest_q_name =>'ORIGINAL_QUEUE_NAME',
33
+ :dest_q_mgr_name =>'BAD_Q_MGR'}
34
+ ]
35
+
36
+ message.descriptor[:format] = WMQ::MQFMT_STRING
37
+
38
+ queue.put(:message=>message)
39
+ end
40
+ end
41
+
@@ -0,0 +1,38 @@
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 'rubygems'
29
+ require 'wmq/wmq'
30
+
31
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
32
+ qmgr.open_queue(:q_name => 'SYSTEM.DEFAULT.MODEL.QUEUE',
33
+ :dynamic_q_name => 'TEST.QUEUE.SAMPLE',
34
+ :mode => :output
35
+ ) do |queue|
36
+ queue.put(:data => 'Hello World')
37
+ end
38
+ end