qpid_messaging 0.20.2 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/LICENSE +0 -4
- data/README.rdoc +15 -20
- data/TODO +10 -5
- data/ext/cqpid/cqpid.cpp +156 -40
- data/ext/cqpid/extconf.rb +10 -2
- data/lib/qpid_messaging.rb +56 -3
- data/lib/qpid_messaging/address.rb +51 -28
- data/lib/qpid_messaging/connection.rb +75 -46
- data/lib/qpid_messaging/duration.rb +49 -14
- data/lib/qpid_messaging/encoding.rb +5 -5
- data/lib/qpid_messaging/message.rb +61 -68
- data/lib/qpid_messaging/receiver.rb +62 -67
- data/lib/qpid_messaging/sender.rb +39 -56
- data/lib/qpid_messaging/session.rb +78 -81
- metadata +51 -61
- data/Rakefile +0 -137
- data/features/closing_a_connection.feature +0 -13
- data/features/closing_a_session.feature +0 -13
- data/features/connecting_to_a_broker.feature +0 -13
- data/features/creating_a_receiver.feature +0 -29
- data/features/creating_a_sender.feature +0 -25
- data/features/creating_a_session.feature +0 -12
- data/features/getting_the_connections_authenticated_username.feature +0 -8
- data/features/receiving_a_message.feature +0 -30
- data/features/sending_a_message.feature +0 -21
- data/features/session_returns_its_connection.feature +0 -12
- data/features/sessions_have_names.feature +0 -8
- data/features/step_definitions/address_steps.rb +0 -22
- data/features/step_definitions/connection_steps.rb +0 -93
- data/features/step_definitions/receiver_steps.rb +0 -69
- data/features/step_definitions/sender_steps.rb +0 -34
- data/features/step_definitions/session_steps.rb +0 -99
- data/features/support/env.rb +0 -22
- data/lib/qpid_messaging/errors.rb +0 -33
- data/lib/qpid_messaging/version.rb +0 -31
- data/spec/qpid_messaging/address_spec.rb +0 -87
- data/spec/qpid_messaging/connection_spec.rb +0 -191
- data/spec/qpid_messaging/duration_spec.rb +0 -56
- data/spec/qpid_messaging/encoding_spec.rb +0 -63
- data/spec/qpid_messaging/message_spec.rb +0 -305
- data/spec/qpid_messaging/receiver_spec.rb +0 -170
- data/spec/qpid_messaging/sender_spec.rb +0 -135
- data/spec/qpid_messaging/session_spec.rb +0 -353
- data/spec/spec_helper.rb +0 -20
@@ -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,19 +15,19 @@
|
|
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
20
|
module Qpid
|
21
21
|
|
22
22
|
module Messaging
|
23
23
|
|
24
24
|
# Encodes the supplied content into the given message.
|
25
|
-
def self.encode content, message, encoding = nil
|
25
|
+
def self.encode content, message, encoding = nil # :nodoc:
|
26
26
|
Cqpid::encode content, message.message_impl, encoding
|
27
27
|
end
|
28
28
|
|
29
29
|
# Decodes and returns the message's content.
|
30
|
-
def self.decode(message, content_type = nil)
|
30
|
+
def self.decode(message, content_type = nil) # :nodoc:
|
31
31
|
content_type = message.content_type if content_type.nil?
|
32
32
|
|
33
33
|
case content_type
|
@@ -42,7 +42,7 @@ module Qpid
|
|
42
42
|
|
43
43
|
# Takes as input any type and converts anything that's a symbol
|
44
44
|
# into a string.
|
45
|
-
def self.stringify(value)
|
45
|
+
def self.stringify(value) # :nodoc:
|
46
46
|
# set the default value
|
47
47
|
result = value
|
48
48
|
|
@@ -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,27 +15,26 @@
|
|
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
20
|
module Qpid
|
21
21
|
|
22
22
|
module Messaging
|
23
23
|
|
24
24
|
# A +Message+ represents an routable piece of information.
|
25
|
-
#
|
26
|
-
# The content for a message is automatically encoded and decoded.
|
27
|
-
#
|
28
25
|
class Message
|
29
26
|
|
30
|
-
# Creates a
|
27
|
+
# Creates a +Message+.
|
31
28
|
#
|
32
29
|
# ==== Options
|
33
30
|
#
|
34
|
-
# *
|
31
|
+
# * +:content+ - the content
|
35
32
|
#
|
36
33
|
# ==== Examples
|
37
34
|
#
|
35
|
+
# # create a simple message and sends it
|
38
36
|
# message = Qpid::Messaging::Message.new :content => "This is a message."
|
37
|
+
# sender.send message
|
39
38
|
#
|
40
39
|
def initialize(args = {})
|
41
40
|
@message_impl = (args[:impl] if args[:impl]) || nil
|
@@ -49,15 +48,20 @@ module Qpid
|
|
49
48
|
@message_impl
|
50
49
|
end
|
51
50
|
|
52
|
-
# Sets the
|
51
|
+
# Sets the reply-to address.
|
52
|
+
#
|
53
|
+
# The address can either be an instance of Address or else and
|
54
|
+
# address string.
|
53
55
|
#
|
54
56
|
# ==== Options
|
55
57
|
#
|
56
|
-
# * address -
|
58
|
+
# * +address+ - the address
|
57
59
|
#
|
58
60
|
# ==== Examples
|
59
61
|
#
|
62
|
+
# # set replies using an Address
|
60
63
|
# msg.reply_to = Qpid:Messaging::Address.new "my-responses"
|
64
|
+
# # set replies using an address string
|
61
65
|
# msg.reply_to = "my-feed/responses"
|
62
66
|
#
|
63
67
|
def reply_to=(address)
|
@@ -67,7 +71,6 @@ module Qpid
|
|
67
71
|
end
|
68
72
|
|
69
73
|
# Returns the reply to address for the +Message+.
|
70
|
-
#
|
71
74
|
def reply_to
|
72
75
|
address_impl = @message_impl.getReplyTo
|
73
76
|
# only return an address if a reply to was specified
|
@@ -78,25 +81,15 @@ module Qpid
|
|
78
81
|
#
|
79
82
|
# ==== Options
|
80
83
|
#
|
81
|
-
# * subject - the subject
|
82
|
-
#
|
83
|
-
# ==== Examples
|
84
|
-
#
|
85
|
-
# msg.subject = "mysubject"
|
86
|
-
#
|
84
|
+
# * +subject+ - the subject
|
87
85
|
def subject=(subject); @message_impl.setSubject subject; end
|
88
86
|
|
89
87
|
# Returns the subject of the +Message+.
|
90
|
-
#
|
91
|
-
# ==== Options
|
92
|
-
#
|
93
|
-
# puts "The subject is #{msg.subject}"
|
94
|
-
#
|
95
88
|
def subject; @message_impl.getSubject; end
|
96
89
|
|
97
90
|
# Sets the content type for the +Message+.
|
98
91
|
#
|
99
|
-
# This should be set by the sending
|
92
|
+
# This should be set by the sending application and indicates to the
|
100
93
|
# recipients of the message how to interpret or decode the content.
|
101
94
|
#
|
102
95
|
# By default, only dictionaries and maps are automatically given a content
|
@@ -105,23 +98,17 @@ module Qpid
|
|
105
98
|
#
|
106
99
|
# ==== Options
|
107
100
|
#
|
108
|
-
# * content_type - the content type
|
109
|
-
#
|
110
|
-
def content_type=(content_type); @message_impl.setContentType content_type; end
|
111
|
-
|
112
|
-
# Returns the content type for the +Message+.
|
101
|
+
# * +content_type+ - the content type
|
113
102
|
#
|
114
103
|
# ==== Examples
|
115
104
|
#
|
116
|
-
#
|
117
|
-
#
|
118
|
-
#
|
119
|
-
# end
|
120
|
-
# when "myapp/audio"
|
121
|
-
# ctl.handle_audio msg
|
122
|
-
# end
|
123
|
-
# end
|
105
|
+
# # send base64 encoded data in a mesage
|
106
|
+
# msg = Qpid::Messaging::Message.new :content = "UXBpZCBSdWxlcyEK"
|
107
|
+
# msg.content_type = "application/base64"
|
124
108
|
#
|
109
|
+
def content_type=(content_type); @message_impl.setContentType content_type; end
|
110
|
+
|
111
|
+
# Returns the content type for the +Message+.
|
125
112
|
def content_type; @message_impl.getContentType; end
|
126
113
|
|
127
114
|
# Sets the message id.
|
@@ -131,16 +118,17 @@ module Qpid
|
|
131
118
|
#
|
132
119
|
# ==== Options
|
133
120
|
#
|
134
|
-
# * id - the id
|
121
|
+
# * +id+ - the id
|
135
122
|
#
|
136
123
|
# ==== Examples
|
137
124
|
#
|
125
|
+
# # this example only works in Ruby >= 1.9, for 1.8 use a UUID library
|
126
|
+
# require 'SecureRandom'
|
127
|
+
# msg.message_id = SecureRandom.uuid
|
138
128
|
#
|
139
129
|
def message_id=(message_id); @message_impl.setMessageId message_id.to_s; end
|
140
130
|
|
141
131
|
# Returns the message id.
|
142
|
-
#
|
143
|
-
# See +message_id=+ for details.
|
144
132
|
def message_id; @message_impl.getMessageId; end
|
145
133
|
|
146
134
|
# Sets the user id for the +Message+.
|
@@ -149,44 +137,38 @@ module Qpid
|
|
149
137
|
# the connection itself, as the messaging infrastructure will verify
|
150
138
|
# this.
|
151
139
|
#
|
152
|
-
# See
|
140
|
+
# See Qpid::Messaging::Connection.authenticated_username
|
153
141
|
#
|
154
142
|
# *NOTE:* If the id is not a +String+ then the id is set using
|
155
143
|
# the object's string representation.
|
156
144
|
#
|
157
145
|
# ==== Options
|
158
146
|
#
|
159
|
-
# * id - the id
|
147
|
+
# * +id+ - the id
|
160
148
|
#
|
161
149
|
def user_id=(user_id); @message_impl.setUserId user_id; end
|
162
150
|
|
163
151
|
# Returns the user id for the +Message+.
|
164
|
-
#
|
165
|
-
# See +user_id=+ for details.
|
166
|
-
#
|
167
152
|
def user_id; @message_impl.getUserId; end
|
168
153
|
|
169
154
|
# Sets the correlation id of the +Message+.
|
170
155
|
#
|
171
156
|
# The correlation id can be used as part of a protocol for message
|
172
|
-
# exchange patterns; e.g., a
|
157
|
+
# exchange patterns; e.g., a request-response pattern might require
|
173
158
|
# the correlation id of the request and the response to match, or it
|
174
159
|
# might use the message id of the request as the correlation id on
|
175
|
-
# the response
|
160
|
+
# the response.
|
176
161
|
#
|
177
162
|
# *NOTE:* If the id is not a +String+ then the id is setup using
|
178
163
|
# the object's string representation.
|
179
164
|
#
|
180
165
|
# ==== Options
|
181
166
|
#
|
182
|
-
# * id - the id
|
167
|
+
# * +id+ - the id
|
183
168
|
#
|
184
169
|
def correlation_id=(correlation_id); @message_impl.setCorrelationId correlation_id; end
|
185
170
|
|
186
171
|
# Returns the correlation id of the +Message+.
|
187
|
-
#
|
188
|
-
# *NOTE:* See +correlation_id=+ for details.
|
189
|
-
#
|
190
172
|
def correlation_id; @message_impl.getCorrelationId; end
|
191
173
|
|
192
174
|
# Sets the priority of the +Message+.
|
@@ -200,19 +182,21 @@ module Qpid
|
|
200
182
|
#
|
201
183
|
# ==== Options
|
202
184
|
#
|
203
|
-
# * priority - the priority
|
185
|
+
# * +priority+ - the priority
|
204
186
|
#
|
205
187
|
def priority=(priority); @message_impl.setPriority priority; end
|
206
188
|
|
207
189
|
# Returns the priority for the +Message+.
|
208
|
-
#
|
209
190
|
def priority; @message_impl.getPriority; end
|
210
191
|
|
211
192
|
# Sets the time-to-live in milliseconds.
|
212
193
|
#
|
194
|
+
# This can be used by the messaging infrastructure to discard messages
|
195
|
+
# that are no longer of relevance.
|
196
|
+
#
|
213
197
|
# ==== Options
|
214
198
|
#
|
215
|
-
# * duration - the number of milliseconds
|
199
|
+
# * +duration+ - the number of milliseconds
|
216
200
|
#
|
217
201
|
def ttl=(duration)
|
218
202
|
if duration.is_a? Qpid::Messaging::Duration
|
@@ -229,16 +213,15 @@ module Qpid
|
|
229
213
|
#
|
230
214
|
# This is a hint to the messaging infrastructure that the message
|
231
215
|
# should be persisted or otherwise stored. This helps to ensure
|
232
|
-
# that
|
216
|
+
# that the message is not lost due to failures or a shutdown.
|
233
217
|
#
|
234
218
|
# ==== Options
|
235
219
|
#
|
236
|
-
# * durable - the durability flag (def. false)
|
220
|
+
# * +durable+ - the durability flag (def. false)
|
237
221
|
#
|
238
222
|
def durable=(durable); @message_impl.setDurable durable; end
|
239
223
|
|
240
224
|
# Returns the durability for the +Message+.
|
241
|
-
#
|
242
225
|
def durable; @message_impl.getDurable; end
|
243
226
|
|
244
227
|
# This is a hint to the messaging infrastructure that if de-duplication
|
@@ -247,17 +230,16 @@ module Qpid
|
|
247
230
|
#
|
248
231
|
# ==== Options
|
249
232
|
#
|
250
|
-
# * redelivered - sets the redelivered state (def. false)
|
233
|
+
# * +redelivered+ - sets the redelivered state (def. false)
|
251
234
|
#
|
252
235
|
# ==== Examples
|
253
236
|
#
|
254
|
-
# # processed is
|
237
|
+
# # processed is a collection of messages already received
|
255
238
|
# msg.redelivered = true if processed.include? msg.message_id
|
256
239
|
#
|
257
240
|
def redelivered=(redelivered); @message_impl.setRedelivered redelivered; end
|
258
241
|
|
259
242
|
# Returns whether the +Message+ has been marked as redelivered.
|
260
|
-
#
|
261
243
|
def redelivered; @message_impl.getRedelivered; end
|
262
244
|
|
263
245
|
# Returns all named properties.
|
@@ -265,14 +247,13 @@ module Qpid
|
|
265
247
|
# *NOTE:* It is recommended to use the []= method for
|
266
248
|
# retrieving and setting properties. Using this method may
|
267
249
|
# result in non-deterministic behavior.
|
268
|
-
#
|
269
250
|
def properties; @message_impl.getProperties; end
|
270
251
|
|
271
252
|
# Returns the value for the named property.
|
272
253
|
#
|
273
254
|
# ==== Options
|
274
255
|
#
|
275
|
-
# * name - the property name
|
256
|
+
# * +name+ - the property name
|
276
257
|
#
|
277
258
|
# ==== Examples
|
278
259
|
#
|
@@ -283,10 +264,21 @@ module Qpid
|
|
283
264
|
|
284
265
|
# Assigns a value to the named property.
|
285
266
|
#
|
267
|
+
# A property's name or value, if a symbol, will be converted to a string
|
268
|
+
# representation. However, you will still be able to access them using
|
269
|
+
# a symbol for the name.
|
270
|
+
#
|
286
271
|
# ==== Options
|
287
272
|
#
|
288
|
-
# * name - the property name
|
289
|
-
# * value - the property value
|
273
|
+
# * +name+ - the property name
|
274
|
+
# * +value+ - the property value
|
275
|
+
#
|
276
|
+
# ==== Examples
|
277
|
+
#
|
278
|
+
# # set the signed attribute on a message and then retrieve it
|
279
|
+
# msg[:signed] = true # sets "signed" => true
|
280
|
+
# puts "It's signed" if msg["signed"] # outputs "It's signed"
|
281
|
+
#
|
290
282
|
def []=(key, value)
|
291
283
|
@message_impl.setProperty(key.to_s,
|
292
284
|
Qpid::Messaging.stringify(value))
|
@@ -295,17 +287,19 @@ module Qpid
|
|
295
287
|
# Sets the content for the +Message+.
|
296
288
|
#
|
297
289
|
# Content is automatically encoded for Array and Hash types. Other types
|
298
|
-
# need to set their own content types (via
|
290
|
+
# need to set their own content types (via content_type) in order to
|
299
291
|
# specify how recipients should process the content.
|
300
292
|
#
|
301
293
|
# ==== Options
|
302
294
|
#
|
303
|
-
# * content - the content
|
295
|
+
# * +content+ - the content
|
304
296
|
#
|
305
297
|
# ==== Examples
|
306
298
|
#
|
307
|
-
#
|
308
|
-
# msg.content =
|
299
|
+
# # set a simple content for a message
|
300
|
+
# msg.content = "This is a simple message."
|
301
|
+
# # sets content that is automatically encoded
|
302
|
+
# msg.content = {:foo => :bar}
|
309
303
|
#
|
310
304
|
def content=(content)
|
311
305
|
content_type = nil
|
@@ -348,8 +342,7 @@ module Qpid
|
|
348
342
|
@content
|
349
343
|
end
|
350
344
|
|
351
|
-
# Returns the content's size.
|
352
|
-
#
|
345
|
+
# Returns the content's size in bytes.
|
353
346
|
def content_size; @message_impl.getContentSize; end
|
354
347
|
|
355
348
|
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,23 +15,32 @@
|
|
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
20
|
module Qpid
|
21
21
|
|
22
22
|
module Messaging
|
23
23
|
|
24
|
-
# Receiver is the entity through which messages are received.
|
24
|
+
# +Receiver+ is the entity through which messages are received.
|
25
25
|
#
|
26
|
-
# An instance of Receiver can only be created using an active (not
|
27
|
-
# previously closed) Session.
|
26
|
+
# An instance of +Receiver+ can only be created using an active (i.e., not
|
27
|
+
# previously closed) Session. See Qpid::Messaging::Session.create_receiver
|
28
|
+
# for more details.
|
28
29
|
#
|
29
30
|
# ==== Example
|
30
31
|
#
|
32
|
+
# # create a connection and a session
|
31
33
|
# conn = Qpid::Messaging::Connection.new :url => "mybroker:5762"
|
32
34
|
# conn.open
|
33
35
|
# session = conn.create_session
|
34
|
-
#
|
36
|
+
#
|
37
|
+
# # create a receiver that listens on the "updates" topic of "alerts"
|
38
|
+
# receiver = session.create_receiver "alerts/updates"
|
39
|
+
#
|
40
|
+
# # wait for an incoming message and process it
|
41
|
+
# incoming = receiver.get Qpid::Messaging::Duration::FOREVER
|
42
|
+
# process(incoming)
|
43
|
+
#
|
35
44
|
class Receiver
|
36
45
|
|
37
46
|
def initialize(session, receiver_impl) # :nodoc:
|
@@ -46,27 +55,24 @@ module Qpid
|
|
46
55
|
# Retrieves a message from the local queue, or waits for up to
|
47
56
|
# the duration specified for one to become available.
|
48
57
|
#
|
49
|
-
# If
|
50
|
-
# is
|
51
|
-
# respectively.
|
58
|
+
# If no message is received within the specified time then a
|
59
|
+
# MessagingException is raised.
|
52
60
|
#
|
53
61
|
# ==== Options
|
54
|
-
# * duration - the timeout to wait (def. Duration::FOREVER)
|
55
|
-
#
|
56
|
-
# ==== Examples
|
57
62
|
#
|
58
|
-
#
|
63
|
+
# * duration - the timeout to wait
|
59
64
|
#
|
60
|
-
#
|
65
|
+
# ==== Examples
|
61
66
|
#
|
62
|
-
# #
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
67
|
+
# # retrieves a message, also handles exceptions raised on no messages
|
68
|
+
# begin
|
69
|
+
# # checks for a message, returning immediately
|
70
|
+
# msg = recv.get Qpid::Messaging::Duration::IMMEDIATE
|
71
|
+
# puts "Received this message: #{message.content}"
|
72
|
+
# rescue
|
73
|
+
# puts "No messages available.
|
69
74
|
# end
|
75
|
+
#
|
70
76
|
def get(duration = Qpid::Messaging::Duration::FOREVER)
|
71
77
|
message_impl = @receiver_impl.get duration.duration_impl
|
72
78
|
create_message_wrapper message_impl unless message_impl.nil?
|
@@ -75,33 +81,35 @@ module Qpid
|
|
75
81
|
# Retrieves a message from the receiver's subscription, or waits
|
76
82
|
# for up to the duration specified for one to become available.
|
77
83
|
#
|
78
|
-
# If
|
79
|
-
# is
|
80
|
-
# respectively.
|
84
|
+
# If no message is fetched within the specified time then a
|
85
|
+
# MessagingException is raised.
|
81
86
|
#
|
82
87
|
# ==== Options
|
88
|
+
#
|
83
89
|
# * duration - the timeout to wait (def. Duration::FOREVER)
|
84
90
|
#
|
85
91
|
# ==== Examples
|
86
92
|
#
|
87
|
-
#
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
#
|
94
|
-
# puts "No message was received."
|
95
|
-
# else
|
96
|
-
# puts "Received this message: #{message.content}"
|
97
|
-
# end
|
93
|
+
# # retrieves a message, also handles exceptions raised on no messages
|
94
|
+
# begin
|
95
|
+
# # checks for a message, times out after one second
|
96
|
+
# msg = recv.fetch Qpid::Messaging::Duration::SECOND
|
97
|
+
# puts "Fetched this message: #{message.content}"
|
98
|
+
# rescue
|
99
|
+
# puts "No messages available.
|
98
100
|
# end
|
101
|
+
#
|
99
102
|
def fetch(duration = Qpid::Messaging::Duration::FOREVER)
|
100
103
|
message_impl = @receiver_impl.fetch duration.duration_impl
|
101
104
|
create_message_wrapper message_impl unless message_impl.nil?
|
102
105
|
end
|
103
106
|
|
104
|
-
# Sets the capacity
|
107
|
+
# Sets the capacity.
|
108
|
+
#
|
109
|
+
# The capacity of a +Receiver+ is the number of Messages that can be
|
110
|
+
# pre-fetched from the broker and held locally. If capacity is 0 then
|
111
|
+
# messages will never be pre-fetched and all messages must instead be
|
112
|
+
# retrieved using #fetch.
|
105
113
|
#
|
106
114
|
# ==== Options
|
107
115
|
#
|
@@ -109,63 +117,50 @@ module Qpid
|
|
109
117
|
#
|
110
118
|
# ==== Examples
|
111
119
|
#
|
112
|
-
#
|
120
|
+
# # create a receiver and give it a capacity of 50
|
121
|
+
# recv = session.create_receiver "alerts/minor"
|
122
|
+
# recv.capacity = 50
|
113
123
|
#
|
114
124
|
def capacity=(capacity); @receiver_impl.setCapacity capacity; end
|
115
125
|
|
116
126
|
# Returns the capacity.
|
117
|
-
#
|
118
|
-
#
|
119
|
-
# The capacity is the numnber of incoming messages that can be held
|
120
|
-
# locally before being fetched.
|
121
|
-
#
|
122
|
-
# ==== Examples
|
123
|
-
#
|
124
|
-
# puts "The receiver can hold #{rcv.capacity} messages."
|
125
|
-
#
|
126
127
|
def capacity; @receiver_impl.getCapacity; end
|
127
128
|
|
128
|
-
# Returns the number of
|
129
|
+
# Returns the number of messages locally held.
|
130
|
+
#
|
131
|
+
# The available is always 0 <= available <= capacity.
|
129
132
|
#
|
130
|
-
#
|
131
|
-
# the capacity for holding incoming messages, where available <= capacity.
|
133
|
+
# If the #capacity is set to 0 then available will always be 0.
|
132
134
|
#
|
133
135
|
# ==== Examples
|
134
136
|
#
|
135
|
-
#
|
137
|
+
# # output the number of messages waiting while processing
|
138
|
+
# loop do
|
139
|
+
# puts "There are #{recv.available} messages pending..."
|
140
|
+
# # wait forever (the default) for the next message
|
141
|
+
# msg = recv.get
|
142
|
+
# # process the message
|
143
|
+
# dispatch_message msg
|
144
|
+
# end
|
136
145
|
#
|
137
146
|
def available; @receiver_impl.getAvailable; end
|
138
147
|
|
139
148
|
# Returns the number of messages that have been received and acknowledged
|
140
149
|
# but whose acknowledgements have not been confirmed by the sender.
|
141
|
-
#
|
142
|
-
# ==== Examples
|
143
|
-
#
|
144
|
-
# puts "You have #{rcv.unsettled} messages to be confirmed."
|
145
|
-
#
|
146
150
|
def unsettled; @receiver_impl.getUnsettled; end
|
147
151
|
|
148
152
|
# Closes this +Receiver+.
|
149
153
|
#
|
150
|
-
# This does not affect the
|
154
|
+
# This does not affect the owning Session or Connection.
|
151
155
|
def close; @receiver_impl.close; end
|
152
156
|
|
153
|
-
# Returns whether the
|
154
|
-
#
|
155
|
-
# ==== Examples
|
156
|
-
#
|
157
|
-
# recv.close unless recv.closed?
|
158
|
-
#
|
157
|
+
# Returns whether the +Receiver+ is closed.
|
159
158
|
def closed?; @receiver_impl.isClosed; end
|
160
159
|
|
161
160
|
# Returns the name of this +Receiver+.
|
162
|
-
#
|
163
|
-
# ==== Examples
|
164
|
-
#
|
165
|
-
# puts "Receiver: #{recv.name}"
|
166
161
|
def name; @receiver_impl.getName; end
|
167
162
|
|
168
|
-
# Returns the Session for this +Receiver+.
|
163
|
+
# Returns the owning Session for this +Receiver+.
|
169
164
|
def session; @session; end
|
170
165
|
|
171
166
|
private
|