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/message_spec.rb DELETED
@@ -1,135 +0,0 @@
1
- require 'torquebox/messaging/message'
2
-
3
- include TorqueBox::Messaging
4
-
5
- class DummyMessage < Message
6
- ENCODING = :dummy
7
- end
8
-
9
- Message.register_encoding( DummyMessage )
10
-
11
- def mock_message
12
- msg = mock( 'JMSMessage' )
13
- msg.stub( :get_string_property ).and_return( 'dummy' )
14
- msg
15
- end
16
-
17
- describe TorqueBox::Messaging::Message do
18
-
19
- describe "message property population" do
20
-
21
- it "should do nothing if no properties are submitted" do
22
- jms_message = mock_message
23
- jms_message.should_not_receive(:setStringProperty)
24
-
25
- Message.new(jms_message).populate_message_properties nil
26
- end
27
-
28
- it "should register properties with String keys" do
29
- properties = {'abc' => 'def'}
30
-
31
- jms_message = mock_message
32
- jms_message.should_receive(:set_string_property).with('abc', 'def')
33
-
34
- Message.new(jms_message).populate_message_properties properties
35
- end
36
-
37
- it "should register properties with Symbol keys" do
38
- properties = {:abc => :def}
39
-
40
- jms_message = mock_message
41
- jms_message.should_receive(:set_string_property).with('abc', 'def')
42
-
43
- Message.new(jms_message).populate_message_properties properties
44
- end
45
-
46
- it "should register true as a boolean" do
47
- properties = {:abc => true}
48
-
49
- jms_message = mock_message
50
- jms_message.should_receive(:set_boolean_property).with('abc', true)
51
-
52
- Message.new(jms_message).populate_message_properties properties
53
- end
54
-
55
- it "should register false as a boolean" do
56
- properties = {:abc => false}
57
-
58
- jms_message = mock_message
59
- jms_message.should_receive(:set_boolean_property).with('abc', false)
60
-
61
- Message.new(jms_message).populate_message_properties properties
62
- end
63
-
64
- it "should register 5 as an long" do
65
- properties = {:abc => 5}
66
-
67
- jms_message = mock_message
68
- jms_message.should_receive(:set_long_property).with('abc', 5)
69
-
70
- Message.new(jms_message).populate_message_properties properties
71
- end
72
-
73
- it "should register 5.5 as a double" do
74
- properties = {:abc => 5.5}
75
-
76
- jms_message = mock_message
77
- jms_message.should_receive(:set_double_property).with('abc', 5.5)
78
-
79
- Message.new(jms_message).populate_message_properties properties
80
- end
81
- end
82
-
83
- describe 'encodings' do
84
- before(:each) do
85
- @class = mock("MessageSubClass", :new => nil)
86
- @session = mock("Session", :is_a? => true)
87
- end
88
-
89
- it 'should use the default encoding if none provided' do
90
- Message.should_receive(:class_for_encoding).with(Message::DEFAULT_ENCODE_ENCODING).and_return(@class)
91
- Message.new(@session)
92
- end
93
-
94
- it 'should use the given encoding if provided' do
95
- Message.should_receive(:class_for_encoding).with(:biscuit).and_return(@class)
96
- Message.new(@session, nil, :biscuit)
97
- end
98
-
99
- it 'should use the encoding from the env if set and no encoding is passed to the constructor' do
100
- ENV['DEFAULT_MESSAGE_ENCODING'] = 'ham'
101
- Message.should_receive(:class_for_encoding).with(:ham).and_return(@class)
102
- Message.new(@session)
103
- ENV['DEFAULT_MESSAGE_ENCODING'] = nil
104
- end
105
-
106
- it 'should ignore the encoding from the env if set and an encoding is passed to the constructor' do
107
- ENV['DEFAULT_MESSAGE_ENCODING'] = 'ham'
108
- Message.should_receive(:class_for_encoding).with(:biscuit).and_return(@class)
109
- Message.new(@session, nil, :biscuit)
110
- ENV['DEFAULT_MESSAGE_ENCODING'] = nil
111
- end
112
- end
113
-
114
- describe 'delegating to jms_message' do
115
- before(:each) do
116
- @jms_msg = mock_message
117
- @message = Message.new(@jms_msg)
118
- end
119
-
120
- it "should pass any missing calls through" do
121
- @jms_msg.should_receive(:ham).with(:biscuit)
122
- @message.ham(:biscuit)
123
- end
124
-
125
- it "should properly report if the jms_message responds to the method" do
126
- @jms_msg.should_receive(:ham).never
127
- @message.respond_to?(:ham).should be_true
128
- end
129
-
130
- it "should properly report if the jms_message does not respond to the method" do
131
- @message.respond_to?(:ham).should_not be_true
132
- end
133
- end
134
-
135
- end
data/spec/task_spec.rb DELETED
@@ -1,111 +0,0 @@
1
- require 'torquebox/messaging/future_responder'
2
- require 'torquebox/messaging/future'
3
- require 'torquebox/messaging/queue'
4
- require 'torquebox/messaging/task'
5
-
6
- class MyTestTask < TorqueBox::Messaging::Task
7
- attr_accessor :payload
8
-
9
- def action(payload={ })
10
- future.status = 1
11
- end
12
- end
13
-
14
- class TorqueBox::Messaging::FutureResponder
15
- def respond
16
- yield
17
- end
18
- end
19
-
20
- describe TorqueBox::Messaging::Task do
21
-
22
-
23
- describe '#async' do
24
- before(:each) do
25
- TorqueBox::Messaging::Future.stub(:unique_id).and_return('1234')
26
- @send_queue = mock('queue')
27
- @send_queue.stub(:publish)
28
- TorqueBox::Messaging::Queue.should_receive(:new).with(MyTestTask.queue_name).and_return(@send_queue)
29
- end
30
-
31
- it "should send payload correctly" do
32
- expectation = [{:method => :payload=, :payload => {:foo => 'bar'}, :future_id => '1234', :future_queue => MyTestTask.queue_name('my_test'), :future_ttl => nil}, anything]
33
- @send_queue.should_receive(:publish).with(*expectation)
34
-
35
- MyTestTask.async(:payload=, :foo => 'bar')
36
- end
37
-
38
- it "should send payload correctly with custom future ttl" do
39
- expectation = [{:method => :payload=, :payload => {:foo => 'bar'}, :future_id => '1234', :future_queue => MyTestTask.queue_name('my_test'), :future_ttl => 10_000}, anything]
40
- @send_queue.should_receive(:publish).with(*expectation)
41
-
42
- MyTestTask.async(:payload=, {:foo => 'bar'}, {:future_ttl => 10_000})
43
- end
44
-
45
- it "should handle nil payload as empty hash" do
46
- @send_queue.should_receive(:publish).with(hash_including(:payload => {}), anything)
47
-
48
- MyTestTask.async(:payload=)
49
- end
50
-
51
- it "should return a future" do
52
- result = MyTestTask.async(:payload=)
53
- result.is_a?(TorqueBox::Messaging::Future).should be_true
54
- end
55
-
56
- it "should always use the :marshal encoding" do
57
- @send_queue.should_receive(:publish).with(anything, hash_including(:encoding => :marshal))
58
-
59
- MyTestTask.async(:payload=)
60
- end
61
- end
62
-
63
- describe "#process!" do
64
- it "should process payload correctly" do
65
- expectation = {:method => :payload=, :payload => {:foo => 'bar'}, :future_id => '1234', :future_queue => MyTestTask.queue_name('my_test')}
66
- message = mock("message")
67
- message.should_receive(:decode).and_return(expectation)
68
-
69
- task = MyTestTask.new
70
- task.process! message
71
- task.payload[:foo].should == 'bar'
72
- end
73
- end
74
-
75
- describe 'the future proxy' do
76
- it "should be available inside a task method" do
77
- TorqueBox::Messaging::FutureResponder.should_receive(:status=).with(1)
78
- MyTestTask.new.action
79
- end
80
- end
81
-
82
- describe "queue_name" do
83
- before(:each) do
84
- ENV['TORQUEBOX_APP_NAME'] = 'app_name'
85
- end
86
-
87
- after(:each) do
88
- ENV.delete('TORQUEBOX_APP_NAME')
89
- end
90
-
91
- it "should derive the queue name from the class name" do
92
- MyTestTask.queue_name.should =~ %r{/my_test$}
93
- end
94
-
95
- it "should include the app name in the queue name" do
96
- MyTestTask.queue_name.should =~ %r{/app_name/}
97
- end
98
-
99
- {
100
- 'FooTask' => 'foo',
101
- 'FooBarTask' => 'foo_bar',
102
- 'Foo::BarBazTask' => 'foo/bar_baz'
103
- }.each do |given, expected|
104
- it "should generate the proper queue name for #{given}" do
105
- MyTestTask.stub(:name).and_return(given)
106
- MyTestTask.queue_name.should == "/queues/torquebox/app_name/tasks/#{expected}"
107
- end
108
- end
109
-
110
- end
111
- end