ferocia-rubywmq 1.1.3 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/.document +0 -4
  2. data/LICENSE.txt +201 -0
  3. data/README.md +408 -0
  4. data/Rakefile +91 -0
  5. data/examples/each_a.rb +1 -17
  6. data/examples/each_b.rb +1 -17
  7. data/examples/each_header.rb +3 -19
  8. data/examples/files_to_q.rb +1 -17
  9. data/examples/get_a.rb +1 -17
  10. data/examples/get_client.rb +5 -21
  11. data/examples/put1_a.rb +1 -17
  12. data/examples/put1_b.rb +1 -17
  13. data/examples/put1_c.rb +3 -19
  14. data/examples/put_a.rb +1 -17
  15. data/examples/put_b.rb +1 -17
  16. data/examples/put_dlh.rb +4 -20
  17. data/examples/put_dynamic_q.rb +1 -17
  18. data/examples/put_group_a.rb +1 -17
  19. data/examples/put_group_b.rb +1 -17
  20. data/examples/put_rfh.rb +12 -28
  21. data/examples/put_rfh2_a.rb +5 -21
  22. data/examples/put_rfh2_b.rb +5 -21
  23. data/examples/put_xmit_q.rb +2 -18
  24. data/examples/q_to_files.rb +1 -17
  25. data/examples/request.rb +7 -23
  26. data/examples/server.rb +10 -26
  27. data/ext/extconf.rb +26 -46
  28. data/ext/extconf_client.rb +3 -19
  29. data/ext/generate/generate_const.rb +16 -43
  30. data/ext/generate/generate_reason.rb +23 -36
  31. data/ext/generate/generate_structs.rb +7 -22
  32. data/ext/generate/wmq_structs.erb +28 -58
  33. data/ext/wmq.c +1 -4
  34. data/ext/wmq.h +5 -1
  35. data/ext/wmq_message.c +1 -1
  36. data/ext/wmq_mq_load.c +1 -1
  37. data/ext/wmq_queue.c +1 -1
  38. data/ext/wmq_queue_manager.c +3 -3
  39. data/lib/rubywmq.rb +1 -0
  40. data/lib/wmq.rb +13 -26
  41. data/lib/wmq/message.rb +70 -0
  42. data/{ext/lib/wmq_temp.rb → lib/wmq/queue_manager.rb} +11 -98
  43. data/lib/wmq/version.rb +3 -0
  44. data/tests/test.rb +30 -40
  45. metadata +10 -20
  46. data/LICENSE +0 -13
  47. data/Manifest.txt +0 -20
  48. data/README +0 -73
  49. data/ext/build.bat +0 -3
  50. data/ext/build.sh +0 -6
  51. data/rubywmq.binary.gemspec +0 -32
  52. data/rubywmq.gemspec +0 -33
@@ -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
data/examples/put_rfh.rb CHANGED
@@ -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
data/examples/request.rb CHANGED
@@ -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:"
data/examples/server.rb CHANGED
@@ -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)