torquebox-messaging 2.2.0-java → 2.3.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/lib/gem_hook.rb +1 -1
  2. data/lib/org.torquebox.messaging-client.rb +1 -1
  3. data/lib/torquebox-messaging.jar +0 -0
  4. data/lib/torquebox-messaging.rb +2 -2
  5. data/lib/torquebox/messaging.rb +1 -1
  6. data/lib/torquebox/messaging/backgroundable.rb +2 -2
  7. data/lib/torquebox/messaging/backgroundable_processor.rb +1 -6
  8. data/lib/torquebox/messaging/connection.rb +1 -1
  9. data/lib/torquebox/messaging/connection_factory.rb +1 -1
  10. data/lib/torquebox/messaging/const_missing.rb +1 -1
  11. data/lib/torquebox/messaging/core.rb +1 -1
  12. data/lib/torquebox/messaging/datamapper_marshaling.rb +1 -1
  13. data/lib/torquebox/messaging/destination.rb +43 -4
  14. data/lib/torquebox/messaging/echo_processor.rb +17 -1
  15. data/lib/torquebox/messaging/edn_message.rb +1 -1
  16. data/lib/torquebox/messaging/ext/javax_jms_queue_browser.rb +1 -1
  17. data/lib/torquebox/messaging/future.rb +1 -1
  18. data/lib/torquebox/messaging/future_responder.rb +1 -1
  19. data/lib/torquebox/messaging/future_status.rb +1 -1
  20. data/lib/torquebox/messaging/json_message.rb +1 -1
  21. data/lib/torquebox/messaging/marshal_base64_message.rb +1 -1
  22. data/lib/torquebox/messaging/marshal_message.rb +1 -1
  23. data/lib/torquebox/messaging/message.rb +10 -10
  24. data/lib/torquebox/messaging/message_processor.rb +1 -1
  25. data/lib/torquebox/messaging/processor_middleware/chain.rb +4 -4
  26. data/lib/torquebox/messaging/processor_middleware/default_middleware.rb +1 -1
  27. data/lib/torquebox/messaging/processor_middleware/with_transaction.rb +6 -13
  28. data/lib/torquebox/messaging/queue.rb +83 -1
  29. data/lib/torquebox/messaging/session.rb +24 -16
  30. data/lib/torquebox/messaging/task.rb +1 -1
  31. data/lib/torquebox/messaging/text_message.rb +1 -1
  32. data/lib/torquebox/messaging/topic.rb +1 -1
  33. data/lib/torquebox/messaging/xa_connection.rb +1 -1
  34. data/lib/torquebox/messaging/xa_connection_factory.rb +1 -1
  35. data/lib/torquebox/messaging/xa_session.rb +1 -1
  36. data/spec/destination_spec.rb +56 -0
  37. metadata +43 -43
data/lib/gem_hook.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
Binary file
@@ -1,6 +1,6 @@
1
1
  module TorqueboxMessaging
2
- VERSION = '2.2.0'
3
- MAVEN_VERSION = '2.2.0'
2
+ VERSION = '2.3.0'
3
+ MAVEN_VERSION = '2.3.0'
4
4
  end
5
5
  begin
6
6
  require 'java'
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -14,7 +14,7 @@
14
14
  # License along with this software; if not, write to the Free
15
15
  # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
16
16
  # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
17
-
17
+
18
18
  require 'torquebox/messaging/queue'
19
19
  require 'torquebox/messaging/future'
20
20
  require 'torquebox/messaging/task'
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -42,11 +42,6 @@ module TorqueBox
42
42
  end
43
43
  end
44
44
 
45
- # Do not begin a transaction before invoking a Backgroundable method
46
- def middleware
47
- super.remove(TorqueBox::Messaging::ProcessorMiddleware::WithTransaction)
48
- end
49
-
50
45
  private
51
46
  def self.log
52
47
  @logger ||= TorqueBox::Logger.new( self )
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -16,6 +16,7 @@
16
16
  # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
17
17
 
18
18
  require 'torquebox/injectors'
19
+ require 'torquebox/msc'
19
20
  require 'torquebox/messaging/session'
20
21
  require 'torquebox/messaging/connection_factory'
21
22
  require 'torquebox/messaging/ext/javax_jms_queue_browser'
@@ -25,7 +26,7 @@ module TorqueBox
25
26
  class Destination
26
27
  include TorqueBox::Injectors
27
28
  include Enumerable
28
-
29
+
29
30
  attr_reader :connection_factory
30
31
  attr_reader :name
31
32
  attr_accessor :enumerable_options
@@ -152,11 +153,49 @@ module TorqueBox
152
153
  @enumerable_options ||= { }
153
154
  @enumerable_options
154
155
  end
155
-
156
- def to_s
156
+
157
+ def to_s
157
158
  name
158
159
  end
159
160
 
161
+ class << self
162
+
163
+ # List all destinations of this application.
164
+ #
165
+ # @return Array of {TorqueBox::Messaging::Queue} or {TorqueBox::Messaging::Topic}
166
+ # depending on the destination type.
167
+ def list
168
+ # Get the JMS Manager
169
+ TorqueBox::ServiceRegistry.lookup("jboss.messaging.default.jms.manager") do |manager|
170
+
171
+ # JMSServerControl will let us grab the deployed queue/topic list
172
+ server_control = Java::org.hornetq.jms.management.impl.JMSServerControlImpl.new(manager)
173
+
174
+ # Retrieve the destination list appropriate to the destination type
175
+ if self == TorqueBox::Messaging::Topic
176
+ names = server_control.topic_names
177
+ elsif self == TorqueBox::Messaging::Queue
178
+ names = server_control.queue_names
179
+ else
180
+ names = []
181
+ end
182
+
183
+ names.map { |name| self.new(name) }
184
+ end
185
+ end
186
+
187
+ # Lookup a destination of this application by name. A destination could be
188
+ # a queue or topic.
189
+ #
190
+ # @param [String] name of the destination
191
+ #
192
+ # @return [TorqueBox::Messaging::Queue] or [TorqueBox::Messaging::Topic]
193
+ # The destination instance.
194
+ def lookup(name)
195
+ list.find { |destination| destination.name == name }
196
+ end
197
+ end
198
+
160
199
  end
161
200
  end
162
201
  end
@@ -1,4 +1,20 @@
1
- # @api private
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
+ #
3
+ # This is free software; you can redistribute it and/or modify it
4
+ # under the terms of the GNU Lesser General Public License as
5
+ # published by the Free Software Foundation; either version 2.1 of
6
+ # the License, or (at your option) any later version.
7
+ #
8
+ # This software is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this software; if not, write to the Free
15
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
16
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
17
+
2
18
  module Torquebox
3
19
  module Messaging
4
20
  # A message processor that echos any messages sent to it back to
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -57,17 +57,17 @@ module TorqueBox
57
57
  end
58
58
 
59
59
  def populate_message_properties(properties)
60
- return if properties.nil?
60
+ return if properties.nil? or properties.empty?
61
61
  properties.each do |key, value|
62
62
  case value
63
- when Integer
64
- @jms_message.set_long_property(key.to_s, value)
65
- when Float
66
- @jms_message.set_double_property(key.to_s, value)
67
- when TrueClass, FalseClass
68
- @jms_message.set_boolean_property(key.to_s, value)
69
- else
70
- @jms_message.set_string_property(key.to_s, value.to_s)
63
+ when Integer
64
+ @jms_message.set_long_property(key.to_s, value)
65
+ when Float
66
+ @jms_message.set_double_property(key.to_s, value)
67
+ when TrueClass, FalseClass
68
+ @jms_message.set_boolean_property(key.to_s, value)
69
+ else
70
+ @jms_message.set_string_property(key.to_s, value.to_s)
71
71
  end
72
72
  end
73
73
  end
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,15 +1,15 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
2
- #
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
+ #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
5
5
  # published by the Free Software Foundation; either version 2.1 of
6
6
  # the License, or (at your option) any later version.
7
- #
7
+ #
8
8
  # This software is distributed in the hope that it will be useful,
9
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
11
  # Lesser General Public License for more details.
12
- #
12
+ #
13
13
  # You should have received a copy of the GNU Lesser General Public
14
14
  # License along with this software; if not, write to the Free
15
15
  # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -21,21 +21,14 @@ module TorqueBox
21
21
  module Messaging
22
22
  module ProcessorMiddleware
23
23
  class WithTransaction
24
-
24
+
25
25
  def call(session, message)
26
- if session
27
- begin
28
- TorqueBox.transaction( session ) { yield }
29
- rescue Exception => ex
30
- $stderr.puts("Unable to process inbound message", ex)
31
- end
32
- else
33
- yield
34
- end
26
+ # This middleware is now a no-op and should be removed
27
+ yield
35
28
  end
36
-
29
+
37
30
  end
38
-
31
+
39
32
  end
40
33
  end
41
34
  end
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -53,6 +53,88 @@ module TorqueBox
53
53
  end
54
54
  end
55
55
 
56
+ # Returns true if queue is paused, false
57
+ # otherwise.
58
+ def paused?
59
+ with_queue_control do |control|
60
+ control.is_paused
61
+ end
62
+ end
63
+
64
+ # Pauses a queue.
65
+ #
66
+ # Messages put into a queue will not be delivered even
67
+ # if there are connected consumers.
68
+ #
69
+ # When executed on a paused queue, nothing happens.
70
+ def pause
71
+ with_queue_control do |control|
72
+ control.pause
73
+ end
74
+ end
75
+
76
+ # Resumes a queue after it was paused.
77
+ # When executed on a active queue, nothing happens.
78
+ def resume
79
+ with_queue_control do |control|
80
+ control.resume
81
+ end
82
+ end
83
+
84
+ # Removes messages from the queue.
85
+ #
86
+ # Accepts optional :filter parameter to remove only
87
+ # selected messages from the queue. By default
88
+ # *all* messages will be removed.
89
+ #
90
+ # The :filter parameter is a String where you define
91
+ # expressions in a SQL92-like syntax based on properties
92
+ # set on the messages.
93
+ #
94
+ # Example:
95
+ #
96
+ # type = 'tomatoe' OR type = 'garlic'
97
+ #
98
+ # This will remove messages with :type property set
99
+ # to 'tomatoe' or 'garlic'
100
+ #
101
+ # This function returns number of removed messages.
102
+ def remove_messages(filter = nil)
103
+ with_queue_control do |control|
104
+ control.remove_messages(filter)
105
+ end
106
+ end
107
+
108
+ # Counts messages in the queue.
109
+ #
110
+ # Accepts optional :filter parameter to count only
111
+ # selected messages in the queue. By default
112
+ # all messages will be counted.
113
+ #
114
+ # The :filter parameter is a String where you define
115
+ # expressions in a SQL92-like syntax based on properties
116
+ # set on the messages.
117
+ #
118
+ # Example:
119
+ #
120
+ # type = 'tomatoe' OR type = 'garlic'
121
+ #
122
+ # This will count messages with :type property set
123
+ # to 'tomatoe' or 'garlic'
124
+ def count_messages(filter = nil)
125
+ with_queue_control do |control|
126
+ control.count_messages(filter)
127
+ end
128
+ end
129
+
130
+ # Retrieves the JMSQueueControl implenetation for current
131
+ # queue.
132
+ def with_queue_control
133
+ TorqueBox::ServiceRegistry.lookup("jboss.messaging.default") do |server|
134
+ yield server.management_service.get_resource("jms.queue.#{_dump(nil)}")
135
+ end
136
+ end
137
+
56
138
  def to_s
57
139
  "[Queue: #{super}]"
58
140
  end
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -42,6 +42,22 @@ module TorqueBox
42
42
  producer = @jms_session.create_producer( java_destination( destination ) )
43
43
  message = Message.new( @jms_session, payload, options[:encoding] )
44
44
 
45
+ options[:properties] ||= {}
46
+
47
+ # This will let us create messages to be scheduled later like this:
48
+ #
49
+ # queue.publish(:ham => :biscuit, :scheduled => Time.now + 10)
50
+ # queue.publish(:ham => :biscuit, :scheduled => Time.now + 2.5)
51
+ #
52
+ # In Rails it is possible to do:
53
+ #
54
+ # queue.publish(:ham => :biscuit, :scheduled => 3.minutes.from_now)
55
+ #
56
+ # Please note that the :scheduled parameter takes a Time object.
57
+ if options.has_key?(:scheduled)
58
+ options[:properties][Java::org.hornetq.api.core.Message::HDR_SCHEDULED_DELIVERY_TIME.to_s] = (options[:scheduled].to_f * 1000).to_i
59
+ end
60
+
45
61
  message.populate_message_headers(options)
46
62
  message.populate_message_properties(options[:properties])
47
63
 
@@ -92,19 +108,13 @@ module TorqueBox
92
108
  # default: true
93
109
  #
94
110
  def publish_and_receive(destination, message, options = {})
95
- options[:timeout] ||= 10000 # 10s
96
- decode = options.fetch(:decode, false)
111
+ options[:timeout] ||= 10_000 # 10s
97
112
  options[:properties] ||= {}
98
113
  options[:properties]["synchronous"] = "true"
99
- wrapped_message = { :timeout => options[:timeout], :message => message }
100
- message = publish(destination, wrapped_message, options)
114
+ message = publish(destination, message, options)
101
115
 
102
116
  options[:selector] = "JMSCorrelationID='#{message.jms_message.jms_message_id}'"
103
- response = receive(destination, options)
104
-
105
- if response
106
- decode ? Message.new( response ).decode : response
107
- end
117
+ receive(destination, options)
108
118
  end
109
119
 
110
120
  # Receiving end of the request-response pattern. The return value of
@@ -119,12 +129,10 @@ module TorqueBox
119
129
 
120
130
  request = receive(destination, receive_options)
121
131
  unless request.nil?
122
- decoded_request = Message.new( request ).decode
123
- request_message = decoded_request[:message]
124
- # Base the response ttl off the original request timeout
125
- request_timeout = decoded_request[:timeout]
126
- options[:ttl] ||= request_timeout
127
-
132
+ request_message = Message.new( request ).decode
133
+ options[:ttl] ||= 60_000 # 1m
134
+ options[:encoding] ||= Message.extract_encoding_from_message( request )
135
+
128
136
  response = block_given? ? yield(request_message) : request_message
129
137
 
130
138
  options[:correlation_id] = request.jms_message_id
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
1
+ # Copyright 2008-2013 Red Hat, Inc, and individual contributors.
2
2
  #
3
3
  # This is free software; you can redistribute it and/or modify it
4
4
  # under the terms of the GNU Lesser General Public License as
@@ -166,4 +166,60 @@ describe TorqueBox::Messaging::Destination do
166
166
  end
167
167
  end
168
168
 
169
+ context "queue management" do
170
+ before(:each) do
171
+ jms_manager = mock('JMSManager')
172
+ @server_control = mock('ServerControl')
173
+
174
+ TorqueBox::ServiceRegistry.stub!(:lookup).with("jboss.messaging.default.jms.manager").and_yield(jms_manager)
175
+ Java::org.hornetq.jms.management.impl.JMSServerControlImpl.stub!(:new).with(jms_manager).and_return(@server_control)
176
+ end
177
+
178
+ describe "lookup" do
179
+ it "should return nil lookup if queue unavailable" do
180
+ @server_control.should_receive(:queue_names).and_return([])
181
+ TorqueBox::Messaging::Queue.lookup('/queues/doesntexist').should be_nil
182
+ end
183
+ end
184
+
185
+ describe "list" do
186
+ before(:each) do
187
+ jms_manager = mock('JMSManager')
188
+ @server_control = mock('ServerControl')
189
+
190
+ TorqueBox::ServiceRegistry.stub!(:lookup).with("jboss.messaging.default.jms.manager").and_yield(jms_manager)
191
+ Java::org.hornetq.jms.management.impl.JMSServerControlImpl.stub!(:new).with(jms_manager).and_return(@server_control)
192
+ end
193
+
194
+ it "should return empty list if no queues are available" do
195
+ @server_control.should_receive(:queue_names).and_return([])
196
+
197
+ TorqueBox::Messaging::Queue.list.should == []
198
+ end
199
+
200
+ it "should return empty list if no topics are available" do
201
+ @server_control.should_receive(:topic_names).and_return([])
202
+
203
+ TorqueBox::Messaging::Topic.list.should == []
204
+ end
205
+
206
+ it "should return list with available queues" do
207
+ @server_control.should_receive(:queue_names).and_return(['/queues/one', '/queues/two'])
208
+
209
+ queues = TorqueBox::Messaging::Queue.list
210
+ queues.size.should == 2
211
+ queues[0].name.should == '/queues/one'
212
+ queues[1].name.should == '/queues/two'
213
+ end
214
+
215
+ it "should return list with available topics" do
216
+ @server_control.should_receive(:topic_names).and_return(['/topics/one', '/topics/two'])
217
+
218
+ topics = TorqueBox::Messaging::Topic.list
219
+ topics.size.should == 2
220
+ topics[0].name.should == '/topics/one'
221
+ topics[1].name.should == '/topics/two'
222
+ end
223
+ end
224
+ end
169
225
  end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: torquebox-messaging
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.2.0
5
+ version: 2.3.0
6
6
  platform: java
7
7
  authors:
8
8
  - The TorqueBox Team
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-06 00:00:00.000000000 Z
12
+ date: 2013-01-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: torquebox-core
@@ -17,13 +17,13 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 2.2.0
20
+ version: 2.3.0
21
21
  none: false
22
22
  requirement: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.2.0
26
+ version: 2.3.0
27
27
  none: false
28
28
  prerelease: false
29
29
  type: :runtime
@@ -33,13 +33,13 @@ dependencies:
33
33
  requirements:
34
34
  - - '='
35
35
  - !ruby/object:Gem::Version
36
- version: 2.2.0
36
+ version: 2.3.0
37
37
  none: false
38
38
  requirement: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - '='
41
41
  - !ruby/object:Gem::Version
42
- version: 2.2.0
42
+ version: 2.3.0
43
43
  none: false
44
44
  prerelease: false
45
45
  type: :runtime
@@ -109,47 +109,47 @@ files:
109
109
  - lib/gem_hook.rb
110
110
  - lib/org.torquebox.messaging-client.rb
111
111
  - lib/torquebox/messaging.rb
112
- - lib/torquebox/messaging/session.rb
113
- - lib/torquebox/messaging/connection.rb
112
+ - lib/torquebox/messaging/xa_connection.rb
113
+ - lib/torquebox/messaging/queue.rb
114
+ - lib/torquebox/messaging/core.rb
115
+ - lib/torquebox/messaging/future_status.rb
116
+ - lib/torquebox/messaging/json_message.rb
117
+ - lib/torquebox/messaging/xa_connection_factory.rb
114
118
  - lib/torquebox/messaging/datamapper_marshaling.rb
115
119
  - lib/torquebox/messaging/backgroundable.rb
116
- - lib/torquebox/messaging/marshal_message.rb
117
- - lib/torquebox/messaging/echo_processor.rb
118
- - lib/torquebox/messaging/xa_connection_factory.rb
119
- - lib/torquebox/messaging/message_processor.rb
120
- - lib/torquebox/messaging/json_message.rb
121
- - lib/torquebox/messaging/xa_session.rb
120
+ - lib/torquebox/messaging/future_responder.rb
121
+ - lib/torquebox/messaging/text_message.rb
122
122
  - lib/torquebox/messaging/message.rb
123
- - lib/torquebox/messaging/edn_message.rb
124
- - lib/torquebox/messaging/task.rb
123
+ - lib/torquebox/messaging/future.rb
124
+ - lib/torquebox/messaging/message_processor.rb
125
+ - lib/torquebox/messaging/backgroundable_processor.rb
126
+ - lib/torquebox/messaging/connection.rb
125
127
  - lib/torquebox/messaging/connection_factory.rb
128
+ - lib/torquebox/messaging/echo_processor.rb
126
129
  - lib/torquebox/messaging/marshal_base64_message.rb
127
- - lib/torquebox/messaging/queue.rb
128
- - lib/torquebox/messaging/xa_connection.rb
129
- - lib/torquebox/messaging/backgroundable_processor.rb
130
- - lib/torquebox/messaging/future.rb
131
- - lib/torquebox/messaging/future_status.rb
132
- - lib/torquebox/messaging/text_message.rb
133
- - lib/torquebox/messaging/const_missing.rb
134
130
  - lib/torquebox/messaging/destination.rb
131
+ - lib/torquebox/messaging/xa_session.rb
132
+ - lib/torquebox/messaging/marshal_message.rb
133
+ - lib/torquebox/messaging/session.rb
135
134
  - lib/torquebox/messaging/topic.rb
136
- - lib/torquebox/messaging/future_responder.rb
137
- - lib/torquebox/messaging/core.rb
138
- - lib/torquebox/messaging/ext/javax_jms_queue_browser.rb
139
- - lib/torquebox/messaging/processor_middleware/with_transaction.rb
135
+ - lib/torquebox/messaging/const_missing.rb
136
+ - lib/torquebox/messaging/edn_message.rb
137
+ - lib/torquebox/messaging/task.rb
140
138
  - lib/torquebox/messaging/processor_middleware/chain.rb
139
+ - lib/torquebox/messaging/processor_middleware/with_transaction.rb
141
140
  - lib/torquebox/messaging/processor_middleware/default_middleware.rb
141
+ - lib/torquebox/messaging/ext/javax_jms_queue_browser.rb
142
+ - spec/json_message_spec.rb
143
+ - spec/message_spec.rb
144
+ - spec/datamapper_marshaling_spec.rb
145
+ - spec/future_spec.rb
146
+ - spec/message_processor_spec.rb
142
147
  - spec/task_spec.rb
148
+ - spec/destination_spec.rb
149
+ - spec/future_responder_spec.rb
143
150
  - spec/backgroundable_spec.rb
144
- - spec/future_spec.rb
145
151
  - spec/default_middleware_spec.rb
146
- - spec/destination_spec.rb
147
- - spec/message_spec.rb
148
- - spec/message_processor_spec.rb
149
152
  - spec/chain_spec.rb
150
- - spec/json_message_spec.rb
151
- - spec/future_responder_spec.rb
152
- - spec/datamapper_marshaling_spec.rb
153
153
  homepage: http://torquebox.org/
154
154
  licenses:
155
155
  - lgpl
@@ -159,14 +159,14 @@ require_paths:
159
159
  - lib
160
160
  required_ruby_version: !ruby/object:Gem::Requirement
161
161
  requirements:
162
- - - ! '>='
162
+ - - ">="
163
163
  - !ruby/object:Gem::Version
164
164
  version: !binary |-
165
165
  MA==
166
166
  none: false
167
167
  required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  requirements:
169
- - - ! '>='
169
+ - - ">="
170
170
  - !ruby/object:Gem::Version
171
171
  version: !binary |-
172
172
  MA==
@@ -178,14 +178,14 @@ signing_key:
178
178
  specification_version: 3
179
179
  summary: TorqueBox Messaging Client
180
180
  test_files:
181
+ - spec/json_message_spec.rb
182
+ - spec/message_spec.rb
183
+ - spec/datamapper_marshaling_spec.rb
184
+ - spec/future_spec.rb
185
+ - spec/message_processor_spec.rb
181
186
  - spec/task_spec.rb
187
+ - spec/destination_spec.rb
188
+ - spec/future_responder_spec.rb
182
189
  - spec/backgroundable_spec.rb
183
- - spec/future_spec.rb
184
190
  - spec/default_middleware_spec.rb
185
- - spec/destination_spec.rb
186
- - spec/message_spec.rb
187
- - spec/message_processor_spec.rb
188
191
  - spec/chain_spec.rb
189
- - spec/json_message_spec.rb
190
- - spec/future_responder_spec.rb
191
- - spec/datamapper_marshaling_spec.rb