torquebox-messaging 3.2.0-java → 4.0.0.alpha1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/lib/torquebox-messaging.rb +19 -20
  3. data/lib/torquebox/messaging.rb +80 -20
  4. data/lib/torquebox/messaging/context.rb +174 -0
  5. data/lib/torquebox/messaging/destination.rb +164 -215
  6. data/lib/torquebox/messaging/helpers.rb +34 -0
  7. data/lib/torquebox/messaging/hornetq.rb +70 -0
  8. data/lib/torquebox/messaging/hornetq/address_settings.rb +228 -0
  9. data/lib/torquebox/messaging/queue.rb +139 -301
  10. data/lib/torquebox/messaging/topic.rb +84 -46
  11. data/lib/wunderboss-jars/hornetq-commons-2.4.5.Final.jar +0 -0
  12. data/lib/wunderboss-jars/hornetq-core-client-2.4.5.Final.jar +0 -0
  13. data/lib/wunderboss-jars/hornetq-jms-client-2.4.5.Final.jar +0 -0
  14. data/lib/wunderboss-jars/hornetq-jms-server-2.4.5.Final.jar +0 -0
  15. data/lib/wunderboss-jars/hornetq-journal-2.4.5.Final.jar +0 -0
  16. data/lib/wunderboss-jars/hornetq-native-2.4.5.Final.jar +0 -0
  17. data/lib/wunderboss-jars/hornetq-server-2.4.5.Final.jar +0 -0
  18. data/lib/wunderboss-jars/javax.inject-1.jar +0 -0
  19. data/lib/wunderboss-jars/jboss-common-core-2.2.10.GA.jar +0 -0
  20. data/lib/wunderboss-jars/jboss-connector-api_1.5_spec-1.0.0.Final.jar +0 -0
  21. data/lib/wunderboss-jars/jboss-jms-api_2.0_spec-1.0.0.Final.jar +0 -0
  22. data/lib/wunderboss-jars/jboss-transaction-api_1.1_spec-1.0.0.Final.jar +0 -0
  23. data/lib/wunderboss-jars/jboss-transaction-spi-7.0.0.Final.jar +0 -0
  24. data/lib/wunderboss-jars/jnpserver-5.0.3.GA.jar +0 -0
  25. data/lib/wunderboss-jars/netty-all-4.0.13.Final.jar +0 -0
  26. data/lib/wunderboss-jars/wunderboss-messaging-1.x.incremental.174.jar +0 -0
  27. metadata +88 -98
  28. data/lib/gem_hook.rb +0 -51
  29. data/lib/hornetq-commons-2.3.1.Final.jar +0 -0
  30. data/lib/hornetq-core-client-2.3.1.Final.jar +0 -0
  31. data/lib/hornetq-jms-client-2.3.1.Final.jar +0 -0
  32. data/lib/hornetq-journal-2.3.1.Final.jar +0 -0
  33. data/lib/jboss-jms-api_1.1_spec-1.0.1.Final.jar +0 -0
  34. data/lib/jboss-logging-3.1.2.GA.jar +0 -0
  35. data/lib/jboss-logmanager-1.4.0.Final.jar +0 -0
  36. data/lib/jboss-transaction-api_1.1_spec-1.0.1.Final.jar +0 -0
  37. data/lib/netty-3.6.2.Final.jar +0 -0
  38. data/lib/org.torquebox.messaging-client.rb +0 -20
  39. data/lib/torquebox-messaging.jar +0 -0
  40. data/lib/torquebox/messaging/backgroundable.rb +0 -250
  41. data/lib/torquebox/messaging/backgroundable_processor.rb +0 -52
  42. data/lib/torquebox/messaging/connection.rb +0 -74
  43. data/lib/torquebox/messaging/connection_factory.rb +0 -115
  44. data/lib/torquebox/messaging/const_missing.rb +0 -28
  45. data/lib/torquebox/messaging/core.rb +0 -27
  46. data/lib/torquebox/messaging/datamapper_marshaling.rb +0 -43
  47. data/lib/torquebox/messaging/echo_processor.rb +0 -35
  48. data/lib/torquebox/messaging/edn_message.rb +0 -26
  49. data/lib/torquebox/messaging/ext/javax_jms_queue_browser.rb +0 -25
  50. data/lib/torquebox/messaging/future.rb +0 -131
  51. data/lib/torquebox/messaging/future_responder.rb +0 -109
  52. data/lib/torquebox/messaging/future_status.rb +0 -37
  53. data/lib/torquebox/messaging/json_message.rb +0 -26
  54. data/lib/torquebox/messaging/marshal_base64_message.rb +0 -26
  55. data/lib/torquebox/messaging/marshal_message.rb +0 -43
  56. data/lib/torquebox/messaging/message.rb +0 -137
  57. data/lib/torquebox/messaging/message_processor.rb +0 -209
  58. data/lib/torquebox/messaging/processor_middleware/chain.rb +0 -89
  59. data/lib/torquebox/messaging/processor_middleware/default_middleware.rb +0 -39
  60. data/lib/torquebox/messaging/processor_middleware/with_transaction.rb +0 -35
  61. data/lib/torquebox/messaging/session.rb +0 -173
  62. data/lib/torquebox/messaging/task.rb +0 -66
  63. data/lib/torquebox/messaging/text_message.rb +0 -36
  64. data/lib/torquebox/messaging/xa_connection.rb +0 -55
  65. data/lib/torquebox/messaging/xa_connection_factory.rb +0 -45
  66. data/lib/torquebox/messaging/xa_session.rb +0 -51
  67. data/licenses/cc0-1.0.txt +0 -121
  68. data/spec/backgroundable_spec.rb +0 -319
  69. data/spec/chain_spec.rb +0 -160
  70. data/spec/datamapper_marshaling_spec.rb +0 -25
  71. data/spec/default_middleware_spec.rb +0 -21
  72. data/spec/destination_spec.rb +0 -248
  73. data/spec/future_responder_spec.rb +0 -81
  74. data/spec/future_spec.rb +0 -163
  75. data/spec/message_processor_spec.rb +0 -211
  76. data/spec/message_spec.rb +0 -135
  77. data/spec/task_spec.rb +0 -111
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,20 +0,0 @@
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
-
18
- # Backwards-compatibility
19
- $stderr.puts "Usage of 'org.torquebox.messaging-client' is deprecated. Please use 'torquebox-messaging'."
20
- require 'torquebox-messaging'
Binary file
@@ -1,250 +0,0 @@
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
-
18
- require 'torquebox/messaging/queue'
19
- require 'torquebox/messaging/future'
20
- require 'torquebox/messaging/task'
21
- require 'torquebox/messaging/future_status'
22
- require 'torquebox/injectors'
23
- require 'torquebox/logger'
24
-
25
- module TorqueBox
26
- module Messaging
27
-
28
- # Backgroundable provides mechanism for executing an object's
29
- # methods asynchronously.
30
- module Backgroundable
31
- # @!parse extend BackgroundableClassMethods
32
-
33
- # @api private
34
- MUTEX = Mutex.new
35
-
36
- def self.included(base)
37
- base.extend(BackgroundableClassMethods)
38
- base.extend(FutureStatus)
39
- base.send(:include, FutureStatus)
40
- end
41
-
42
- # Signals if the newrelic gem is loaded.
43
- def self.newrelic_available?
44
- defined?(NewRelic::Agent)
45
- end
46
-
47
- # Allows you to background any method that has not been marked
48
- # as a backgrounded method via {BackgroundableClassMethods#always_background}.
49
- # @param [Hash] options that are passed through to
50
- # {TorqueBox::Messaging::Destination#publish}
51
- # @return [Future]
52
- def background(options = { })
53
- BackgroundProxy.new(self, options)
54
- end
55
-
56
- module BackgroundableClassMethods
57
-
58
- # Marks methods to always be backgrounded. Takes one or more
59
- # method symbols, and an optional options hash as the final
60
- # argument. The options allow you to set publish options for
61
- # each call.
62
- # see TorqueBox::Messaging::Destination#publish
63
- def always_background(*methods)
64
- options = methods.last.is_a?(Hash) ? methods.pop : {}
65
- @__backgroundable_methods ||= {}
66
-
67
- methods.each do |method|
68
- method = method.to_s
69
- if !@__backgroundable_methods[method]
70
- @__backgroundable_methods[method] ||= { }
71
- @__backgroundable_methods[method][:options] = options
72
- if Util.singleton_methods_include?(self, method) ||
73
- Util.instance_methods_include?(self, method)
74
- __enable_backgrounding(method)
75
- end
76
- end
77
- end
78
- end
79
-
80
- # Allows you to background any method that has not been marked
81
- # as a backgrounded method via {BackgroundableClassMethods#always_background}.
82
- # @param [Hash] options that are passed through to
83
- # {TorqueBox::Messaging::Destination#publish}
84
- # @return [Future]
85
- def background(options = { })
86
- BackgroundProxy.new(self, options)
87
- end
88
-
89
- # @api private
90
- def method_added(method)
91
- super
92
- __method_added(method)
93
- end
94
-
95
- # @api private
96
- def singleton_method_added(method)
97
- super
98
- __method_added(method)
99
- end
100
-
101
- # @api private
102
- def __enable_backgroundable_newrelic_tracing(method)
103
- method = method.to_s
104
- if Backgroundable.newrelic_available?
105
- TorqueBox::Messaging::Backgroundable::MUTEX.synchronize do
106
- @__enabled_bg_tracing_methods ||= {}
107
- if !@__enabled_bg_tracing_methods[method]
108
- include(NewRelic::Agent::Instrumentation::ControllerInstrumentation) unless
109
- include?(NewRelic::Agent::Instrumentation::ControllerInstrumentation)
110
- begin
111
- add_transaction_tracer(method, :name => method.sub("__sync_", ""), :category => :task)
112
- rescue Exception => e
113
- TorqueBox::Logger.new( Backgroundable ).error "Error loading New Relic for backgrounded method #{method.sub("__sync_", "")}: #{e}"
114
- end
115
- @__enabled_bg_tracing_methods[method] = true
116
- end
117
- end
118
- end
119
- end
120
-
121
- private
122
-
123
- def __method_added(method)
124
- method = method.to_s
125
- if @__backgroundable_methods &&
126
- @__backgroundable_methods[method] &&
127
- !@__backgroundable_methods[method][:backgrounding]
128
- __enable_backgrounding(method)
129
- end
130
- end
131
-
132
- def __enable_backgrounding(method)
133
- singleton_method = Util.singleton_methods_include?(self, method)
134
- singleton = (class << self; self; end)
135
-
136
- if singleton_method
137
-
138
- TorqueBox::Logger.new( self ).
139
- warn("always_background called for :#{method}, but :#{method} " +
140
- "exists as both a class and instance method. Only the " +
141
- "class method will be backgrounded.") if Util.instance_methods_include?(self, method)
142
-
143
- privatize = Util.private_singleton_methods_include?(self, method)
144
- protect = Util.protected_singleton_methods_include?(self, method) unless privatize
145
- else
146
- privatize = Util.private_instance_methods_include?(self, method)
147
- protect = Util.protected_instance_methods_include?(self, method) unless privatize
148
- end
149
-
150
- async_method = "__async_#{method}"
151
- sync_method = "__sync_#{method}"
152
-
153
- @__backgroundable_methods[method][:backgrounding] = true
154
- options = @__backgroundable_methods[method][:options]
155
-
156
- (singleton_method ? singleton : self).class_eval do
157
- define_method async_method do |*args|
158
- Util.publish_message(self, sync_method, args, options)
159
- end
160
- end
161
-
162
- code = singleton_method ? "class << self" : ""
163
- code << %Q{
164
- alias_method :#{sync_method}, :#{method}
165
- alias_method :#{method}, :#{async_method}
166
- }
167
- code << %Q{
168
- #{privatize ? "private" : "protected"} :#{method}, :#{sync_method}, :#{async_method}
169
- } if privatize || protect
170
- code << "end" if singleton_method
171
-
172
- class_eval code
173
- ensure
174
- @__backgroundable_methods[method][:backgrounding] = nil
175
- end
176
-
177
- end
178
-
179
- # @api private
180
- class BackgroundProxy
181
- def initialize(receiver, options)
182
- @receiver = receiver
183
- @options = options
184
- end
185
-
186
- def method_missing(method, *args, &block)
187
- @receiver.method_missing(method, *args, &block) unless @receiver.respond_to?(method)
188
- raise ArgumentError.new("Backgrounding a method with a block argument is not supported. If you need this feature, please file a feature request at http://issues.jboss.org/browse/TORQUE") if block_given?
189
- Util.publish_message(@receiver, method, args, @options)
190
- end
191
- end
192
-
193
- # @api private
194
- module Util
195
-
196
- class << self
197
- def publish_message(receiver, method, args, options = { })
198
- queue_name = Task.queue_name( "torquebox_backgroundable" )
199
- queue = Queue.new( queue_name )
200
- future = Future.new( queue )
201
- options[:encoding] = :marshal
202
- queue.publish( {:receiver => receiver,
203
- :future_id => future.correlation_id,
204
- :future_queue => queue_name,
205
- :future_ttl => options[:future_ttl],
206
- :method => method,
207
- :args => args}, options )
208
-
209
- future
210
- rescue javax.jms.InvalidDestinationException => ex
211
- raise RuntimeError.new("The Backgroundable queue is not available. Did you disable it by setting its concurrency to 0?")
212
- end
213
-
214
- def singleton_methods_include?(klass, method)
215
- methods_include?(klass.singleton_methods, method) ||
216
- private_singleton_methods_include?(klass, method)
217
- end
218
-
219
- def private_singleton_methods_include?(klass, method)
220
- methods_include?(klass.private_methods, method)
221
- end
222
-
223
- def protected_singleton_methods_include?(klass, method)
224
- methods_include?(klass.protected_methods, method)
225
- end
226
-
227
- def instance_methods_include?(klass, method)
228
- methods_include?(klass.instance_methods, method) ||
229
- private_instance_methods_include?(klass, method)
230
- end
231
-
232
- def private_instance_methods_include?(klass, method)
233
- methods_include?(klass.private_instance_methods, method)
234
- end
235
-
236
- def protected_instance_methods_include?(klass, method)
237
- methods_include?(klass.protected_instance_methods, method)
238
- end
239
-
240
- def methods_include?(methods, method)
241
- method = (RUBY_VERSION =~ /^1\.8\./ ? method.to_s : method.to_sym)
242
- methods.include?(method)
243
- end
244
- end
245
- end
246
- end
247
- end
248
- end
249
-
250
-
@@ -1,52 +0,0 @@
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
-
18
- require 'torquebox/messaging/message_processor'
19
- require 'torquebox/messaging/const_missing'
20
- require 'torquebox/messaging/future_responder'
21
-
22
- module TorqueBox
23
- module Messaging
24
- # @api private
25
- class BackgroundableProcessor < MessageProcessor
26
-
27
- def self.log_newrelic_notice(klass)
28
- @newrelic_notice_logged ||=
29
- log.warn( "The New Relic agent is loaded, but an issue with the inheritance hierachy of " <<
30
- klass.name << " prevents us from reporting on its Backgroundable calls." ) || true
31
- end
32
-
33
- def on_message(hash)
34
- FutureResponder.new( Queue.new( hash[:future_queue] ), hash[:future_id], hash[:future_ttl] ).respond do
35
- klass = hash[:receiver].class
36
- if klass.respond_to?( :__enable_backgroundable_newrelic_tracing )
37
- klass.__enable_backgroundable_newrelic_tracing( hash[:method] )
38
- elsif Backgroundable.newrelic_available?
39
- self.class.log_newrelic_notice( klass )
40
- end
41
-
42
- hash[:receiver].send(hash[:method], *hash[:args])
43
- end
44
- end
45
-
46
- private
47
- def self.log
48
- @logger ||= TorqueBox::Logger.new( self )
49
- end
50
- end
51
- end
52
- end
@@ -1,74 +0,0 @@
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
-
18
- require 'torquebox/injectors'
19
- require 'torquebox/messaging/session'
20
-
21
- module TorqueBox
22
- module Messaging
23
- class Connection
24
-
25
- attr_accessor :jms_connection
26
-
27
- def initialize(jms_connection, connection_factory)
28
- @jms_connection = jms_connection
29
- @connection_factory = connection_factory
30
- @tm = TorqueBox.fetch('transaction-manager')
31
- end
32
-
33
- def start
34
- jms_connection.start
35
- end
36
-
37
- def close
38
- jms_connection.close
39
- end
40
-
41
- def client_id
42
- jms_connection.client_id
43
- end
44
-
45
- def client_id=(client_id)
46
- jms_connection.client_id = client_id
47
- end
48
-
49
- def with_session(&block)
50
- begin
51
- session = create_session
52
- result = block.call( session )
53
- ensure
54
- session.close
55
- end
56
- result
57
- end
58
-
59
- def create_session
60
- Session.new( jms_connection.create_session( false, Session::AUTO_ACK ) )
61
- end
62
-
63
- def transaction
64
- @tm && @tm.transaction
65
- end
66
-
67
- def deactivate
68
- @connection_factory.deactivate
69
- end
70
-
71
- end
72
-
73
- end
74
- end
@@ -1,115 +0,0 @@
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
-
18
- require 'java'
19
- require 'torquebox/messaging/connection'
20
-
21
- module TorqueBox
22
- module Messaging
23
- class ConnectionFactory
24
-
25
- attr_reader :internal_connection_factory
26
-
27
- def self.new(internal_connection_factory = nil)
28
- return internal_connection_factory if internal_connection_factory.is_a?( ConnectionFactory )
29
- super
30
- end
31
-
32
- def initialize(internal_connection_factory = nil)
33
- @internal_connection_factory = internal_connection_factory
34
- @tm = TorqueBox.fetch('transaction-manager')
35
- end
36
-
37
- def with_new_connection(options, enlist_tx = true, &block)
38
- client_id = options[:client_id]
39
- create_internal_connection_factory( options )
40
- if !enlist_tx || (current.nil? && !transaction)
41
- connection = create_connection( options )
42
- connection.client_id = client_id if client_id
43
- begin
44
- connection.start
45
- result = block.call( connection )
46
- ensure
47
- connection.close
48
- end
49
- elsif transaction && (!current.respond_to?(:session_transaction) || current.session_transaction != transaction)
50
- result = block.call( activate( create_xa_connection( options ), client_id ) )
51
- # XaSession's afterCompletion callback deactivates XA connections
52
- else
53
- result = block.call( current )
54
- end
55
- result
56
- end
57
-
58
- def connections
59
- Thread.current[:torquebox_connection] ||= []
60
- end
61
-
62
- def current
63
- connections.last
64
- end
65
-
66
- def activate(connection, client_id)
67
- connection.client_id = client_id if client_id
68
- connection.start
69
- connections.push(connection) && current
70
- end
71
-
72
- def deactivate
73
- connections.pop.close
74
- end
75
-
76
- def transaction
77
- @tm && @tm.transaction
78
- end
79
-
80
- def create_internal_connection_factory(options)
81
- host = options[:host] || "localhost"
82
- port = options[:port] || 5445
83
- if !@internal_connection_factory
84
- @internal_connection_factory = create_connection_factory( host, port )
85
- end
86
- end
87
-
88
- def create_connection(options={})
89
- username = options[:username]
90
- password = options[:password]
91
- Connection.new( @internal_connection_factory.create_connection( username, password ), self )
92
- end
93
-
94
- def create_xa_connection(options={})
95
- username = options[:username]
96
- password = options[:password]
97
- XaConnection.new( @internal_connection_factory.create_xa_connection( username, password ), self )
98
- end
99
-
100
- def create_connection_factory(host, port)
101
- connect_opts = { "host" => host, "port" => port }
102
- transport_config =
103
- org.hornetq.api.core.TransportConfiguration.new("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory",
104
- connect_opts)
105
- org.hornetq.api.jms.HornetQJMSClient.createConnectionFactoryWithoutHA( org.hornetq.api.jms::JMSFactoryType::CF, transport_config )
106
- end
107
-
108
-
109
- def to_s
110
- "[ConnectionFactory: internal_connection_factory=#{internal_connection_factory}]"
111
- end
112
-
113
- end
114
- end
115
- end