qpid_proton 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ChangeLog +18 -0
- data/ext/cproton/cproton.c +4868 -1733
- data/lib/qpid_proton.rb +5 -0
- data/lib/qpid_proton/array.rb +173 -0
- data/lib/qpid_proton/data.rb +87 -99
- data/lib/qpid_proton/described.rb +66 -0
- data/lib/qpid_proton/exception_handling.rb +3 -0
- data/lib/qpid_proton/exceptions.rb +1 -0
- data/lib/qpid_proton/hash.rb +86 -0
- data/lib/qpid_proton/mapping.rb +142 -0
- data/lib/qpid_proton/message.rb +180 -1
- data/lib/qpid_proton/messenger.rb +60 -51
- metadata +18 -21
@@ -28,14 +28,6 @@ module Qpid
|
|
28
28
|
#
|
29
29
|
class Messenger
|
30
30
|
|
31
|
-
# Automatically accept every message as it is returned by #get
|
32
|
-
#
|
33
|
-
ACCEPT_MODE_AUTO = Cproton::PN_ACCEPT_MODE_AUTO
|
34
|
-
|
35
|
-
# Messages must be manually accepted or rejected using #accept
|
36
|
-
#
|
37
|
-
ACCEPT_MODE_MANUAL = Cproton::PN_ACCEPT_MODE_MANUAL
|
38
|
-
|
39
31
|
include Qpid::Proton::ExceptionHandling
|
40
32
|
|
41
33
|
# Creates a new +Messenger+.
|
@@ -54,7 +46,6 @@ module Qpid
|
|
54
46
|
|
55
47
|
def self.finalize!(impl) # :nodoc:
|
56
48
|
proc {
|
57
|
-
Cproton.pn_messenger_stop(impl)
|
58
49
|
Cproton.pn_messenger_free(impl)
|
59
50
|
}
|
60
51
|
end
|
@@ -84,6 +75,14 @@ module Qpid
|
|
84
75
|
Cproton.pn_messenger_get_timeout(@impl)
|
85
76
|
end
|
86
77
|
|
78
|
+
def blocking
|
79
|
+
Cproton.pn_mesenger_is_blocking(@impl)
|
80
|
+
end
|
81
|
+
|
82
|
+
def blocking=(blocking)
|
83
|
+
Cproton.pn_messenger_set_blocking(@impl, blocking)
|
84
|
+
end
|
85
|
+
|
87
86
|
# Reports whether an error occurred.
|
88
87
|
#
|
89
88
|
def error?
|
@@ -99,7 +98,7 @@ module Qpid
|
|
99
98
|
# Returns the most recent error message.
|
100
99
|
#
|
101
100
|
def error
|
102
|
-
Cproton.pn_messenger_error(@impl)
|
101
|
+
Cproton.pn_error_text(Cproton.pn_messenger_error(@impl))
|
103
102
|
end
|
104
103
|
|
105
104
|
# Starts the +Messenger+, allowing it to begin sending and
|
@@ -116,6 +115,10 @@ module Qpid
|
|
116
115
|
check_for_error(Cproton.pn_messenger_stop(@impl))
|
117
116
|
end
|
118
117
|
|
118
|
+
def stopped
|
119
|
+
Cproton.pn_messenger_stopped(@impl)
|
120
|
+
end
|
121
|
+
|
119
122
|
# Subscribes the +Messenger+ to a remote address.
|
120
123
|
#
|
121
124
|
def subscribe(address)
|
@@ -193,14 +196,17 @@ module Qpid
|
|
193
196
|
def put(message)
|
194
197
|
raise TypeError.new("invalid message: #{message}") if message.nil?
|
195
198
|
raise ArgumentError.new("invalid message type: #{message.class}") unless message.kind_of?(Message)
|
199
|
+
# encode the message first
|
200
|
+
message.pre_encode
|
196
201
|
check_for_error(Cproton.pn_messenger_put(@impl, message.impl))
|
202
|
+
return outgoing_tracker
|
197
203
|
end
|
198
204
|
|
199
205
|
# Sends all outgoing messages, blocking until the outgoing queue
|
200
206
|
# is empty.
|
201
207
|
#
|
202
|
-
def send
|
203
|
-
check_for_error(Cproton.pn_messenger_send(@impl))
|
208
|
+
def send(n = -1)
|
209
|
+
check_for_error(Cproton.pn_messenger_send(@impl, n))
|
204
210
|
end
|
205
211
|
|
206
212
|
# Gets a single message incoming message from the local queue.
|
@@ -213,9 +219,15 @@ module Qpid
|
|
213
219
|
# * msg - the (optional) +Message+ instance to be used
|
214
220
|
#
|
215
221
|
def get(msg = nil)
|
216
|
-
|
217
|
-
|
218
|
-
|
222
|
+
msg_impl = nil
|
223
|
+
if msg.nil? then
|
224
|
+
msg_impl = nil
|
225
|
+
else
|
226
|
+
msg_impl = msg.impl
|
227
|
+
end
|
228
|
+
check_for_error(Cproton.pn_messenger_get(@impl, msg_impl))
|
229
|
+
msg.post_decode unless msg.nil?
|
230
|
+
return incoming_tracker
|
219
231
|
end
|
220
232
|
|
221
233
|
# Receives up to the specified number of messages, blocking until at least
|
@@ -223,12 +235,24 @@ module Qpid
|
|
223
235
|
#
|
224
236
|
# Options ====
|
225
237
|
#
|
226
|
-
# *
|
238
|
+
# * limit - the maximum number of messages to receive
|
227
239
|
#
|
228
|
-
def receive(
|
229
|
-
|
230
|
-
|
231
|
-
|
240
|
+
def receive(limit = -1)
|
241
|
+
check_for_error(Cproton.pn_messenger_recv(@impl, limit))
|
242
|
+
end
|
243
|
+
|
244
|
+
def receiving
|
245
|
+
Cproton.pn_messenger_receiving(@impl)
|
246
|
+
end
|
247
|
+
|
248
|
+
def work(timeout=-1)
|
249
|
+
err = Cproton.pn_messenger_work(@impl, timeout)
|
250
|
+
if (err == Cproton::PN_TIMEOUT) then
|
251
|
+
return false
|
252
|
+
else
|
253
|
+
check_for_error(err)
|
254
|
+
return true
|
255
|
+
end
|
232
256
|
end
|
233
257
|
|
234
258
|
# Returns the number messages in the outgoing queue that have not been
|
@@ -262,28 +286,6 @@ module Qpid
|
|
262
286
|
Qpid::Proton::Tracker.new(impl)
|
263
287
|
end
|
264
288
|
|
265
|
-
# Set the accept mode for the Messenger. See #ACCEPT_MODE_AUTO and
|
266
|
-
# #ACCEPT_MODE_MANUAL for more details
|
267
|
-
#
|
268
|
-
# ==== Options
|
269
|
-
#
|
270
|
-
# * mode - the acceptance mode
|
271
|
-
#
|
272
|
-
# ==== Examples
|
273
|
-
#
|
274
|
-
# @messenger.accept_mode = Qpid::Proton::Messenger::ACCEPT_MODE_AUTO
|
275
|
-
#
|
276
|
-
def accept_mode=(mode)
|
277
|
-
raise TypeError.new("Invalid mode: #{mode}") unless valid_mode?(mode)
|
278
|
-
Cproton.pn_messenger_set_accept_mode(@impl, mode)
|
279
|
-
end
|
280
|
-
|
281
|
-
# Returns the current acceptance mode for the Messenger.
|
282
|
-
#
|
283
|
-
def accept_mode
|
284
|
-
Cproton.pn_messenger_get_accept_mode(@impl)
|
285
|
-
end
|
286
|
-
|
287
289
|
# Accepts the incoming message identified by the tracker.
|
288
290
|
#
|
289
291
|
# ==== Options
|
@@ -291,9 +293,14 @@ module Qpid
|
|
291
293
|
# * tracker - the tracker
|
292
294
|
# * flag - the flag
|
293
295
|
#
|
294
|
-
def accept(tracker
|
295
|
-
raise TypeError.new("invalid tracker: #{tracker}") unless valid_tracker?(tracker)
|
296
|
-
|
296
|
+
def accept(tracker = nil)
|
297
|
+
raise TypeError.new("invalid tracker: #{tracker}") unless tracker.nil? or valid_tracker?(tracker)
|
298
|
+
if tracker.nil? then
|
299
|
+
tracker = self.incoming_tracker
|
300
|
+
flag = Cproton::PN_CUMULATIVE
|
301
|
+
else
|
302
|
+
flag = 0
|
303
|
+
end
|
297
304
|
check_for_error(Cproton.pn_messenger_accept(@impl, tracker.impl, flag))
|
298
305
|
end
|
299
306
|
|
@@ -304,8 +311,14 @@ module Qpid
|
|
304
311
|
# * tracker - the tracker
|
305
312
|
# * flag - the flag
|
306
313
|
#
|
307
|
-
def reject(tracker
|
308
|
-
raise TypeError.new("invalid tracker: #{tracker}") unless valid_tracker?(tracker)
|
314
|
+
def reject(tracker)
|
315
|
+
raise TypeError.new("invalid tracker: #{tracker}") unless tracker.nil? or valid_tracker?(tracker)
|
316
|
+
if tracker.nil? then
|
317
|
+
tracker = self.incoming_tracker
|
318
|
+
flag = Cproton::PN_CUMULATIVE
|
319
|
+
else
|
320
|
+
flag = 0
|
321
|
+
end
|
309
322
|
check_for_error(Cproton.pn_messenger_reject(@impl, tracker.impl, flag))
|
310
323
|
end
|
311
324
|
|
@@ -384,10 +397,6 @@ module Qpid
|
|
384
397
|
!tracker.nil? && tracker.is_a?(Qpid::Proton::Tracker)
|
385
398
|
end
|
386
399
|
|
387
|
-
def valid_mode?(mode)
|
388
|
-
[ACCEPT_MODE_AUTO, ACCEPT_MODE_MANUAL].include?(mode)
|
389
|
-
end
|
390
|
-
|
391
400
|
def valid_window?(window)
|
392
401
|
!window.nil? && [Float, Fixnum].include?(window.class)
|
393
402
|
end
|
metadata
CHANGED
@@ -1,26 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qpid_proton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
5
|
-
prerelease:
|
4
|
+
version: '0.5'
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Darryl L. Pierce
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-08-29 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
|
-
description:
|
15
|
-
be used in
|
16
|
-
|
13
|
+
description: |
|
14
|
+
Proton is a high performance, lightweight messaging library. It can be used in
|
17
15
|
the widest range of messaging applications including brokers, client libraries,
|
18
|
-
|
19
16
|
routers, bridges, proxies, and more. Proton is based on the AMQP 1.0 messaging
|
20
|
-
|
21
17
|
standard.
|
22
|
-
|
23
|
-
'
|
24
18
|
email:
|
25
19
|
- proton@qpid.apache.org
|
26
20
|
executables: []
|
@@ -34,37 +28,40 @@ files:
|
|
34
28
|
- ext/cproton/extconf.rb
|
35
29
|
- ext/cproton/cproton.c
|
36
30
|
- lib/qpid_proton.rb
|
31
|
+
- lib/qpid_proton/tracker_status.rb
|
32
|
+
- lib/qpid_proton/described.rb
|
33
|
+
- lib/qpid_proton/tracker.rb
|
34
|
+
- lib/qpid_proton/hash.rb
|
37
35
|
- lib/qpid_proton/subscription.rb
|
36
|
+
- lib/qpid_proton/message.rb
|
37
|
+
- lib/qpid_proton/message_format.rb
|
38
38
|
- lib/qpid_proton/messenger.rb
|
39
|
-
- lib/qpid_proton/tracker.rb
|
40
39
|
- lib/qpid_proton/exception_handling.rb
|
41
|
-
- lib/qpid_proton/message_format.rb
|
42
|
-
- lib/qpid_proton/message.rb
|
43
|
-
- lib/qpid_proton/exceptions.rb
|
44
40
|
- lib/qpid_proton/data.rb
|
45
|
-
- lib/qpid_proton/
|
41
|
+
- lib/qpid_proton/array.rb
|
42
|
+
- lib/qpid_proton/exceptions.rb
|
43
|
+
- lib/qpid_proton/mapping.rb
|
46
44
|
homepage: http://qpid.apache.org/proton
|
47
45
|
licenses: []
|
46
|
+
metadata: {}
|
48
47
|
post_install_message:
|
49
48
|
rdoc_options: []
|
50
49
|
require_paths:
|
51
50
|
- lib
|
52
51
|
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
-
none: false
|
54
52
|
requirements:
|
55
|
-
- -
|
53
|
+
- - '>='
|
56
54
|
- !ruby/object:Gem::Version
|
57
55
|
version: '0'
|
58
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
-
none: false
|
60
57
|
requirements:
|
61
|
-
- -
|
58
|
+
- - '>='
|
62
59
|
- !ruby/object:Gem::Version
|
63
60
|
version: '0'
|
64
61
|
requirements: []
|
65
62
|
rubyforge_project:
|
66
|
-
rubygems_version:
|
63
|
+
rubygems_version: 2.0.7
|
67
64
|
signing_key:
|
68
|
-
specification_version:
|
65
|
+
specification_version: 4
|
69
66
|
summary: Ruby language bindings for the Qpid Proton messaging framework
|
70
67
|
test_files: []
|