rubywmq 1.1.1 → 2.0.0.pre

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.
data/ext/wmq.c CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
2
+ * Copyright 2006 J. Reid Morrison
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -80,9 +80,6 @@ void Init_wmq() {
80
80
  QueueManager_selector_id_init();
81
81
  QueueManager_command_id_init();
82
82
  wmq_structs_id_init();
83
-
84
- rb_require("wmq/wmq_temp");
85
- rb_require("wmq/wmq_const");
86
83
  }
87
84
 
88
85
  /*
data/ext/wmq.h CHANGED
@@ -1,5 +1,5 @@
1
1
  /* --------------------------------------------------------------------------
2
- * Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
2
+ * Copyright 2006 J. Reid Morrison
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -33,6 +33,10 @@
33
33
  #define rb_str_set_len(str, length) (RSTRING_LEN(str) = (length))
34
34
  #endif
35
35
 
36
+ #ifndef _int64
37
+ #define _int64 long long
38
+ #endif
39
+
36
40
  #include <cmqc.h>
37
41
  #include <cmqxc.h>
38
42
 
@@ -1,5 +1,5 @@
1
1
  /* --------------------------------------------------------------------------
2
- * Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
2
+ * Copyright 2006 J. Reid Morrison
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
2
+ * Copyright 2006 J. Reid Morrison
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /* --------------------------------------------------------------------------
2
- * Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
2
+ * Copyright 2006 J. Reid Morrison
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
2
+ * Copyright 2006 J. Reid Morrison
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
data/lib/wmq.rb CHANGED
@@ -1,23 +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
- ################################################################################
1
+ require 'wmq/version'
2
+ require 'wmq/constants'
3
+ require 'wmq/constants_admin'
4
+ require 'wmq/queue_manager'
5
+ require 'wmq/message'
16
6
 
17
- # Load wmq that uses auto-load library.
18
- #
19
- # If it fails, then it is likely due to this platform not being supported
20
- # by auto load facility in Ruby WMQ, so try to load client linked library
7
+ # Load wmq using the auto-load library.
8
+ #
9
+ # If it fails, then it is most likely since this platform is not supported
10
+ # by the auto load facility in Ruby WMQ, so try to load client linked library
11
+ # For Example AIX does not support Autoload whereas Windows and Linux are supported
21
12
  begin
22
13
  require 'wmq/wmq'
23
14
  rescue LoadError
@@ -0,0 +1,70 @@
1
+ # Message Ruby methods
2
+ module WMQ
3
+ # Message contains the message descriptor (MQMD), data
4
+ # and any headers.
5
+ #
6
+ # Note:
7
+ # * The format in the descriptor applies only to the format of the data portion,
8
+ # not the format of any included headers
9
+ # * The message format can ONLY be supplied in the descriptor.
10
+ # * I.e. It is the format of the data, Not the headers.
11
+ # * On the wire formats are determined automatically by the :header_type key for
12
+ # each header
13
+ # * Other WebSphere MQ interfaces require that the formats be "daisy-chained"
14
+ # * I.e. The MQMD.Format is actually the format of the first header
15
+ # * Ruby WMQ removes this tedious requirement and performs this
16
+ # requirement automatically under the covers
17
+ # * The format of any header should not be supplied in the descriptor or any header
18
+ #
19
+ # Message has the following attributes:
20
+ # * descriptor = {
21
+ # # WebSphere MQ Equivalent
22
+ # :format => WMQ::MQFMT_STRING, # MQMD.Format - Format of data only
23
+ # WMQ::MQFMT_NONE # Do not supply header formats here
24
+ # :original_length => Number # MQMD.OriginalLength
25
+ # :priority => 0 .. 9 # MQMD.Priority
26
+ # :put_time => String # MQMD.PutTime
27
+ # :msg_id => String ...
28
+ # :expiry => Number
29
+ # :persistence => Number
30
+ # :reply_to_q => String
31
+ # :correl_id => String
32
+ # :feedback => Number
33
+ # :offset => Number
34
+ # :report => Number
35
+ # :msg_flags => Number
36
+ # :reply_to_q_mgr => String
37
+ # :appl_identity_data => String
38
+ # :put_appl_name => String
39
+ # :user_identifier => String
40
+ # :msg_seq_number => Number
41
+ # :appl_origin_data => String
42
+ # :accounting_token => String
43
+ # :backout_count => Number
44
+ # :coded_char_set_id => Number
45
+ # :put_appl_type => Number
46
+ # :msg_type => Number
47
+ # :group_id => String
48
+ # :put_date => String
49
+ # :encoding => Number
50
+ # }
51
+ # * data => String
52
+ # * headers => Array of Hashes
53
+ # * Note: Do not supply the format of any header. Ruby WMQ does this for you.
54
+ #
55
+ # The following headers are supported:
56
+ # * Rules And Formatting Header (RFH)
57
+ # :header_type => :rf_header
58
+ # :....
59
+ # * Rules and Formatting V2 Header (RFH2)
60
+ # ....
61
+ # * Dead Letter Header
62
+ # * CICS Header
63
+ # * IMS Header
64
+ # * Transmission Queue Header
65
+ # * ...
66
+ class Message
67
+ attr_accessor :data, :descriptor, :headers
68
+ end
69
+
70
+ end
@@ -1,35 +1,6 @@
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
-
1
+ # QueueManager ruby methods
17
2
  module WMQ
18
-
19
- # Temporary placeholder until the following code is moved to 'C'
20
-
21
- #
22
3
  class QueueManager
23
- def method_missing(name, *args)
24
- if args.size == 1
25
- self.execute({:command=>name}.merge(args[0]))
26
- elsif args.size == 0
27
- self.execute({:command=>name})
28
- else
29
- raise("Invalid arguments supplied to QueueManager#:#{name}, args:#{args}")
30
- end
31
- end
32
-
33
4
  # Execute any MQSC command against the queue manager
34
5
  #
35
6
  # Example
@@ -124,74 +95,16 @@ module WMQ
124
95
  return self.put(parms)
125
96
  end
126
97
 
127
- end
98
+ # Expose Commands directly as Queue Manager methods
99
+ def method_missing(name, *args)
100
+ if args.size == 1
101
+ self.execute({:command=>name}.merge(args[0]))
102
+ elsif args.size == 0
103
+ self.execute({:command=>name})
104
+ else
105
+ raise("Invalid arguments supplied to QueueManager#:#{name}, args:#{args}")
106
+ end
107
+ end
128
108
 
129
- # Message contains the message descriptor (MQMD), data
130
- # and any headers.
131
- #
132
- # Note:
133
- # * The format in the descriptor applies only to the format of the data portion,
134
- # not the format of any included headers
135
- # * The message format can ONLY be supplied in the descriptor.
136
- # * I.e. It is the format of the data, Not the headers.
137
- # * On the wire formats are determined automatically by the :header_type key for
138
- # each header
139
- # * Other WebSphere MQ interfaces require that the formats be "daisy-chained"
140
- # * I.e. The MQMD.Format is actually the format of the first header
141
- # * Ruby WMQ removes this tedious requirement and performs this
142
- # requirement automatically under the covers
143
- # * The format of any header should not be supplied in the descriptor or any header
144
- #
145
- # Message has the following attributes:
146
- # * descriptor = {
147
- # # WebSphere MQ Equivalent
148
- # :format => WMQ::MQFMT_STRING, # MQMD.Format - Format of data only
149
- # WMQ::MQFMT_NONE # Do not supply header formats here
150
- # :original_length => Number # MQMD.OriginalLength
151
- # :priority => 0 .. 9 # MQMD.Priority
152
- # :put_time => String # MQMD.PutTime
153
- # :msg_id => String ...
154
- # :expiry => Number
155
- # :persistence => Number
156
- # :reply_to_q => String
157
- # :correl_id => String
158
- # :feedback => Number
159
- # :offset => Number
160
- # :report => Number
161
- # :msg_flags => Number
162
- # :reply_to_q_mgr => String
163
- # :appl_identity_data => String
164
- # :put_appl_name => String
165
- # :user_identifier => String
166
- # :msg_seq_number => Number
167
- # :appl_origin_data => String
168
- # :accounting_token => String
169
- # :backout_count => Number
170
- # :coded_char_set_id => Number
171
- # :put_appl_type => Number
172
- # :msg_type => Number
173
- # :group_id => String
174
- # :put_date => String
175
- # :encoding => Number
176
- # }
177
- # * data => String
178
- # * headers => Array of Hashes
179
- # * Note: Do not supply the format of any header. Ruby WMQ does this for you.
180
- #
181
- # The following headers are supported:
182
- # * Rules And Formatting Header (RFH)
183
- # :header_type => :rf_header
184
- # :....
185
- # * Rules and Formatting V2 Header (RFH2)
186
- # ....
187
- # * Dead Letter Header
188
- # * CICS Header
189
- # * IMS Header
190
- # * Transmission Queue Header
191
- # * ...
192
- class Message
193
- attr_reader :data, :descriptor, :headers
194
- attr_writer :data, :descriptor, :headers
195
109
  end
196
-
197
110
  end
@@ -0,0 +1,3 @@
1
+ module WMQ #:nodoc
2
+ VERSION = "2.0.0.pre"
3
+ end
@@ -1,15 +1,14 @@
1
- # Shift include path to use locally built copy of rubywmq - For testing dev builds only
2
- #$:.unshift '../lib'
1
+ # Allow test to be run in-place without requiring a gem install
2
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
3
3
 
4
4
  require 'rubygems'
5
- require 'wmq/wmq'
6
- require 'wmq/wmq_const_admin'
5
+ require 'wmq'
7
6
  require 'test/unit'
8
7
  class TestTest < Test::Unit::TestCase
9
8
 
10
9
  def setup
11
10
  puts '****** setup: start ******'
12
- @queue_manager = WMQ::QueueManager.new(:q_mgr_name => 'REID') #, :connection_name=>'localhost(1414)')
11
+ @queue_manager = WMQ::QueueManager.new(:q_mgr_name => 'TEST') #, :connection_name=>'localhost(1414)')
13
12
  @queue_manager.connect
14
13
 
15
14
  # Create Queue and clear any messages from the queue
@@ -161,7 +160,7 @@ class TestTest < Test::Unit::TestCase
161
160
  count = count + 1
162
161
  end
163
162
  end
164
-
163
+
165
164
  def test_dlh
166
165
  puts '****** test_dlh ******'
167
166
  dlh = {:header_type =>:dead_letter_header,
@@ -205,7 +204,7 @@ class TestTest < Test::Unit::TestCase
205
204
  }
206
205
  verify_header(cics, WMQ::MQFMT_NONE)
207
206
  end
208
-
207
+
209
208
  def test_ims
210
209
  puts '****** test_ims ******'
211
210
  ims = {:header_type =>:ims,
@@ -214,7 +213,7 @@ class TestTest < Test::Unit::TestCase
214
213
  }
215
214
  verify_header(ims, WMQ::MQFMT_STRING)
216
215
  end
217
-
216
+
218
217
  def test_transmission_header
219
218
  puts '****** test_transmission_header ******'
220
219
  xqh = {:header_type =>:xmit_q_header,
@@ -225,45 +224,45 @@ class TestTest < Test::Unit::TestCase
225
224
  }
226
225
  verify_header(xqh, WMQ::MQFMT_STRING)
227
226
  end
228
-
227
+
229
228
  def test_rf_header
230
229
  puts '****** test_rf_header ******'
231
230
  rfh = {:header_type =>:rf_header,
232
- :name_value => {' name s' => ' v a "l" u e 1 ',
233
- 'n a m e 2 ' => 'v a l u e 2',
231
+ :name_value => {' name s' => ' v a "l" u e 1 ',
232
+ 'n a m e 2 ' => 'v a l u e 2',
234
233
  '' => ['"', '""', '"""', '""""', ''],
235
234
  'name3'=>['"value3"', '', '"',' value 43"']},
236
235
  }
237
236
  verify_header(rfh, WMQ::MQFMT_STRING)
238
237
  end
239
-
238
+
240
239
  def test_rf_header_2
241
240
  puts '****** test_rf_header_2 ******'
242
241
  rfh2 = {:header_type =>:rf_header_2,
243
- :xml => ['<hello>to the world</hello>',
242
+ :xml => ['<hello>to the world</hello>',
244
243
  '<another>xml like string</another>'],
245
244
  }
246
245
  verify_header(rfh2, WMQ::MQFMT_STRING)
247
246
  end
248
-
247
+
249
248
  def test_multiple_headers
250
249
  puts '****** test_multiple_headers ******'
251
250
  headers = [{:header_type => :rf_header_2,
252
- :xml => ['<hello>to the world</hello>',
251
+ :xml => ['<hello>to the world</hello>',
253
252
  '<another>xml like string</another>'],},
254
-
253
+
255
254
  {:header_type => :rf_header,
256
- :name_value => {' name s' => ' v a l u e 1 ',
257
- 'n a m e 2 ' => 'v a l u e 2',
255
+ :name_value => {' name s' => ' v a l u e 1 ',
256
+ 'n a m e 2 ' => 'v a l u e 2',
258
257
  'name3'=>['value3', '', 'value 43']} },
259
-
258
+
260
259
  {:header_type => :ims,
261
260
  :l_term_override => 'LTERM',
262
261
  :reply_to_format => WMQ::MQFMT_STRING},
263
-
262
+
264
263
  {:header_type => :rf_header,
265
- :name_value => {' name s' => ' v a l u e 1 ',
266
- 'n a m e 2 ' => 'v a l u e 2',
264
+ :name_value => {' name s' => ' v a l u e 1 ',
265
+ 'n a m e 2 ' => 'v a l u e 2',
267
266
  'name3'=>['value3', '', 'value 43']} },
268
267
 
269
268
  {:header_type => :cics,
@@ -273,16 +272,16 @@ class TestTest < Test::Unit::TestCase
273
272
 
274
273
  {:header_type => :rf_header_2,
275
274
  :xml => ['<hello>to the world</hello>', '<another>xml like string</another>'],},
276
-
275
+
277
276
  {:header_type => :xmit_q_header,
278
277
  :remote_q_name => 'SOME_REMOTE_QUEUE',
279
278
  :remote_q_mgr_name=> 'SOME_REMOTE_Q_MGR',
280
279
  :msg_type => WMQ::MQMT_REQUEST,
281
280
  :msg_id => 'my message Id'},
282
- ]
281
+ ]
283
282
  verify_multiple_headers(headers, WMQ::MQFMT_STRING)
284
283
  end
285
-
284
+
286
285
  def test_xmit_multiple_headers
287
286
  puts '****** test_xmit_q_header with ims header ******'
288
287
  headers = [{:header_type => :xmit_q_header,
@@ -290,39 +289,30 @@ class TestTest < Test::Unit::TestCase
290
289
  :remote_q_mgr_name=> 'SOME_REMOTE_Q_MGR',
291
290
  :msg_type => WMQ::MQMT_REQUEST,
292
291
  :msg_id => 'my message Id'},
293
-
292
+
294
293
  {:header_type => :ims,
295
294
  :l_term_override => 'LTERM',
296
295
  :reply_to_format => WMQ::MQFMT_STRING},
297
296
  ]
298
297
  verify_multiple_headers(headers, WMQ::MQFMT_STRING)
299
298
  end
300
-
299
+
301
300
  def test_message_grouping
302
301
  puts '****** test_message_grouping ******'
303
302
  # Clear out queue of any messages
304
303
  @in_queue.each { |message| }
305
-
304
+
306
305
  msg = WMQ::Message.new
307
306
  msg.data = 'First'
308
307
  msg.descriptor[:msg_flags] = WMQ::MQMF_MSG_IN_GROUP
309
308
  assert_equal(@out_queue.put(:message=>msg, :options => WMQ::MQPMO_LOGICAL_ORDER), true)
310
-
309
+
311
310
  msg.data = 'Second'
312
311
  assert_equal(@out_queue.put(:message=>msg, :options => WMQ::MQPMO_LOGICAL_ORDER), true)
313
-
312
+
314
313
  msg.data = 'Last'
315
314
  msg.descriptor[:msg_flags] = WMQ::MQMF_LAST_MSG_IN_GROUP
316
315
  assert_equal(@out_queue.put(:message=>msg, :options => WMQ::MQPMO_LOGICAL_ORDER), true)
317
-
318
- # Now retrieve the messages destructively
319
- message = WMQ::Message.new
320
- test_sizes.each do |size|
321
- assert_equal(true, @in_queue.get(:message=>message, :match=>WMQ::MQMO_NONE))
322
- assert_equal(size, message.data.length)
323
- str = '0123456789ABCDEF' * (size/16) + '0123456789ABCDEF'[0,size%16]
324
- assert_equal(str, message.data)
325
- end
326
316
  end
327
-
317
+
328
318
  end