qpid_proton 0.8 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/cproton/cproton.c +5004 -4239
- data/ext/cproton/extconf.rb +4 -1
- data/lib/qpid_proton.rb +7 -3
- data/lib/qpid_proton/array.rb +5 -5
- data/lib/qpid_proton/data.rb +6 -8
- data/lib/qpid_proton/described.rb +2 -2
- data/lib/qpid_proton/exception_handling.rb +51 -5
- data/lib/qpid_proton/exceptions.rb +10 -4
- data/lib/qpid_proton/filters.rb +4 -4
- data/lib/qpid_proton/hash.rb +3 -3
- data/lib/qpid_proton/mapping.rb +36 -8
- data/lib/qpid_proton/message.rb +30 -22
- data/lib/qpid_proton/messenger.rb +72 -34
- data/lib/qpid_proton/selectable.rb +4 -4
- data/lib/qpid_proton/strings.rb +65 -0
- data/lib/qpid_proton/subscription.rb +4 -4
- data/lib/qpid_proton/tracker.rb +4 -4
- data/lib/qpid_proton/tracker_status.rb +4 -4
- data/lib/qpid_proton/version.rb +7 -4
- metadata +19 -4
- data/lib/qpid_proton/message_format.rb +0 -75
@@ -17,9 +17,9 @@
|
|
17
17
|
# under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
module Qpid
|
20
|
+
module Qpid # :nodoc:
|
21
21
|
|
22
|
-
module Proton
|
22
|
+
module Proton # :nodoc:
|
23
23
|
|
24
24
|
# The +Messenger+ class defines a high level interface for
|
25
25
|
# sending and receiving Messages. Every Messenger contains
|
@@ -59,6 +59,11 @@ module Qpid
|
|
59
59
|
|
60
60
|
include Qpid::Proton::ExceptionHandling
|
61
61
|
|
62
|
+
can_raise_exception [:send, :receive, :password=, :start, :stop,
|
63
|
+
:perform_put, :perform_get, :interrupt,
|
64
|
+
:route, :rewrite, :accept, :reject,
|
65
|
+
:incoming_window=, :outgoing_window=]
|
66
|
+
|
62
67
|
# Creates a new +Messenger+.
|
63
68
|
#
|
64
69
|
# The +name+ parameter is optional. If one is not provided then
|
@@ -94,7 +99,7 @@ module Qpid
|
|
94
99
|
# * password - the password
|
95
100
|
#
|
96
101
|
def password=(password)
|
97
|
-
|
102
|
+
Cproton.pn_messenger_set_password(@impl, password)
|
98
103
|
end
|
99
104
|
|
100
105
|
# Returns the password property for the Messenger.private_key file.
|
@@ -179,25 +184,34 @@ module Qpid
|
|
179
184
|
Cproton.pn_error_text(Cproton.pn_messenger_error(@impl))
|
180
185
|
end
|
181
186
|
|
187
|
+
# Clears the current error state.
|
188
|
+
#
|
189
|
+
def clear_error
|
190
|
+
error = Cproton.pn_messenger_error(@impl)
|
191
|
+
unless error.nil?
|
192
|
+
Cproton.pn_error_clear(error)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
182
196
|
# Currently a no-op placeholder.
|
183
197
|
# For future compatibility, do not send or recv messages
|
184
198
|
# before starting the +Messenger+.
|
185
199
|
#
|
186
200
|
def start
|
187
|
-
|
201
|
+
Cproton.pn_messenger_start(@impl)
|
188
202
|
end
|
189
203
|
|
190
204
|
# Stops the +Messenger+, preventing it from sending or receiving
|
191
205
|
# any more messages.
|
192
206
|
#
|
193
207
|
def stop
|
194
|
-
|
208
|
+
Cproton.pn_messenger_stop(@impl)
|
195
209
|
end
|
196
210
|
|
197
|
-
# Returns true
|
211
|
+
# Returns true if a Messenger is in the stopped state.
|
198
212
|
# This function does not block.
|
199
213
|
#
|
200
|
-
def stopped
|
214
|
+
def stopped?
|
201
215
|
Cproton.pn_messenger_stopped(@impl)
|
202
216
|
end
|
203
217
|
|
@@ -207,13 +221,19 @@ module Qpid
|
|
207
221
|
# domain portion of the address begins with the '~' character, the
|
208
222
|
# Messenger will interpret the domain as host/port, bind to it,
|
209
223
|
# and listen for incoming messages. For example "~0.0.0.0",
|
210
|
-
# "amqp://~0.0.0.0" will all bind to any local interface and
|
211
|
-
# listen for incoming messages.
|
224
|
+
# "amqp://~0.0.0.0" will all bind to any local interface and
|
225
|
+
# listen for incoming messages. An address of "amqps://~0.0.0.0"
|
212
226
|
# will only permit incoming SSL connections.
|
213
227
|
#
|
214
|
-
|
228
|
+
# ==== Options
|
229
|
+
#
|
230
|
+
# * address - the source address to be subscribe
|
231
|
+
# * timeout - an optional time-to-live value, in seconds, for the
|
232
|
+
# subscription
|
233
|
+
#
|
234
|
+
def subscribe(address, timeout=0)
|
215
235
|
raise TypeError.new("invalid address: #{address}") if address.nil?
|
216
|
-
subscription = Cproton.
|
236
|
+
subscription = Cproton.pn_messenger_subscribe_ttl(@impl, address, timeout)
|
217
237
|
raise Qpid::Proton::ProtonError.new("Subscribe failed") if subscription.nil?
|
218
238
|
Qpid::Proton::Subscription.new(subscription)
|
219
239
|
end
|
@@ -282,10 +302,10 @@ module Qpid
|
|
282
302
|
# Places the content contained in the message onto the outgoing
|
283
303
|
# queue of the Messenger.
|
284
304
|
#
|
285
|
-
# This method will never block, however it will send any unblocked
|
305
|
+
# This method will never block, however it will send any unblocked
|
286
306
|
# Messages in the outgoing queue immediately and leave any blocked
|
287
307
|
# Messages remaining in the outgoing queue.
|
288
|
-
# The send call may then be used to block until the outgoing queue
|
308
|
+
# The send call may then be used to block until the outgoing queue
|
289
309
|
# is empty. The outgoing attribute may be used to check the depth
|
290
310
|
# of the outgoing queue.
|
291
311
|
#
|
@@ -298,18 +318,27 @@ module Qpid
|
|
298
318
|
raise ArgumentError.new("invalid message type: #{message.class}") unless message.kind_of?(Message)
|
299
319
|
# encode the message first
|
300
320
|
message.pre_encode
|
301
|
-
|
321
|
+
perform_put(message)
|
302
322
|
return outgoing_tracker
|
303
323
|
end
|
304
324
|
|
325
|
+
private
|
326
|
+
|
327
|
+
def perform_put(message) # :nodoc:
|
328
|
+
Cproton.pn_messenger_put(@impl, message.impl)
|
329
|
+
end
|
330
|
+
|
331
|
+
public
|
332
|
+
|
333
|
+
|
305
334
|
# This call will block until the indicated number of messages
|
306
335
|
# have been sent, or until the operation times out.
|
307
|
-
# If n is -1 this call will block until all outgoing messages
|
308
|
-
# have been sent. If n is 0 then this call will send whatever
|
336
|
+
# If n is -1 this call will block until all outgoing messages
|
337
|
+
# have been sent. If n is 0 then this call will send whatever
|
309
338
|
# it can without blocking.
|
310
339
|
#
|
311
340
|
def send(n = -1)
|
312
|
-
|
341
|
+
Cproton.pn_messenger_send(@impl, n)
|
313
342
|
end
|
314
343
|
|
315
344
|
# Moves the message from the head of the incoming message queue into
|
@@ -333,11 +362,19 @@ module Qpid
|
|
333
362
|
else
|
334
363
|
msg_impl = msg.impl
|
335
364
|
end
|
336
|
-
|
365
|
+
perform_get(msg_impl)
|
337
366
|
msg.post_decode unless msg.nil?
|
338
367
|
return incoming_tracker
|
339
368
|
end
|
340
369
|
|
370
|
+
private
|
371
|
+
|
372
|
+
def perform_get(msg) # :nodoc:
|
373
|
+
Cproton.pn_messenger_get(@impl, msg)
|
374
|
+
end
|
375
|
+
|
376
|
+
public
|
377
|
+
|
341
378
|
# Receives up to limit messages into the incoming queue. If no value
|
342
379
|
# for limit is supplied, this call will receive as many messages as it
|
343
380
|
# can buffer internally. If the Messenger is in blocking mode, this
|
@@ -349,10 +386,11 @@ module Qpid
|
|
349
386
|
# * limit - the maximum number of messages to receive
|
350
387
|
#
|
351
388
|
def receive(limit = -1)
|
352
|
-
|
389
|
+
Cproton.pn_messenger_recv(@impl, limit)
|
353
390
|
end
|
354
391
|
|
355
|
-
|
392
|
+
# Returns true if the messenger is currently receiving data.
|
393
|
+
def receiving?
|
356
394
|
Cproton.pn_messenger_receiving(@impl)
|
357
395
|
end
|
358
396
|
|
@@ -369,7 +407,7 @@ module Qpid
|
|
369
407
|
# originated the interrupt.
|
370
408
|
#
|
371
409
|
def interrupt
|
372
|
-
|
410
|
+
Cproton.pn_messenger_interrupt(@impl)
|
373
411
|
end
|
374
412
|
|
375
413
|
# Sends or receives any outstanding messages queued for a Messenger.
|
@@ -377,7 +415,7 @@ module Qpid
|
|
377
415
|
# This will block for the indicated timeout. This method may also do I/O
|
378
416
|
# other than sending and receiving messages. For example, closing
|
379
417
|
# connections after stop() has been called.
|
380
|
-
#
|
418
|
+
#
|
381
419
|
def work(timeout=-1)
|
382
420
|
err = Cproton.pn_messenger_work(@impl, timeout)
|
383
421
|
if (err == Cproton::PN_TIMEOUT) then
|
@@ -457,7 +495,7 @@ module Qpid
|
|
457
495
|
# messenger.route("*", "amqp://user:password@broker/$1")
|
458
496
|
#
|
459
497
|
def route(pattern, address)
|
460
|
-
|
498
|
+
Cproton.pn_messenger_route(@impl, pattern, address)
|
461
499
|
end
|
462
500
|
|
463
501
|
# Similar to #route, except that the destination of
|
@@ -479,7 +517,7 @@ module Qpid
|
|
479
517
|
# * address - the target address
|
480
518
|
#
|
481
519
|
def rewrite(pattern, address)
|
482
|
-
|
520
|
+
Cproton.pn_messenger_rewrite(@impl, pattern, address)
|
483
521
|
end
|
484
522
|
|
485
523
|
def selectable
|
@@ -533,7 +571,7 @@ module Qpid
|
|
533
571
|
else
|
534
572
|
flag = 0
|
535
573
|
end
|
536
|
-
|
574
|
+
Cproton.pn_messenger_accept(@impl, tracker.impl, flag)
|
537
575
|
end
|
538
576
|
|
539
577
|
# Rejects the incoming message identified by the tracker.
|
@@ -553,13 +591,13 @@ module Qpid
|
|
553
591
|
else
|
554
592
|
flag = 0
|
555
593
|
end
|
556
|
-
|
594
|
+
Cproton.pn_messenger_reject(@impl, tracker.impl, flag)
|
557
595
|
end
|
558
596
|
|
559
597
|
# Gets the last known remote state of the delivery associated with
|
560
|
-
# the given tracker, as long as the Message is still within your
|
561
|
-
# outgoing window. (Also works on incoming messages that are still
|
562
|
-
# within your incoming queue. See TrackerStatus for details on the
|
598
|
+
# the given tracker, as long as the Message is still within your
|
599
|
+
# outgoing window. (Also works on incoming messages that are still
|
600
|
+
# within your incoming queue. See TrackerStatus for details on the
|
563
601
|
# values returned.
|
564
602
|
#
|
565
603
|
# ==== Options
|
@@ -594,13 +632,13 @@ module Qpid
|
|
594
632
|
|
595
633
|
# Sets the incoming window.
|
596
634
|
#
|
597
|
-
# The Messenger will track the remote status of this many incoming
|
635
|
+
# The Messenger will track the remote status of this many incoming
|
598
636
|
# deliveries after they have been accepted or rejected.
|
599
637
|
#
|
600
638
|
# Messages enter this window only when you take them into your application
|
601
639
|
# using get(). If your incoming window size is n, and you get n+1 messages
|
602
640
|
# without explicitly accepting or rejecting the oldest message, then the
|
603
|
-
# message that passes beyond the edge of the incoming window will be
|
641
|
+
# message that passes beyond the edge of the incoming window will be
|
604
642
|
# assigned the default disposition of its link.
|
605
643
|
#
|
606
644
|
# ==== Options
|
@@ -609,7 +647,7 @@ module Qpid
|
|
609
647
|
#
|
610
648
|
def incoming_window=(window)
|
611
649
|
raise TypeError.new("invalid window: #{window}") unless valid_window?(window)
|
612
|
-
|
650
|
+
Cproton.pn_messenger_set_incoming_window(@impl, window)
|
613
651
|
end
|
614
652
|
|
615
653
|
# Returns the incoming window.
|
@@ -620,7 +658,7 @@ module Qpid
|
|
620
658
|
|
621
659
|
# Sets the outgoing window.
|
622
660
|
#
|
623
|
-
# The Messenger will track the remote status of this many outgoing
|
661
|
+
# The Messenger will track the remote status of this many outgoing
|
624
662
|
# deliveries after calling send.
|
625
663
|
# A Message enters this window when you call the put() method with the
|
626
664
|
# message. If your outgoing window size is n, and you call put n+1
|
@@ -633,7 +671,7 @@ module Qpid
|
|
633
671
|
#
|
634
672
|
def outgoing_window=(window)
|
635
673
|
raise TypeError.new("invalid window: #{window}") unless valid_window?(window)
|
636
|
-
|
674
|
+
Cproton.pn_messenger_set_outgoing_window(@impl, window)
|
637
675
|
end
|
638
676
|
|
639
677
|
# Returns the outgoing window.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
#--
|
2
2
|
# Licensed to the Apache Software Foundation (ASF) under one
|
3
3
|
# or more contributor license agreements. See the NOTICE file
|
4
4
|
# distributed with this work for additional information
|
@@ -15,11 +15,11 @@
|
|
15
15
|
# KIND, either express or implied. See the License for the
|
16
16
|
# specific language governing permissions and limitations
|
17
17
|
# under the License.
|
18
|
-
|
18
|
+
#++
|
19
19
|
|
20
|
-
module Qpid
|
20
|
+
module Qpid # :nodoc:
|
21
21
|
|
22
|
-
module Proton
|
22
|
+
module Proton # :nodoc:
|
23
23
|
|
24
24
|
# Selectable enables accessing the underlying file descriptors
|
25
25
|
# for Messenger.
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#--
|
2
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
3
|
+
# or more contributor license agreements. See the NOTICE file
|
4
|
+
# distributed with this work for additional information
|
5
|
+
# regarding copyright ownership. The ASF licenses this file
|
6
|
+
# to you under the Apache License, Version 2.0 (the
|
7
|
+
# "License"); you may not use this file except in compliance
|
8
|
+
# with the License. You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing,
|
13
|
+
# software distributed under the License is distributed on an
|
14
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
# KIND, either express or implied. See the License for the
|
16
|
+
# specific language governing permissions and limitations
|
17
|
+
# under the License.
|
18
|
+
#++
|
19
|
+
|
20
|
+
module Qpid # :nodoc:
|
21
|
+
|
22
|
+
module Proton # :nodoc:
|
23
|
+
|
24
|
+
def self.is_valid_utf?(value)
|
25
|
+
# In Ruby 1.9+ we have encoding methods that can check the content of
|
26
|
+
# the string, so use them to see if what we have is unicode. If so,
|
27
|
+
# good! If not, then just treat is as binary.
|
28
|
+
#
|
29
|
+
# No such thing in Ruby 1.8. So there we need to use Iconv to try and
|
30
|
+
# convert it to unicode. If it works, good! But if it raises an
|
31
|
+
# exception then we'll treat it as binary.
|
32
|
+
if RUBY_VERSION < "1.9"
|
33
|
+
return true if value.isutf8
|
34
|
+
return false
|
35
|
+
else
|
36
|
+
return true if (value.encoding == "UTF-8" ||
|
37
|
+
value.encode("UTF-8").valid_encoding?)
|
38
|
+
|
39
|
+
return false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# UTFString lets an application explicitly state that a
|
44
|
+
# string of characters is to be UTF-8 encoded.
|
45
|
+
#
|
46
|
+
class UTFString < ::String
|
47
|
+
|
48
|
+
def initialize(value)
|
49
|
+
if !Qpid::Proton.is_valid_utf?(value)
|
50
|
+
raise RuntimeError.new("invalid UTF string")
|
51
|
+
end
|
52
|
+
|
53
|
+
super(value)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
# BinaryString lets an application explicitly declare that
|
59
|
+
# a string value represents arbitrary data.
|
60
|
+
#
|
61
|
+
class BinaryString < ::String; end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
#--
|
2
2
|
# Licensed to the Apache Software Foundation (ASF) under one
|
3
3
|
# or more contributor license agreements. See the NOTICE file
|
4
4
|
# distributed with this work for additional information
|
@@ -15,11 +15,11 @@
|
|
15
15
|
# KIND, either express or implied. See the License for the
|
16
16
|
# specific language governing permissions and limitations
|
17
17
|
# under the License.
|
18
|
-
|
18
|
+
#++
|
19
19
|
|
20
|
-
module Qpid
|
20
|
+
module Qpid # :nodoc:
|
21
21
|
|
22
|
-
module Proton
|
22
|
+
module Proton # :nodoc:
|
23
23
|
|
24
24
|
# A +Subscription+ is an opaque object for working with a +Messenger+'s
|
25
25
|
# subscriptions.
|
data/lib/qpid_proton/tracker.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
#--
|
2
2
|
# Licensed to the Apache Software Foundation (ASF) under one
|
3
3
|
# or more contributor license agreements. See the NOTICE file
|
4
4
|
# distributed with this work for additional information
|
@@ -15,11 +15,11 @@
|
|
15
15
|
# KIND, either express or implied. See the License for the
|
16
16
|
# specific language governing permissions and limitations
|
17
17
|
# under the License.
|
18
|
-
|
18
|
+
#++
|
19
19
|
|
20
|
-
module Qpid
|
20
|
+
module Qpid # :nodoc:
|
21
21
|
|
22
|
-
module Proton
|
22
|
+
module Proton # :nodoc:
|
23
23
|
|
24
24
|
# A +Tracker+ is used to track the disposition of a +Message+.
|
25
25
|
#
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
#--
|
2
2
|
# Licensed to the Apache Software Foundation (ASF) under one
|
3
3
|
# or more contributor license agreements. See the NOTICE file
|
4
4
|
# distributed with this work for additional information
|
@@ -15,11 +15,11 @@
|
|
15
15
|
# KIND, either express or implied. See the License for the
|
16
16
|
# specific language governing permissions and limitations
|
17
17
|
# under the License.
|
18
|
-
|
18
|
+
#++
|
19
19
|
|
20
|
-
module Qpid
|
20
|
+
module Qpid # :nodoc:
|
21
21
|
|
22
|
-
module Proton
|
22
|
+
module Proton # :nodoc:
|
23
23
|
|
24
24
|
# TrackerStatus contains symbols that represent the status value for a
|
25
25
|
# Tracker.
|
data/lib/qpid_proton/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
#--
|
2
2
|
# Licensed to the Apache Software Foundation (ASF) under one
|
3
3
|
# or more contributor license agreements. See the NOTICE file
|
4
4
|
# distributed with this work for additional information
|
@@ -15,13 +15,16 @@
|
|
15
15
|
# KIND, either express or implied. See the License for the
|
16
16
|
# specific language governing permissions and limitations
|
17
17
|
# under the License.
|
18
|
-
|
18
|
+
#++
|
19
19
|
|
20
|
-
module Qpid
|
20
|
+
module Qpid # :nodoc:
|
21
21
|
|
22
|
-
module Proton
|
22
|
+
module Proton # :nodoc:
|
23
23
|
|
24
|
+
# The major version for the underlying Proton library.
|
24
25
|
VERSION_MAJOR = Cproton::PN_VERSION_MAJOR
|
26
|
+
|
27
|
+
# The minor version for the underlying Proton library.
|
25
28
|
VERSION_MINOR = Cproton::PN_VERSION_MINOR
|
26
29
|
|
27
30
|
end
|