rubywmq 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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/README ADDED
@@ -0,0 +1,73 @@
1
+ == Description
2
+ rubywmq - Ruby WMQ 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,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 : each() : Retrieve all messages from a queue
19
+ # If no messages are on the queue, the program
20
+ # completes without waiting
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=>:input) do |queue|
26
+ queue.each do |message|
27
+ puts "Data Received: #{message.data}"
28
+ end
29
+ end
30
+ puts 'Completed.'
31
+ 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 : each() : Retrieve all messages from a queue that
19
+ # have the same correlation id
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=>:input) do |queue|
25
+ message = WMQ::Message.new
26
+
27
+ # Retrieve First message
28
+ if queue.get(:message=>message)
29
+ puts "Data Received: #{message.data}"
30
+
31
+ #Retrieve all subsequent messages that have the same correlation id
32
+ queue.each(:message=>message, :match=>WMQ::MQMO_MATCH_CORREL_ID) do |msg|
33
+ puts "Matching Data Received: #{msg.data}"
34
+ end
35
+ else
36
+ puts 'No message available'
37
+ end
38
+ end
39
+ puts 'Completed.'
40
+ end
@@ -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 : each() : Retrieve all messages from a queue
19
+ # If no messages are on the queue, the program
20
+ # completes without waiting
21
+ #
22
+ require 'wmq/wmq'
23
+
24
+ WMQ::QueueManager.connect(:q_mgr_name=>'REID') do |qmgr|
25
+ qmgr.open_queue(:q_name=>'TEST.DEAD', :mode=>:browse) do |queue|
26
+ queue.each do |message|
27
+ puts "Data Received: #{message.data}"
28
+
29
+ puts "Message Descriptor:"
30
+ p message.descriptor
31
+
32
+ puts "Headers Received:"
33
+ message.headers.each {|header| p header}
34
+ end
35
+ end
36
+ puts 'Completed.'
37
+ end
@@ -0,0 +1,24 @@
1
+ dev:
2
+ qmgr_options:
3
+ :q_mgr_name: REID
4
+ output_queue:
5
+ :q_name: TEST.DEAD.BACKUP
6
+ put_options:
7
+ :new_msg_id: true
8
+ descriptor:
9
+ :format: MQSTR
10
+ source_directory: samples
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.DEAD.BACKUP
19
+ put_options:
20
+ :new_msg_id: true
21
+ descriptor:
22
+ :format: MQSTR
23
+ source_directory: samples
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
+ # Sample : files_to_q : Place all files in a directory to a queue
19
+ # Each file is written as a separate message
20
+ #
21
+ require 'find'
22
+ require 'yaml'
23
+ require 'wmq/wmq'
24
+
25
+ # Call program passing environment name as first parameter
26
+ # The environment corresponds to an entry in the config file
27
+ # Defaults to dev
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
@@ -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 : get() : Retrieve a single message from a queue
19
+ # If no messages are on the queue, message.data is nil
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=>:input) do |queue|
25
+
26
+ message = WMQ::Message.new
27
+ if queue.get(:message => message)
28
+ puts "Data Received: #{message.data}"
29
+ else
30
+ puts 'No message available'
31
+ end
32
+ end
33
+ end
34
+
@@ -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