qpid_messaging 0.20.2 → 0.22.0

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.
Files changed (45) hide show
  1. data/ChangeLog +4 -0
  2. data/LICENSE +0 -4
  3. data/README.rdoc +15 -20
  4. data/TODO +10 -5
  5. data/ext/cqpid/cqpid.cpp +156 -40
  6. data/ext/cqpid/extconf.rb +10 -2
  7. data/lib/qpid_messaging.rb +56 -3
  8. data/lib/qpid_messaging/address.rb +51 -28
  9. data/lib/qpid_messaging/connection.rb +75 -46
  10. data/lib/qpid_messaging/duration.rb +49 -14
  11. data/lib/qpid_messaging/encoding.rb +5 -5
  12. data/lib/qpid_messaging/message.rb +61 -68
  13. data/lib/qpid_messaging/receiver.rb +62 -67
  14. data/lib/qpid_messaging/sender.rb +39 -56
  15. data/lib/qpid_messaging/session.rb +78 -81
  16. metadata +51 -61
  17. data/Rakefile +0 -137
  18. data/features/closing_a_connection.feature +0 -13
  19. data/features/closing_a_session.feature +0 -13
  20. data/features/connecting_to_a_broker.feature +0 -13
  21. data/features/creating_a_receiver.feature +0 -29
  22. data/features/creating_a_sender.feature +0 -25
  23. data/features/creating_a_session.feature +0 -12
  24. data/features/getting_the_connections_authenticated_username.feature +0 -8
  25. data/features/receiving_a_message.feature +0 -30
  26. data/features/sending_a_message.feature +0 -21
  27. data/features/session_returns_its_connection.feature +0 -12
  28. data/features/sessions_have_names.feature +0 -8
  29. data/features/step_definitions/address_steps.rb +0 -22
  30. data/features/step_definitions/connection_steps.rb +0 -93
  31. data/features/step_definitions/receiver_steps.rb +0 -69
  32. data/features/step_definitions/sender_steps.rb +0 -34
  33. data/features/step_definitions/session_steps.rb +0 -99
  34. data/features/support/env.rb +0 -22
  35. data/lib/qpid_messaging/errors.rb +0 -33
  36. data/lib/qpid_messaging/version.rb +0 -31
  37. data/spec/qpid_messaging/address_spec.rb +0 -87
  38. data/spec/qpid_messaging/connection_spec.rb +0 -191
  39. data/spec/qpid_messaging/duration_spec.rb +0 -56
  40. data/spec/qpid_messaging/encoding_spec.rb +0 -63
  41. data/spec/qpid_messaging/message_spec.rb +0 -305
  42. data/spec/qpid_messaging/receiver_spec.rb +0 -170
  43. data/spec/qpid_messaging/sender_spec.rb +0 -135
  44. data/spec/qpid_messaging/session_spec.rb +0 -353
  45. 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,23 +15,39 @@
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
- # Sender is the entity through which messages sent.
24
+ # +Sender+ is the entity through which messages are sent.
25
25
  #
26
- # An instance of Sender can only be created using an active (not previously
27
- # closed) Session.
26
+ # An instance of +Sender+ can only be created using an active (not previously
27
+ # closed) Session. See Qpid::Messaging::Session.create_sender for more details.
28
28
  #
29
29
  # ==== Examples
30
30
  #
31
- # conn = Qpid::Messaging::Connection.new :url => "mybroker:5762"
31
+ # # create a connection
32
+ # conn = Qpid::Messaging::Connection.new "mybroker:5672"
32
33
  # conn.open
33
- # session = conn.create_session
34
- # sender = session.create_session "my-sender-queue;{create:always}"
34
+ #
35
+ # if conn.open?
36
+ #
37
+ # # create a session
38
+ # session = conn.create_session
39
+ #
40
+ # # create a sender that posts messages to the "updates" queue
41
+ # sender = session.create_sender "updates;{create:always}
42
+ #
43
+ # # begin sending updates
44
+ # loop do
45
+ # # wait for the next event content then send it
46
+ # content = wait_for_event
47
+ # sender.send Qpid::Messaging::Message.new :content => content
48
+ # end
49
+ # end
50
+ #
35
51
  class Sender
36
52
 
37
53
  def initialize(session, sender_impl) # :nodoc:
@@ -43,15 +59,13 @@ module Qpid
43
59
  @sender_impl
44
60
  end
45
61
 
46
- # Sends a message.
47
- #
48
- # If a block is given, then it will be invoked after the message
49
- # is sent.
62
+ # Sends a message, optionally blocking until the message is received
63
+ # by the broker.
50
64
  #
51
65
  # ==== Options
52
66
  #
53
- # * message - The message to send.
54
- # * :sync - See note below on synching.
67
+ # * +message+ - The message to send.
68
+ # * +:sync+ - Block until received. See note below on synching.
55
69
  #
56
70
  # ==== Synching
57
71
  #
@@ -61,9 +75,13 @@ module Qpid
61
75
  #
62
76
  # ==== Examples
63
77
  #
64
- # sender.send message do |message|
65
- # puts "Message sent: #{message.content}"
66
- # end
78
+ # # send a message
79
+ # outgoing = Qpid::Messaging::Message.new :content => content
80
+ # sender.send outgoing
81
+ #
82
+ # # send a message, wait for confirmation from the broker
83
+ # outgoing = Qpid::Messaging::Message.new :content => content
84
+ # sender.send outgoing, :sync => true
67
85
  #
68
86
  def send(message, args = {}, &block)
69
87
  sync = args[:sync] || false
@@ -73,52 +91,27 @@ module Qpid
73
91
 
74
92
  # Closes this +Sender+.
75
93
  #
76
- # This does not affect the +Session+.
94
+ # This does not affect the owning Session or Connection.
77
95
  def close; @sender_impl.close; end
78
96
 
79
97
  # Returns the human-readable name for this +Sender+.
80
- #
81
- # ==== Examples
82
- #
83
- # puts "Sender: #{sender.name}"
84
- #
85
98
  def name; @sender_impl.getName; end
86
99
 
87
100
  # Sets the capacity for this +Sender+.
88
101
  #
89
102
  # The capacity is the number of outgoing messages that can be held
90
- # pending confirmation or receipt by the broker.
103
+ # pending confirmation of receipt by the broker.
91
104
  #
92
105
  # ==== Options
93
106
  #
94
- # * capacity - the capacity
95
- #
96
- # ==== Examples
97
- #
98
- # sender.capacity = 50 # sets the outgoing capacity to 50 messages
99
- #
107
+ # * +capacity+ - the capacity
100
108
  def capacity=(capacity); @sender_impl.setCapacity capacity; end
101
109
 
102
110
  # Returns the capacity.
103
- #
104
- # The capacity is the total number of outgoing messages that can be
105
- # sent before a called to +send+ begins to block by default.
106
- #
107
- # ==== Examples
108
- #
109
- # puts "You can send a maximum of #{sender.capacity} messages."
110
- #
111
111
  def capacity; @sender_impl.getCapacity; end
112
112
 
113
113
  # Returns the number of messages sent that are pending receipt
114
114
  # confirmation by the broker.
115
- #
116
- # ==== Examples
117
- #
118
- # if sender.unsettled > 0
119
- # puts "There are #{sender.unsettled} messages pending."
120
- # end
121
- #
122
115
  def unsettled; @sender_impl.getUnsettled; end
123
116
 
124
117
  # Returns the available slots for sending messages.
@@ -127,21 +120,11 @@ module Qpid
127
120
  # the senders capacity for holding outgoing messages. The difference
128
121
  # between capacity and available is the number of messages that
129
122
  # have not been delivered yet.
130
- #
131
- # ==== Examples
132
- #
133
- # puts "You can send #{sender.available} messages before blocking."
134
- #
135
123
  def available
136
124
  @sender_impl.getAvailable
137
125
  end
138
126
 
139
- # Returns the +Session+ for this sender.
140
- #
141
- # ==== Examples
142
- #
143
- # recv.session.close if done
144
- #
127
+ # Returns the Session for this sender.
145
128
  def session; @session; end
146
129
 
147
130
  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,44 +15,41 @@
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
- # A Session represents a distinct conversation between end points.
24
+ # A +Session+ represents a distinct conversation between end points. They are
25
+ # created from an active (i.e., not closed) Connection.
26
+ #
27
+ # A +Session+ is used to acknowledge individual or all messages that have
28
+ # passed through it
25
29
  class Session
26
30
 
27
31
  def initialize(connection, session) # :nodoc:
28
32
  @connection = connection
29
33
  @session_impl = session
30
- @senders = Hash.new
31
- @receivers = Hash.new
32
34
  end
33
35
 
34
36
  def session_impl # :nodoc:
35
37
  @session_impl
36
38
  end
37
39
 
38
- # Returns the +Connection+ associated with this session.
40
+ # Returns the Connection associated with this session.
39
41
  def connection
40
42
  @connection
41
43
  end
42
44
 
43
45
  # Creates a new endpoint for sending messages.
44
46
  #
45
- # The +address+ can either be an instance +Address+ or else a
46
- # string that describes an address endpoint.
47
+ # The address can either be an instance Address or else an
48
+ # address string.
47
49
  #
48
50
  # ==== Arguments
49
51
  #
50
- # * +address+ The end point address.
51
- #
52
- # ==== Examples
53
- #
54
- # sender = session.create_sender "my-queue;{create:always}"
55
- #
52
+ # * +address+ - the end point address.
56
53
  def create_sender(address)
57
54
  _address = address
58
55
 
@@ -63,43 +60,28 @@ module Qpid
63
60
  sender_impl = @session_impl.createSender(_address)
64
61
  sender_name = sender_impl.getName
65
62
 
66
- @senders[sender_name] = Qpid::Messaging::Sender.new(self, sender_impl)
67
-
68
- @senders[sender_name]
63
+ Qpid::Messaging::Sender.new(self, sender_impl)
69
64
  end
70
65
 
71
- # Retrieves the +Sender+ with the specified name.
66
+ # Retrieves the Sender with the specified name.
72
67
  #
73
- # The +Sender+ must have been previously created using
74
- # the +create_sender+ method.
68
+ # Raises an exception if no such Sender exists.
75
69
  #
76
70
  # ==== Arguments
77
71
  #
78
- # * +name+ The +Sender+ name.
79
- #
80
- # ==== Examples
81
- #
82
- # sender = session.sender "my-queue"
83
- #
72
+ # * +name+ - the name of the Sender
84
73
  def sender(name)
85
- raise Qpid::Messaging::KeyError, "No such sender: #{name}" unless @senders.has_key? name
86
-
87
- @senders[name]
74
+ Qpid::Messaging::Sender.new self, @session_impl.getSender(name)
88
75
  end
89
76
 
90
77
  # Creates a new endpoint for receiving messages.
91
78
  #
92
- # The +address+ can either be an instance +Address+ or else a
93
- # string that describes an address endpoint.
79
+ # The +address+ can either be an instance Address or else an
80
+ # address string.
94
81
  #
95
82
  # ==== Arguments
96
83
  #
97
- # * +address+ The end point address.
98
- #
99
- # ==== Examples
100
- #
101
- # receiver = session.create_receiver "my-queue"
102
- #
84
+ # * +address+ - the end point address.
103
85
  def create_receiver(address)
104
86
  result = nil
105
87
  receiver_impl = nil
@@ -111,36 +93,24 @@ module Qpid
111
93
  receiver_impl = @session_impl.createReceiver(address)
112
94
  end
113
95
 
114
- receiver_name = receiver_impl.getName
115
-
116
- @receivers[receiver_name] = Qpid::Messaging::Receiver.new self, receiver_impl
117
-
118
- @receivers[receiver_name]
96
+ Qpid::Messaging::Receiver.new self, receiver_impl
119
97
  end
120
98
 
121
- # Retrieves the +Receiver+ with the specified name.
122
- #
123
- # The +Receiver+ must have been previously created using
124
- # the +create_receiver+ method.
99
+ # Retrieves the +Receiver+ with the specified name, or nil if no such
100
+ # Receiver exists.
125
101
  #
126
102
  # ==== Arguments
127
103
  #
128
- # * +name+ The +Receiver+ name.
129
- #
130
- # ==== Examples
131
- #
132
- # receiver = session.receiver "my-queue"
133
- #
104
+ # * +name+ - the name of the Receiver
134
105
  def receiver(name)
135
- raise Qpid::Messaging::KeyError, "No such receiver: #{name}" unless @receivers.has_key? name
136
-
137
- @receivers[name]
106
+ Qpid::Messaging::Receiver.new self, @session_impl.getReceiver(name)
138
107
  end
139
108
 
140
109
  # Closes the +Session+ and all associated +Sender+ and +Receiver+ instances.
141
110
  #
142
- # NOTE: All +Session+ instances for a +Connection+ are closed when the
143
- # +Connection+ is closed.
111
+ # *NOTE:* All +Session+ instances for a Connection are closed when the
112
+ # Connection is closed. But closing a +Session+ does not affect the
113
+ # owning Connection.
144
114
  def close; @session_impl.close; end
145
115
 
146
116
  # Commits any pending transactions for a transactional session.
@@ -154,21 +124,30 @@ module Qpid
154
124
  #
155
125
  # ==== Arguments
156
126
  #
157
- # * :message - if specified, then only the +Message+ specified is acknowledged
158
- # * :sync - if true then the call will block until processed by the server (def. false)
127
+ # * +options+ - the set of options
128
+ #
129
+ # ==== Options
130
+ #
131
+ # * :message - if specified, then only that Message is acknowledged
132
+ # * :sync - if true, the call will block until processed by the broker
159
133
  #
160
134
  # ==== Examples
161
135
  #
162
- # session.acknowledge # acknowledges all received messages
163
- # session.acknowledge :message => message # acknowledge one message
164
- # session.acknowledge :sync => true # blocks until the call completes
136
+ # # acknowledge all received messages
137
+ # session.acknowledge
138
+ #
139
+ # # acknowledge a single message
140
+ # session.acknowledge :message => message
141
+ #
142
+ # # acknowledge all messages, wait until the call finishes
143
+ # session.acknowledge :sync => true
165
144
  #
166
145
  #--
167
146
  # TODO: Add an optional block to be used for blocking calls.
168
147
  #++
169
- def acknowledge(args = {})
170
- sync = args[:sync] || false
171
- message = args[:message] if args[:message]
148
+ def acknowledge(options = {})
149
+ sync = options[:sync] || false
150
+ message = options[:message] if options[:message]
172
151
 
173
152
  unless message.nil?
174
153
  @session_impl.acknowledge message.message_impl, sync
@@ -189,11 +168,15 @@ module Qpid
189
168
  # NOTE: A message connot be released once it has been acknowled.
190
169
  def release(message); @session_impl.release message.message_impl; end
191
170
 
192
- # Requests synchronization with the server.
171
+ # Requests synchronization with the broker.
193
172
  #
194
173
  # ==== Arguments
195
174
  #
196
- # * :block - if true then the call blocks until the server acknowledges it (def. false)
175
+ # * +options+ - the list of options
176
+ #
177
+ # ==== Options
178
+ #
179
+ # * +:block+ - if true, the call blocks until the broker acknowledges it
197
180
  #
198
181
  #--
199
182
  # TODO: Add an optional block to be used for blocking calls.
@@ -204,26 +187,43 @@ module Qpid
204
187
  end
205
188
 
206
189
  # Returns the total number of receivable messages, and messages already
207
- # received, by +Receiver+ instances associated with this +Session+.
190
+ # received, by Receiver instances associated with this +Session+.
208
191
  def receivable; @session_impl.getReceivable; end
209
192
 
210
- # Returns the number of messages that have been acknowledged by this session
211
- # whose acknowledgements have not been confirmed as processed by the server.
193
+ # Returns the number of messages that have been acknowledged by this
194
+ # +Session+ whose acknowledgements have not been confirmed as processed
195
+ # by the broker.
212
196
  def unsettled_acks; @session_impl.getUnsettledAcks; end
213
197
 
214
- # Fetches the +Receiver+ for the next message.
198
+ # Fetches the next Receiver with a message pending. Waits the specified
199
+ # number of milliseconds before timing out.
200
+ #
201
+ # For a Receiver to be returned, it must have a capacity > 0 and have
202
+ # Messages locally queued.
203
+ #
204
+ # If no Receiver is found within the time out period, then a MessageError
205
+ # is raised.
215
206
  #
216
207
  # ==== Arguments
217
208
  #
218
- # * timeout - time to wait for a +Receiver+ before timing out
209
+ # * +timeout+ - the duration
219
210
  #
220
211
  # ==== Examples
221
212
  #
222
- # recv = session.next_receiver # wait forever for the next +Receiver+
223
- # # execute a block on the next receiver
224
- # session.next_receiver do |recv|
225
- # msg = recv.get
226
- # puts "Received message: #{msg.content}"
213
+ # loop do
214
+ #
215
+ # begin
216
+ # # wait a maximum of one minute for the next receiver to be ready
217
+ # recv = session.next_receiver Qpid::Messaging::Duration::MINUTE
218
+ #
219
+ # # get and dispatch the message
220
+ # msg = recv.get
221
+ # dispatch_message msg
222
+ #
223
+ # rescue
224
+ # puts "No receivers were returned"
225
+ # end
226
+ #
227
227
  # end
228
228
  def next_receiver(timeout = Qpid::Messaging::Duration::FOREVER, &block)
229
229
  receiver_impl = @session_impl.nextReceiver(timeout.duration_impl)
@@ -237,10 +237,6 @@ module Qpid
237
237
  end
238
238
 
239
239
  # Returns true if there were exceptions on this session.
240
- #
241
- # ==== Examples
242
- #
243
- # puts "There were session errors." if @session.errors?
244
240
  def errors?; @session_impl.hasError; end
245
241
 
246
242
  # If the +Session+ has been rendered invalid due to some exception,
@@ -250,6 +246,7 @@ module Qpid
250
246
  #
251
247
  # ==== Examples
252
248
  #
249
+ # # show any errors that occurred during the Session
253
250
  # if @session.errors?
254
251
  # begin
255
252
  # @session.errors
metadata CHANGED
@@ -1,96 +1,86 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: qpid_messaging
3
- version: !ruby/object:Gem::Version
4
- version: 0.20.2
3
+ version: !ruby/object:Gem::Version
4
+ hash: 71
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 22
9
+ - 0
10
+ version: 0.22.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Apache Qpid Project
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2013-03-07 00:00:00.000000000 Z
17
+
18
+ date: 2013-06-18 00:00:00 Z
13
19
  dependencies: []
20
+
14
21
  description: Qpid is an enterprise messaging framework.
15
22
  email: dev@qpid.apache.org
16
23
  executables: []
17
- extensions:
24
+
25
+ extensions:
18
26
  - ext/cqpid/extconf.rb
19
- extra_rdoc_files:
20
- - README.rdoc
21
- files:
27
+ extra_rdoc_files: []
28
+
29
+ files:
22
30
  - LICENSE
31
+ - ChangeLog
23
32
  - README.rdoc
24
- - Rakefile
25
33
  - TODO
26
34
  - lib/qpid_messaging.rb
27
- - lib/qpid_messaging/address.rb
28
- - lib/qpid_messaging/connection.rb
29
35
  - lib/qpid_messaging/duration.rb
30
- - lib/qpid_messaging/encoding.rb
31
- - lib/qpid_messaging/errors.rb
32
- - lib/qpid_messaging/message.rb
33
36
  - lib/qpid_messaging/receiver.rb
34
- - lib/qpid_messaging/sender.rb
35
37
  - lib/qpid_messaging/session.rb
36
- - lib/qpid_messaging/version.rb
37
- - examples/client.rb
38
- - examples/drain.rb
38
+ - lib/qpid_messaging/connection.rb
39
+ - lib/qpid_messaging/message.rb
40
+ - lib/qpid_messaging/address.rb
41
+ - lib/qpid_messaging/encoding.rb
42
+ - lib/qpid_messaging/sender.rb
43
+ - ext/cqpid/cqpid.cpp
44
+ - ext/cqpid/extconf.rb
45
+ - examples/spout.rb
46
+ - examples/server.rb
39
47
  - examples/hello_world.rb
40
48
  - examples/map_receiver.rb
41
49
  - examples/map_sender.rb
42
- - examples/server.rb
43
- - examples/spout.rb
44
- - ext/cqpid/cqpid.cpp
45
- - ext/cqpid/extconf.rb
46
- - features/closing_a_connection.feature
47
- - features/closing_a_session.feature
48
- - features/connecting_to_a_broker.feature
49
- - features/creating_a_receiver.feature
50
- - features/creating_a_sender.feature
51
- - features/creating_a_session.feature
52
- - features/getting_the_connections_authenticated_username.feature
53
- - features/receiving_a_message.feature
54
- - features/sending_a_message.feature
55
- - features/session_returns_its_connection.feature
56
- - features/sessions_have_names.feature
57
- - features/step_definitions/address_steps.rb
58
- - features/step_definitions/connection_steps.rb
59
- - features/step_definitions/receiver_steps.rb
60
- - features/step_definitions/sender_steps.rb
61
- - features/step_definitions/session_steps.rb
62
- - features/support/env.rb
63
- - spec/qpid_messaging/address_spec.rb
64
- - spec/qpid_messaging/connection_spec.rb
65
- - spec/qpid_messaging/duration_spec.rb
66
- - spec/qpid_messaging/encoding_spec.rb
67
- - spec/qpid_messaging/message_spec.rb
68
- - spec/qpid_messaging/receiver_spec.rb
69
- - spec/qpid_messaging/sender_spec.rb
70
- - spec/qpid_messaging/session_spec.rb
71
- - spec/spec_helper.rb
50
+ - examples/drain.rb
51
+ - examples/client.rb
72
52
  homepage: http://qpid.apache.org
73
53
  licenses: []
54
+
74
55
  post_install_message:
75
56
  rdoc_options: []
76
- require_paths:
57
+
58
+ require_paths:
77
59
  - lib
78
- required_ruby_version: !ruby/object:Gem::Requirement
60
+ required_ruby_version: !ruby/object:Gem::Requirement
79
61
  none: false
80
- requirements:
81
- - - ! '>='
82
- - !ruby/object:Gem::Version
83
- version: '0'
84
- required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ hash: 3
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
70
  none: false
86
- requirements:
87
- - - ! '>='
88
- - !ruby/object:Gem::Version
89
- version: '0'
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
90
78
  requirements: []
79
+
91
80
  rubyforge_project:
92
- rubygems_version: 1.8.25
81
+ rubygems_version: 1.8.24
93
82
  signing_key:
94
83
  specification_version: 3
95
84
  summary: Qpid is an enterprise messaging framework.
96
85
  test_files: []
86
+