rubywmq 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +10 -0
- data/Gemfile.lock +37 -0
- data/LICENSE.txt +1 -1
- data/README.md +29 -47
- data/Rakefile +12 -76
- data/examples/each_a.rb +2 -3
- data/examples/each_b.rb +4 -5
- data/examples/each_header.rb +5 -6
- data/examples/files_to_q.rb +7 -8
- data/examples/get_a.rb +3 -5
- data/examples/get_client.rb +9 -10
- data/examples/put1_a.rb +2 -3
- data/examples/put1_b.rb +4 -7
- data/examples/put1_c.rb +6 -6
- data/examples/put_a.rb +0 -2
- data/examples/put_b.rb +5 -7
- data/examples/put_dlh.rb +11 -12
- data/examples/put_dynamic_q.rb +7 -7
- data/examples/put_group_a.rb +3 -4
- data/examples/put_group_b.rb +7 -7
- data/examples/put_rfh.rb +13 -11
- data/examples/put_rfh2_a.rb +9 -10
- data/examples/put_rfh2_b.rb +9 -9
- data/examples/put_xmit_q.rb +63 -8
- data/examples/q_to_files.rb +6 -7
- data/examples/request.rb +20 -18
- data/examples/server.rb +19 -16
- data/ext/extconf.rb +2 -1
- data/ext/extconf_client.rb +3 -3
- data/ext/generate/generate_const.rb +30 -23
- data/ext/generate/generate_reason.rb +70 -72
- data/ext/generate/generate_structs.rb +20 -19
- data/ext/generate/wmq_structs.erb +67 -67
- data/ext/wmq.c +0 -16
- data/ext/wmq.h +0 -16
- data/ext/wmq_message.c +8 -24
- data/ext/wmq_mq_load.c +5 -17
- data/ext/wmq_queue.c +73 -90
- data/ext/wmq_queue_manager.c +115 -108
- data/lib/wmq/message.rb +36 -34
- data/lib/wmq/queue_manager.rb +22 -19
- data/lib/wmq/version.rb +1 -1
- data/rubywmq.gemspec +38 -0
- data/test/queue_manager_test.rb +334 -0
- data/test/test_helper.rb +14 -0
- metadata +16 -26
- data/tests/test.rb +0 -318
data/test/test_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'minitest/autorun'
|
5
|
+
require 'minitest/reporters'
|
6
|
+
require 'minitest/stub_any_instance'
|
7
|
+
require 'shoulda/context'
|
8
|
+
require 'wmq'
|
9
|
+
require 'awesome_print'
|
10
|
+
|
11
|
+
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
|
12
|
+
|
13
|
+
# SemanticLogger.add_appender('test.log', &SemanticLogger::Appender::Base.colorized_formatter)
|
14
|
+
# SemanticLogger.default_level = :debug
|
metadata
CHANGED
@@ -1,30 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubywmq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reid Morrison
|
8
|
-
- Edwin Fine
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: shoulda
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - '>='
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: '0'
|
21
|
-
type: :development
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - '>='
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: '0'
|
11
|
+
date: 2015-08-18 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
28
13
|
description: RubyWMQ is a high performance native Ruby interface into WebSphere MQ.
|
29
14
|
email:
|
30
15
|
- reidmo@gmail.com
|
@@ -33,6 +18,9 @@ extensions:
|
|
33
18
|
- ext/extconf.rb
|
34
19
|
extra_rdoc_files: []
|
35
20
|
files:
|
21
|
+
- ".document"
|
22
|
+
- Gemfile
|
23
|
+
- Gemfile.lock
|
36
24
|
- LICENSE.txt
|
37
25
|
- README.md
|
38
26
|
- Rakefile
|
@@ -79,8 +67,9 @@ files:
|
|
79
67
|
- lib/wmq/message.rb
|
80
68
|
- lib/wmq/queue_manager.rb
|
81
69
|
- lib/wmq/version.rb
|
82
|
-
-
|
83
|
-
- .
|
70
|
+
- rubywmq.gemspec
|
71
|
+
- test/queue_manager_test.rb
|
72
|
+
- test/test_helper.rb
|
84
73
|
homepage: https://github.com/reidmorrison/rubywmq
|
85
74
|
licenses:
|
86
75
|
- Apache License V2.0
|
@@ -91,20 +80,21 @@ require_paths:
|
|
91
80
|
- lib
|
92
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
93
82
|
requirements:
|
94
|
-
- -
|
83
|
+
- - ">="
|
95
84
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.
|
85
|
+
version: '1.9'
|
97
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
87
|
requirements:
|
99
|
-
- -
|
88
|
+
- - ">="
|
100
89
|
- !ruby/object:Gem::Version
|
101
90
|
version: '0'
|
102
91
|
requirements:
|
103
92
|
- WebSphere MQ v5.3, v6 or v7 Client or Server with Development Kit
|
104
|
-
rubyforge_project:
|
105
|
-
rubygems_version: 2.
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.4.8
|
106
95
|
signing_key:
|
107
96
|
specification_version: 4
|
108
97
|
summary: Native Ruby interface into WebSphere MQ
|
109
98
|
test_files:
|
110
|
-
-
|
99
|
+
- test/queue_manager_test.rb
|
100
|
+
- test/test_helper.rb
|
data/tests/test.rb
DELETED
@@ -1,318 +0,0 @@
|
|
1
|
-
# Allow test to be run in-place without requiring a gem install
|
2
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
3
|
-
|
4
|
-
require 'rubygems'
|
5
|
-
require 'wmq'
|
6
|
-
require 'test/unit'
|
7
|
-
class TestTest < Test::Unit::TestCase
|
8
|
-
|
9
|
-
def setup
|
10
|
-
puts '****** setup: start ******'
|
11
|
-
@queue_manager = WMQ::QueueManager.new(:q_mgr_name => 'TEST') #, :connection_name=>'localhost(1414)')
|
12
|
-
@queue_manager.connect
|
13
|
-
|
14
|
-
# Create Queue and clear any messages from the queue
|
15
|
-
@in_queue = WMQ::Queue.new(:queue_manager=>@queue_manager,
|
16
|
-
:mode=>:input,
|
17
|
-
:dynamic_q_name=>'UNIT.TEST.*',
|
18
|
-
:q_name=>'SYSTEM.DEFAULT.MODEL.QUEUE',
|
19
|
-
:fail_if_exists=>false)
|
20
|
-
@in_queue.open
|
21
|
-
@in_queue.each { |message| }
|
22
|
-
|
23
|
-
# Open same queue for Output. Queue should be created by now
|
24
|
-
@out_queue = WMQ::Queue.new(:queue_manager=>@queue_manager,
|
25
|
-
:mode=>:output,
|
26
|
-
:q_name=>@in_queue.name)
|
27
|
-
@out_queue.open
|
28
|
-
puts '****** setup: end ******'
|
29
|
-
end
|
30
|
-
|
31
|
-
def teardown
|
32
|
-
puts '****** teardown: start ******'
|
33
|
-
@out_queue.close
|
34
|
-
@in_queue.close
|
35
|
-
@queue_manager.disconnect
|
36
|
-
puts '****** teardown: end ******'
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_exceptions
|
40
|
-
puts '****** test_exceptions: start ******'
|
41
|
-
assert_raise(TypeError) { WMQ::QueueManager.new(1) }
|
42
|
-
assert_nothing_raised { WMQ::QueueManager.new(:exception_on_error=>nil) }
|
43
|
-
assert_raise(TypeError) { WMQ::QueueManager.new(:exception_on_error=>1) }
|
44
|
-
assert_raise(TypeError) { WMQ::QueueManager.new(:q_mgr_name=>2).connect }
|
45
|
-
assert_raise(WMQ::WMQException) { WMQ::QueueManager.new(:q_mgr_name=>'bad').connect }
|
46
|
-
puts '****** test_exceptions: end ******'
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_queue_manager
|
50
|
-
puts '****** test_queue_manager ******'
|
51
|
-
assert_equal(Object, WMQ::QueueManager.superclass)
|
52
|
-
assert_equal(WMQ::QueueManager, @queue_manager.class)
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_1
|
56
|
-
puts '****** test_1 ******'
|
57
|
-
assert_equal(@out_queue.put(:data=>'Hello World'), true)
|
58
|
-
message = WMQ::Message.new
|
59
|
-
assert_equal(@in_queue.get(:message=>message), true)
|
60
|
-
assert_equal(message.data, 'Hello World')
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_dynamic_buffer
|
64
|
-
puts '****** test_dynamic_buffer ******'
|
65
|
-
# Clear out queue of any messages
|
66
|
-
@in_queue.each { |message| }
|
67
|
-
|
68
|
-
test_sizes = [0, 1, 100, 101, 102, 500, 65534, 65535, 65536, 65537, 1*1024*1024, 4*1024*1024]
|
69
|
-
test_sizes.each do |size|
|
70
|
-
str = '0123456789ABCDEF' * (size/16) + '0123456789ABCDEF'[0,size%16]
|
71
|
-
assert_equal(str.length, size)
|
72
|
-
assert_equal(@out_queue.put(:data=>str), true)
|
73
|
-
end
|
74
|
-
|
75
|
-
# First test the browse mechanism
|
76
|
-
counter = 0
|
77
|
-
@queue_manager.open_queue(:mode=>:browse, :q_name=>@in_queue.name) do |browse_queue|
|
78
|
-
browse_queue.each do |message|
|
79
|
-
size = test_sizes[counter]
|
80
|
-
assert_equal(size, message.data.length)
|
81
|
-
str = '0123456789ABCDEF' * (size/16) + '0123456789ABCDEF'[0,size%16]
|
82
|
-
assert_equal(str, message.data)
|
83
|
-
counter = counter + 1
|
84
|
-
end
|
85
|
-
end
|
86
|
-
assert_equal(test_sizes.size, counter)
|
87
|
-
|
88
|
-
# Now retrieve the messages destructively
|
89
|
-
message = WMQ::Message.new
|
90
|
-
test_sizes.each do |size|
|
91
|
-
assert_equal(true, @in_queue.get(:message=>message, :match=>WMQ::MQMO_NONE))
|
92
|
-
assert_equal(size, message.data.length)
|
93
|
-
str = '0123456789ABCDEF' * (size/16) + '0123456789ABCDEF'[0,size%16]
|
94
|
-
assert_equal(str, message.data)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_q_name_hash
|
99
|
-
puts '****** test_q_name_hash ******'
|
100
|
-
@queue_manager.open_queue(:mode=>:output,
|
101
|
-
:q_name=>{:q_name=>@in_queue.name,
|
102
|
-
:q_mgr_name=>@queue_manager.name}
|
103
|
-
) do |test_queue|
|
104
|
-
assert_equal(true, test_queue.put(:data=>'Hello World'))
|
105
|
-
message = WMQ::Message.new
|
106
|
-
assert_equal(true, @in_queue.get(:message=>message))
|
107
|
-
assert_equal('Hello World', message.data)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_execute
|
112
|
-
puts '****** test_execute ******'
|
113
|
-
array = @queue_manager.inquire_q(:q_name=>@in_queue.name, :q_type=>WMQ::MQQT_LOCAL, :current_q_depth=>nil)
|
114
|
-
assert_equal(1, array.size)
|
115
|
-
assert_equal(@in_queue.name, array[0][:q_name])
|
116
|
-
|
117
|
-
assert_equal(true, @queue_manager.inquire_process(:process_name=>'*').size>0)
|
118
|
-
assert_raise(WMQ::WMQException) { @queue_manager.inquire_q(:q_name=>'BADQUEUENAME*') }
|
119
|
-
assert_equal(1, @queue_manager.ping_q_mgr.size)
|
120
|
-
end
|
121
|
-
|
122
|
-
def test_mqsc
|
123
|
-
puts '****** test_mqsc ******'
|
124
|
-
array = @queue_manager.mqsc("dis ql(#{@in_queue.name})")
|
125
|
-
assert_equal(1, array.size)
|
126
|
-
assert_equal(true, array[0].include?("QUEUE(#{@in_queue.name})"))
|
127
|
-
end
|
128
|
-
|
129
|
-
def test_put1
|
130
|
-
puts '****** test_put1 ******'
|
131
|
-
data = 'Some Test Data'
|
132
|
-
assert_equal(true,@queue_manager.put(:q_name=>@in_queue.name, :data=>data))
|
133
|
-
|
134
|
-
message = WMQ::Message.new
|
135
|
-
assert_equal(true, @in_queue.get(:message=>message))
|
136
|
-
assert_equal(data, message.data)
|
137
|
-
end
|
138
|
-
|
139
|
-
def verify_header(header, format)
|
140
|
-
verify_multiple_headers([header], format)
|
141
|
-
end
|
142
|
-
|
143
|
-
def verify_multiple_headers(headers, format)
|
144
|
-
data = 'Some Test Data'
|
145
|
-
message = WMQ::Message.new
|
146
|
-
message.data = data
|
147
|
-
message.descriptor[:format] = format
|
148
|
-
message.headers = headers
|
149
|
-
#assert_equal(true,@queue_manager.put(:q_name=>@in_queue.name, :message=>message))
|
150
|
-
assert_equal(true,@out_queue.put(:message=>message))
|
151
|
-
|
152
|
-
message = WMQ::Message.new
|
153
|
-
assert_equal(true, @in_queue.get(:message=>message))
|
154
|
-
assert_equal(data, message.data)
|
155
|
-
assert_equal(headers.size, message.headers.size)
|
156
|
-
count = 0
|
157
|
-
headers.each do |header|
|
158
|
-
reply_header = message.headers[count]
|
159
|
-
header.each_pair{|key, value| assert_equal(value, reply_header[key])}
|
160
|
-
count = count + 1
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
def test_dlh
|
165
|
-
puts '****** test_dlh ******'
|
166
|
-
dlh = {:header_type =>:dead_letter_header,
|
167
|
-
:reason => WMQ::MQRC_UNKNOWN_REMOTE_Q_MGR,
|
168
|
-
:dest_q_name =>'ORIGINAL_QUEUE_NAME',
|
169
|
-
:dest_q_mgr_name =>'BAD_Q_MGR',
|
170
|
-
:put_appl_name =>'TestApp.exe',
|
171
|
-
}
|
172
|
-
|
173
|
-
verify_header(dlh, WMQ::MQFMT_DEAD_LETTER_HEADER)
|
174
|
-
# Untested keys:
|
175
|
-
#:put_date=>"",
|
176
|
-
#:put_time=>"",
|
177
|
-
#:encoding=>0,
|
178
|
-
#:coded_char_set_id=>437,
|
179
|
-
#:put_appl_type=>0,
|
180
|
-
|
181
|
-
# Test again, but use QueueManager#put this time
|
182
|
-
data = 'Some Test Data'
|
183
|
-
message = WMQ::Message.new
|
184
|
-
message.data = data
|
185
|
-
message.descriptor[:format] = WMQ::MQFMT_STRING
|
186
|
-
message.headers << dlh
|
187
|
-
assert_equal(true,@queue_manager.put(:q_name=>@in_queue.name, :message=>message))
|
188
|
-
|
189
|
-
message = WMQ::Message.new
|
190
|
-
assert_equal(true, @in_queue.get(:message=>message))
|
191
|
-
assert_equal(data, message.data)
|
192
|
-
assert_equal(1, message.headers.size)
|
193
|
-
reply_header = message.headers[0]
|
194
|
-
|
195
|
-
dlh.each_pair{|key, value| assert_equal(value, reply_header[key])}
|
196
|
-
end
|
197
|
-
|
198
|
-
def test_cics
|
199
|
-
puts '****** test_cics ******'
|
200
|
-
cics = {:header_type =>:cics,
|
201
|
-
:reason =>WMQ::MQRC_UNKNOWN_REMOTE_Q_MGR,
|
202
|
-
:facility =>'TOKEN123',
|
203
|
-
:reply_to_format =>WMQ::MQFMT_STRING,
|
204
|
-
}
|
205
|
-
verify_header(cics, WMQ::MQFMT_NONE)
|
206
|
-
end
|
207
|
-
|
208
|
-
def test_ims
|
209
|
-
puts '****** test_ims ******'
|
210
|
-
ims = {:header_type =>:ims,
|
211
|
-
:l_term_override =>'LTERM',
|
212
|
-
:reply_to_format =>WMQ::MQFMT_STRING,
|
213
|
-
}
|
214
|
-
verify_header(ims, WMQ::MQFMT_STRING)
|
215
|
-
end
|
216
|
-
|
217
|
-
def test_transmission_header
|
218
|
-
puts '****** test_transmission_header ******'
|
219
|
-
xqh = {:header_type =>:xmit_q_header,
|
220
|
-
:remote_q_name =>'SOME_REMOTE_QUEUE',
|
221
|
-
:remote_q_mgr_name=>'SOME_REMOTE_Q_MGR',
|
222
|
-
:msg_type =>WMQ::MQMT_REQUEST,
|
223
|
-
:msg_id =>'my message Id',
|
224
|
-
}
|
225
|
-
verify_header(xqh, WMQ::MQFMT_STRING)
|
226
|
-
end
|
227
|
-
|
228
|
-
def test_rf_header
|
229
|
-
puts '****** test_rf_header ******'
|
230
|
-
rfh = {:header_type =>:rf_header,
|
231
|
-
:name_value => {' name s' => ' v a "l" u e 1 ',
|
232
|
-
'n a m e 2 ' => 'v a l u e 2',
|
233
|
-
'' => ['"', '""', '"""', '""""', ''],
|
234
|
-
'name3'=>['"value3"', '', '"',' value 43"']},
|
235
|
-
}
|
236
|
-
verify_header(rfh, WMQ::MQFMT_STRING)
|
237
|
-
end
|
238
|
-
|
239
|
-
def test_rf_header_2
|
240
|
-
puts '****** test_rf_header_2 ******'
|
241
|
-
rfh2 = {:header_type =>:rf_header_2,
|
242
|
-
:xml => ['<hello>to the world</hello>',
|
243
|
-
'<another>xml like string</another>'],
|
244
|
-
}
|
245
|
-
verify_header(rfh2, WMQ::MQFMT_STRING)
|
246
|
-
end
|
247
|
-
|
248
|
-
def test_multiple_headers
|
249
|
-
puts '****** test_multiple_headers ******'
|
250
|
-
headers = [{:header_type => :rf_header_2,
|
251
|
-
:xml => ['<hello>to the world</hello>',
|
252
|
-
'<another>xml like string</another>'],},
|
253
|
-
|
254
|
-
{:header_type => :rf_header,
|
255
|
-
:name_value => {' name s' => ' v a l u e 1 ',
|
256
|
-
'n a m e 2 ' => 'v a l u e 2',
|
257
|
-
'name3'=>['value3', '', 'value 43']} },
|
258
|
-
|
259
|
-
{:header_type => :ims,
|
260
|
-
:l_term_override => 'LTERM',
|
261
|
-
:reply_to_format => WMQ::MQFMT_STRING},
|
262
|
-
|
263
|
-
{:header_type => :rf_header,
|
264
|
-
:name_value => {' name s' => ' v a l u e 1 ',
|
265
|
-
'n a m e 2 ' => 'v a l u e 2',
|
266
|
-
'name3'=>['value3', '', 'value 43']} },
|
267
|
-
|
268
|
-
{:header_type => :cics,
|
269
|
-
:reason => WMQ::MQRC_UNKNOWN_REMOTE_Q_MGR,
|
270
|
-
:facility => 'TOKEN123',
|
271
|
-
:reply_to_format => WMQ::MQFMT_STRING},
|
272
|
-
|
273
|
-
{:header_type => :rf_header_2,
|
274
|
-
:xml => ['<hello>to the world</hello>', '<another>xml like string</another>'],},
|
275
|
-
|
276
|
-
{:header_type => :xmit_q_header,
|
277
|
-
:remote_q_name => 'SOME_REMOTE_QUEUE',
|
278
|
-
:remote_q_mgr_name=> 'SOME_REMOTE_Q_MGR',
|
279
|
-
:msg_type => WMQ::MQMT_REQUEST,
|
280
|
-
:msg_id => 'my message Id'},
|
281
|
-
]
|
282
|
-
verify_multiple_headers(headers, WMQ::MQFMT_STRING)
|
283
|
-
end
|
284
|
-
|
285
|
-
def test_xmit_multiple_headers
|
286
|
-
puts '****** test_xmit_q_header with ims header ******'
|
287
|
-
headers = [{:header_type => :xmit_q_header,
|
288
|
-
:remote_q_name => 'SOME_REMOTE_QUEUE',
|
289
|
-
:remote_q_mgr_name=> 'SOME_REMOTE_Q_MGR',
|
290
|
-
:msg_type => WMQ::MQMT_REQUEST,
|
291
|
-
:msg_id => 'my message Id'},
|
292
|
-
|
293
|
-
{:header_type => :ims,
|
294
|
-
:l_term_override => 'LTERM',
|
295
|
-
:reply_to_format => WMQ::MQFMT_STRING},
|
296
|
-
]
|
297
|
-
verify_multiple_headers(headers, WMQ::MQFMT_STRING)
|
298
|
-
end
|
299
|
-
|
300
|
-
def test_message_grouping
|
301
|
-
puts '****** test_message_grouping ******'
|
302
|
-
# Clear out queue of any messages
|
303
|
-
@in_queue.each { |message| }
|
304
|
-
|
305
|
-
msg = WMQ::Message.new
|
306
|
-
msg.data = 'First'
|
307
|
-
msg.descriptor[:msg_flags] = WMQ::MQMF_MSG_IN_GROUP
|
308
|
-
assert_equal(@out_queue.put(:message=>msg, :options => WMQ::MQPMO_LOGICAL_ORDER), true)
|
309
|
-
|
310
|
-
msg.data = 'Second'
|
311
|
-
assert_equal(@out_queue.put(:message=>msg, :options => WMQ::MQPMO_LOGICAL_ORDER), true)
|
312
|
-
|
313
|
-
msg.data = 'Last'
|
314
|
-
msg.descriptor[:msg_flags] = WMQ::MQMF_LAST_MSG_IN_GROUP
|
315
|
-
assert_equal(@out_queue.put(:message=>msg, :options => WMQ::MQPMO_LOGICAL_ORDER), true)
|
316
|
-
end
|
317
|
-
|
318
|
-
end
|