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
data/spec/chain_spec.rb DELETED
@@ -1,160 +0,0 @@
1
- require 'torquebox/messaging/processor_middleware/chain'
2
-
3
- class MockMWare
4
- def initialize(*args)
5
- @log = args.first unless args.empty?
6
- end
7
-
8
- def call(session, message)
9
- @log << self.class if @log
10
- yield
11
- end
12
- end
13
-
14
- class MockMWare2 < MockMWare; end
15
-
16
-
17
- class TorqueBox::Messaging::ProcessorMiddleware::MWare
18
- attr_reader :args
19
- end
20
-
21
- class TorqueBox::Messaging::ProcessorMiddleware::Chain
22
- def get_chain
23
- chain
24
- end
25
- end
26
-
27
- describe TorqueBox::Messaging::ProcessorMiddleware::Chain do
28
- before(:each) do
29
- @chain = TorqueBox::Messaging::ProcessorMiddleware::Chain.new
30
- end
31
-
32
- describe "#prepend" do
33
- it "should work when the chain is empty" do
34
- @chain.prepend(MockMWare)
35
- @chain.get_chain.first.klass.should == MockMWare
36
- end
37
-
38
- it "should work when the chain is not empty" do
39
- @chain.prepend(MockMWare)
40
- @chain.prepend(MockMWare2)
41
- @chain.get_chain.first.klass.should == MockMWare2
42
- end
43
-
44
- it "should not add the same class twice" do
45
- @chain.prepend(MockMWare)
46
- @chain.prepend(MockMWare)
47
- @chain.get_chain.first.klass.should == MockMWare
48
- @chain.get_chain.length.should == 1
49
- end
50
-
51
- it "should work with args" do
52
- @chain.prepend(MockMWare, :arg1, :arg2)
53
- mware = @chain.get_chain.first
54
- mware.args.should == [:arg1, :arg2]
55
- end
56
-
57
- it "should return the chain" do
58
- @chain.prepend(MockMWare).should == @chain
59
- end
60
-
61
-
62
- end
63
-
64
- describe "#append" do
65
- it "should work when the chain is empty" do
66
- @chain.append(MockMWare)
67
- @chain.get_chain.first.klass.should == MockMWare
68
- end
69
-
70
- it "should work when the chain is not empty" do
71
- @chain.append(MockMWare)
72
- @chain.append(MockMWare2)
73
- @chain.get_chain.last.klass.should == MockMWare2
74
- end
75
-
76
- it "should not add the same class twice" do
77
- @chain.append(MockMWare)
78
- @chain.append(MockMWare)
79
- @chain.get_chain.first.klass.should == MockMWare
80
- @chain.get_chain.length.should == 1
81
- end
82
-
83
- it "should return the chain" do
84
- @chain.append(MockMWare).should == @chain
85
- end
86
-
87
- end
88
-
89
- describe "#remove" do
90
- it "should work" do
91
- @chain.append(MockMWare)
92
- @chain.remove(MockMWare)
93
- @chain.get_chain.should be_empty
94
- end
95
-
96
- it "should not barf if the class isn't present" do
97
- lambda do
98
- @chain.remove(MockMWare)
99
- end.should_not raise_error
100
- end
101
-
102
- it "should only remove the given class" do
103
- @chain.append(MockMWare)
104
- @chain.append(MockMWare2)
105
- @chain.remove(MockMWare)
106
- @chain.get_chain.first.klass.should == MockMWare2
107
- @chain.get_chain.length.should == 1
108
- end
109
-
110
- it "should return the chain" do
111
- @chain.remove(MockMWare).should == @chain
112
- end
113
-
114
- end
115
-
116
- describe '#invoke' do
117
- before(:each) do
118
- @processor = mock('processor')
119
- @log = []
120
- @processor.stub(:process!) do
121
- @log << :processor
122
- end.with("message")
123
- end
124
-
125
- describe "when the chain is empty" do
126
- it "should call the processor" do
127
- @chain.invoke("session", "message", @processor)
128
- end
129
- end
130
-
131
- describe "when the chain is not empty" do
132
- it "should call the processor" do
133
- @chain.append(MockMWare)
134
- @chain.invoke("session", "message", @processor)
135
- end
136
-
137
- it "should call the chain first" do
138
- @chain.append(MockMWare, @log)
139
- @chain.invoke("session", "message", @processor)
140
- @log.should == [MockMWare, :processor]
141
- end
142
-
143
- it "should call the chain in order" do
144
- @chain.append(MockMWare, @log)
145
- @chain.append(MockMWare2, @log)
146
- @chain.invoke("session", "message", @processor)
147
- @log.should == [MockMWare, MockMWare2, :processor]
148
- end
149
- end
150
- end
151
-
152
- describe "#inspect" do
153
- it "should work" do
154
- @chain.append(MockMWare)
155
- @chain.inspect.should == "[MockMWare]"
156
- end
157
- end
158
-
159
- end
160
-
@@ -1,25 +0,0 @@
1
- require 'torquebox/messaging/datamapper_marshaling'
2
-
3
- class MyTestDataMapperModel
4
- include TorqueBox::Messaging::DataMapper
5
- def id ; 100 end
6
- end
7
-
8
- describe TorqueBox::Messaging::DataMapper do
9
-
10
- describe "DataMapper::Resource" do
11
- it "should _dump as a string with the ID and class name" do
12
- model = MyTestDataMapperModel.new
13
- id, clazz = model._dump(-1).split(':')
14
- clazz.should == model.class.name
15
- id.should == "100"
16
- end
17
-
18
- it "should call Resource.get with the id on Marshal.load" do
19
- MyTestDataMapperModel.should_receive(:get).with("100")
20
- Marshal.load(Marshal.dump(MyTestDataMapperModel.new))
21
- end
22
- end
23
-
24
- end
25
-
@@ -1,21 +0,0 @@
1
- require 'torquebox/messaging/processor_middleware/default_middleware'
2
-
3
- class Thing
4
- include TorqueBox::Messaging::ProcessorMiddleware::DefaultMiddleware
5
- end
6
-
7
-
8
- describe TorqueBox::Messaging::ProcessorMiddleware::DefaultMiddleware do
9
-
10
- before(:each) do
11
- @thing = Thing.new
12
- end
13
-
14
- describe "#middleware" do
15
- it "should return the default middleware" do
16
- @thing.middleware.inspect.should == "[TorqueBox::Messaging::ProcessorMiddleware::WithTransaction]"
17
- end
18
- end
19
-
20
-
21
- end
@@ -1,248 +0,0 @@
1
-
2
- require 'torquebox/messaging/queue'
3
- require 'torquebox/messaging/topic'
4
- require 'torquebox/service_registry'
5
-
6
- java_import org.mockito.ArgumentCaptor
7
- java_import org.mockito.Matchers
8
- java_import org.mockito.Mockito
9
- java_import org.hornetq.jms.server.impl.JMSServerManagerImpl
10
-
11
- describe TorqueBox::Messaging::Destination do
12
-
13
- after(:each) do
14
- TorqueBox::Registry.registry.clear
15
- end
16
-
17
- it "should return its name for to_s" do
18
- queue = TorqueBox::Messaging::Queue.new("/queues/foo")
19
- queue.name.should == "/queues/foo"
20
- topic = TorqueBox::Messaging::Topic.new("/topics/bar")
21
- topic.name.should == "/topics/bar"
22
- end
23
-
24
- it "should fall back to internal connection factory" do
25
- factory = Object.new
26
- TorqueBox::Registry.merge!("connection-factory" => factory)
27
- queue = TorqueBox::Messaging::Queue.new("/queues/foo")
28
- queue.connection_factory.internal_connection_factory.should == factory
29
- end
30
-
31
- it "should initialize with connection factory if given" do
32
- factory = Object.new
33
- queue = TorqueBox::Messaging::Queue.new("/queues/foo", factory)
34
- queue.connection_factory.internal_connection_factory.should == factory
35
- queue.connect_options.should be_empty
36
- end
37
-
38
- it "should default to no connect options" do
39
- queue = TorqueBox::Messaging::Queue.new("/queues/foo")
40
- queue.connect_options.should be_empty
41
- end
42
-
43
- it "should initialize with connect options if given" do
44
- queue = TorqueBox::Messaging::Queue.new("/queues/foo", :host => "bart")
45
- queue.connect_options[:host].should == "bart"
46
- end
47
-
48
- it "should connect with host and port if given" do
49
- factory = mock("factory")
50
- connection = mock("connection").as_null_object
51
- factory.stub(:create_connection).and_return(connection)
52
-
53
- queue = TorqueBox::Messaging::Queue.new("/queues/foo", :host => "bar", :port => 123)
54
- queue.connection_factory.should_receive(:create_connection_factory).with("bar", 123).and_return(factory)
55
- queue.with_session { }
56
- end
57
-
58
- it "should connect with host and port if given even when inside container" do
59
- internal_factory = Object.new
60
- TorqueBox::Registry.merge!("connection-factory" => internal_factory)
61
- factory = mock("factory")
62
- connection = mock("connection").as_null_object
63
- factory.stub(:create_connection).and_return(connection)
64
-
65
- queue = TorqueBox::Messaging::Queue.new("/queues/foo", :host => "bar", :port => 123)
66
- queue.connection_factory.should_receive(:create_connection_factory).with("bar", 123).and_return(factory)
67
- queue.with_session { }
68
- end
69
-
70
- it "should connect with username and password if given" do
71
- factory = mock("factory")
72
- connection = mock("connection").as_null_object
73
- factory.should_receive(:create_connection).with("ham", "biscuit").and_return(connection)
74
- TorqueBox::Registry.merge!("connection-factory" => factory)
75
-
76
- queue = TorqueBox::Messaging::Queue.new("/queues/foo", :username => "ham", :password => "biscuit")
77
- queue.with_session { }
78
- end
79
-
80
- it "should start and stop a queue" do
81
- destinationizer = mock("Destinationizer")
82
- destinationizer.should_receive(:create_queue).with("my_queue", true, "", false).and_return(true)
83
- destinationizer.should_receive(:remove_destination).with("my_queue")
84
-
85
- TorqueBox::Messaging::Destination.should_receive(:with_destinationizer).twice.and_yield(destinationizer)
86
-
87
- queue = TorqueBox::Messaging::Queue.start("my_queue")
88
- queue.should_not be_nil
89
- queue.name.should == "my_queue"
90
- queue.stop
91
- end
92
-
93
- it "should start and stop a topic" do
94
- destinationizer = mock("Destinationizer")
95
- destinationizer.should_receive(:create_topic).with("my_topic", false).and_return(true)
96
- destinationizer.should_receive(:remove_destination).with("my_topic")
97
-
98
- TorqueBox::Messaging::Destination.should_receive(:with_destinationizer).twice.and_yield(destinationizer)
99
-
100
- topic = TorqueBox::Messaging::Topic.start( "my_topic" )
101
- topic.name.should == "my_topic"
102
- topic.stop
103
- end
104
-
105
- it "should start a queue and stop it in an synchronous way" do
106
- destinationizer = mock("Destinationizer")
107
- destinationizer.should_receive(:create_queue).with("my_queue", true, "", false)
108
- destinationizer.should_receive(:remove_destination).with("my_queue")
109
-
110
- TorqueBox::Messaging::Destination.should_receive(:with_destinationizer).twice.and_yield(destinationizer)
111
-
112
- queue = TorqueBox::Messaging::Queue.start("my_queue")
113
- queue.should_not be_nil
114
- queue.name.should == "my_queue"
115
- queue.stop_sync
116
- end
117
-
118
- it "should start a topic and stop it in an synchronous way" do
119
- destinationizer = mock("Destinationizer")
120
- destinationizer.should_receive(:create_topic).with("my_topic", false)
121
- destinationizer.should_receive(:remove_destination).with("my_topic")
122
-
123
- TorqueBox::Messaging::Destination.should_receive(:with_destinationizer).twice.and_yield(destinationizer)
124
-
125
- topic = TorqueBox::Messaging::Topic.start( "my_topic" )
126
- topic.name.should == "my_topic"
127
- topic.stop_sync
128
- end
129
-
130
- it "should raise ArgumentError if destination is nil" do
131
- lambda {
132
- TorqueBox::Messaging::Queue.new( nil )
133
- }.should raise_error( ArgumentError )
134
- lambda {
135
- TorqueBox::Messaging::Topic.new( nil )
136
- }.should raise_error( ArgumentError )
137
- end
138
-
139
- describe "publish" do
140
- before(:each) do
141
- @session = mock('session')
142
- @session.stub(:transacted?).and_return(false)
143
- @queue = TorqueBox::Messaging::Queue.new('foo')
144
- @queue.stub(:with_session).and_yield(@session)
145
- end
146
-
147
- context "normalizing options" do
148
- context "priority" do
149
- {
150
- :low => 1,
151
- :normal => 4,
152
- :high => 7,
153
- :critical => 9
154
- }.each do |symbol, level|
155
- it "should normalize :#{symbol} to #{level}" do
156
- @session.should_receive(:publish).with(anything, anything, { :priority => level })
157
- @queue.publish('message', { :priority => symbol })
158
- end
159
- end
160
-
161
- it "should pass through valid integer priorities" do
162
- @session.should_receive(:publish).with(anything, anything, { :priority => 5 })
163
- @queue.publish('message', { :priority => 5 })
164
- end
165
-
166
- it "should pass through valid integer-as-string priorities" do
167
- @session.should_receive(:publish).with(anything, anything, { :priority => 5 })
168
- @queue.publish('message', { :priority => "5" })
169
- end
170
-
171
- it "should raise on an invalid integer" do
172
- lambda {
173
- @queue.publish('message', { :priority => -1 })
174
- }.should raise_error(ArgumentError)
175
- end
176
- end
177
-
178
- it "should handle persistence = true" do
179
- @session.should_receive(:publish).with(anything, anything, { :delivery_mode => javax.jms::DeliveryMode.PERSISTENT })
180
- @queue.publish('message', { :persistent => true })
181
- end
182
-
183
- it "should handle persistence = false" do
184
- @session.should_receive(:publish).with(anything, anything, { :delivery_mode => javax.jms::DeliveryMode.NON_PERSISTENT })
185
- @queue.publish('message', { :persistent => false })
186
- end
187
- end
188
- end
189
-
190
- context "queue management" do
191
- before(:each) do
192
- jms_manager = mock('JMSManager')
193
- @server_control = mock('ServerControl')
194
-
195
- TorqueBox::ServiceRegistry.stub!(:lookup).with("jboss.messaging.default.jms.manager").and_yield(jms_manager)
196
- Java::org.hornetq.jms.management.impl.JMSServerControlImpl.stub!(:new).with(jms_manager).and_return(@server_control)
197
- end
198
-
199
- describe "lookup" do
200
- it "should return nil lookup if queue unavailable" do
201
- @server_control.should_receive(:queue_names).and_return([])
202
- TorqueBox::Messaging::Queue.lookup('/queues/doesntexist').should be_nil
203
- end
204
- end
205
-
206
- describe "list" do
207
- before(:each) do
208
- jms_manager = mock('JMSManager')
209
- @server_control = mock('ServerControl')
210
-
211
- TorqueBox::Registry.merge!("connection-factory" => Object.new)
212
- TorqueBox::Registry.merge!("transaction-manager" => Object.new)
213
- TorqueBox::ServiceRegistry.stub!(:lookup).with("jboss.messaging.default.jms.manager").and_yield(jms_manager)
214
- Java::org.hornetq.jms.management.impl.JMSServerControlImpl.stub!(:new).with(jms_manager).and_return(@server_control)
215
- end
216
-
217
- it "should return empty list if no queues are available" do
218
- @server_control.should_receive(:queue_names).and_return([])
219
-
220
- TorqueBox::Messaging::Queue.list.should == []
221
- end
222
-
223
- it "should return empty list if no topics are available" do
224
- @server_control.should_receive(:topic_names).and_return([])
225
-
226
- TorqueBox::Messaging::Topic.list.should == []
227
- end
228
-
229
- it "should return list with available queues" do
230
- @server_control.should_receive(:queue_names).and_return(['/queues/one', '/queues/two'])
231
-
232
- queues = TorqueBox::Messaging::Queue.list
233
- queues.size.should == 2
234
- queues[0].name.should == '/queues/one'
235
- queues[1].name.should == '/queues/two'
236
- end
237
-
238
- it "should return list with available topics" do
239
- @server_control.should_receive(:topic_names).and_return(['/topics/one', '/topics/two'])
240
-
241
- topics = TorqueBox::Messaging::Topic.list
242
- topics.size.should == 2
243
- topics[0].name.should == '/topics/one'
244
- topics[1].name.should == '/topics/two'
245
- end
246
- end
247
- end
248
- end