torquebox-messaging 2.3.2-java → 3.0.0.beta1-java
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hornetq-commons-2.3.0.CR1.jar +0 -0
- data/lib/hornetq-core-client-2.3.0.CR1.jar +0 -0
- data/lib/hornetq-jms-client-2.3.0.CR1.jar +0 -0
- data/lib/hornetq-journal-2.3.0.CR1.jar +0 -0
- data/lib/jboss-logging-3.1.2.GA.jar +0 -0
- data/lib/jboss-logmanager-1.4.0.Final.jar +0 -0
- data/lib/netty-3.6.2.Final.jar +0 -0
- data/lib/torquebox/messaging/backgroundable.rb +16 -8
- data/lib/torquebox/messaging/backgroundable_processor.rb +2 -1
- data/lib/torquebox/messaging/connection.rb +21 -74
- data/lib/torquebox/messaging/connection_factory.rb +52 -13
- data/lib/torquebox/messaging/datamapper_marshaling.rb +1 -0
- data/lib/torquebox/messaging/destination.rb +77 -8
- data/lib/torquebox/messaging/echo_processor.rb +1 -0
- data/lib/torquebox/messaging/edn_message.rb +0 -11
- data/lib/torquebox/messaging/future_responder.rb +2 -2
- data/lib/torquebox/messaging/json_message.rb +0 -24
- data/lib/torquebox/messaging/marshal_base64_message.rb +0 -18
- data/lib/torquebox/messaging/marshal_message.rb +4 -5
- data/lib/torquebox/messaging/message.rb +10 -0
- data/lib/torquebox/messaging/message_processor.rb +162 -3
- data/lib/torquebox/messaging/processor_middleware/chain.rb +1 -0
- data/lib/torquebox/messaging/processor_middleware/default_middleware.rb +1 -0
- data/lib/torquebox/messaging/processor_middleware/with_transaction.rb +1 -0
- data/lib/torquebox/messaging/queue.rb +210 -41
- data/lib/torquebox/messaging/session.rb +4 -8
- data/lib/torquebox/messaging/task.rb +8 -6
- data/lib/torquebox/messaging/topic.rb +23 -11
- data/lib/torquebox/messaging/xa_connection.rb +22 -25
- data/lib/torquebox/messaging/xa_connection_factory.rb +2 -17
- data/lib/torquebox/messaging/xa_session.rb +21 -0
- data/lib/torquebox-messaging.jar +0 -0
- data/lib/torquebox-messaging.rb +9 -5
- data/licenses/cc0-1.0.txt +121 -0
- data/spec/backgroundable_spec.rb +21 -0
- data/spec/destination_spec.rb +81 -14
- data/spec/message_processor_spec.rb +151 -1
- data/spec/task_spec.rb +8 -1
- metadata +51 -65
- data/lib/hornetq-core-2.2.21.Final.jar +0 -0
- data/lib/hornetq-jms-2.2.21.Final.jar +0 -0
- data/lib/netty-3.2.6.Final.jar +0 -0
- data/licenses/lgpl-2.1.txt +0 -502
- data/spec/json_message_spec.rb +0 -50
@@ -23,6 +23,7 @@ module TorqueBox
|
|
23
23
|
AUTO_ACK = javax.jms::Session::AUTO_ACKNOWLEDGE
|
24
24
|
CLIENT_ACK = javax.jms::Session::CLIENT_ACKNOWLEDGE
|
25
25
|
DUPS_OK_ACK = javax.jms::Session::DUPS_OK_ACKNOWLEDGE
|
26
|
+
SESSION_TRANSACTED = javax.jms::Session::SESSION_TRANSACTED
|
26
27
|
|
27
28
|
attr_accessor :jms_session
|
28
29
|
|
@@ -149,14 +150,9 @@ module TorqueBox
|
|
149
150
|
end
|
150
151
|
|
151
152
|
def java_destination(destination)
|
152
|
-
java_destination
|
153
|
-
|
154
|
-
|
155
|
-
meth = destination.is_a?( Queue ) ? :create_queue : :create_topic
|
156
|
-
java_destination = @jms_session.send( meth, java_destination )
|
157
|
-
end
|
158
|
-
|
159
|
-
java_destination
|
153
|
+
return destination.java_destination unless destination.java_destination.nil?
|
154
|
+
meth = destination.is_a?( Queue ) ? :create_queue : :create_topic
|
155
|
+
@jms_session.send( meth, destination.name )
|
160
156
|
end
|
161
157
|
|
162
158
|
def self.canonical_ack_mode(ack_mode)
|
@@ -23,11 +23,12 @@ require 'torquebox/messaging/processor_middleware/default_middleware'
|
|
23
23
|
|
24
24
|
module TorqueBox
|
25
25
|
module Messaging
|
26
|
-
|
27
|
-
|
26
|
+
|
27
|
+
# @api private
|
28
|
+
class Task
|
28
29
|
include FutureStatus
|
29
30
|
include ProcessorMiddleware::DefaultMiddleware
|
30
|
-
|
31
|
+
|
31
32
|
def self.queue_name( name = self.name[0...-4] )
|
32
33
|
suffix = org.torquebox.core.util.StringUtils.underscore(name)
|
33
34
|
"/queues/torquebox/#{ENV['TORQUEBOX_APP_NAME']}/tasks/#{suffix}"
|
@@ -40,11 +41,12 @@ module TorqueBox
|
|
40
41
|
:method => method,
|
41
42
|
:payload => payload,
|
42
43
|
:future_id => future.correlation_id,
|
43
|
-
:future_queue => queue_name
|
44
|
+
:future_queue => queue_name,
|
45
|
+
:future_ttl => options[:future_ttl]
|
44
46
|
}
|
45
47
|
options[:encoding] = :marshal
|
46
48
|
queue.publish( message, options )
|
47
|
-
|
49
|
+
|
48
50
|
future
|
49
51
|
rescue javax.naming.NameNotFoundException => ex
|
50
52
|
raise RuntimeError.new("The queue for #{self.name} is not available. Did you disable it by setting its concurrency to 0?")
|
@@ -52,7 +54,7 @@ module TorqueBox
|
|
52
54
|
|
53
55
|
def process!(message)
|
54
56
|
hash = message.decode
|
55
|
-
FutureResponder.new( Queue.new( hash[:future_queue] ), hash[:future_id] ).respond do
|
57
|
+
FutureResponder.new( Queue.new( hash[:future_queue] ), hash[:future_id], hash[:future_ttl] ).respond do
|
56
58
|
self.send hash[:method].to_sym, hash[:payload]
|
57
59
|
end
|
58
60
|
end
|
@@ -23,21 +23,33 @@ module TorqueBox
|
|
23
23
|
class Topic < Destination
|
24
24
|
|
25
25
|
DEFAULT_SUBSCRIBER_NAME = 'subscriber-1'
|
26
|
-
|
27
|
-
def self.start( name, options={} )
|
28
|
-
jndi = options.fetch( :jndi, [].to_java(:string) )
|
29
|
-
TorqueBox::ServiceRegistry.lookup("jboss.messaging.default.jms.manager") do |server|
|
30
|
-
server.createTopic( false, name, jndi )
|
31
|
-
end
|
32
|
-
new( name )
|
33
|
-
end
|
34
26
|
|
35
|
-
|
36
|
-
|
37
|
-
|
27
|
+
class << self
|
28
|
+
|
29
|
+
# Creates the topic, starts and return a Topic object.
|
30
|
+
#
|
31
|
+
# @param name The name of the topic
|
32
|
+
# @param options Optional parameters (a Hash), including:
|
33
|
+
# @option options [Boolean] :exported If the topic should be visible in remote JNDI lookups
|
34
|
+
# @return [Topic] if the service is created and started
|
35
|
+
# @return [nil] if the service is not created in the specified time (30 s)
|
36
|
+
def start(name, options={})
|
37
|
+
exported = options.fetch(:exported, false)
|
38
|
+
|
39
|
+
with_destinationizer do |destinationizer|
|
40
|
+
latch = destinationizer.create_topic(name, exported)
|
41
|
+
return nil unless TorqueBox::Messaging::Destination.wait_for_latch(latch)
|
42
|
+
end
|
43
|
+
|
44
|
+
new(name, options)
|
38
45
|
end
|
39
46
|
end
|
40
47
|
|
48
|
+
# Unsubscribes the selected subscriber from the topic
|
49
|
+
#
|
50
|
+
# @param subscriber_name The subscriber name to unsubscribe
|
51
|
+
# @param options Optional parameters (a Hash)
|
52
|
+
# @return [void]
|
41
53
|
def unsubscribe(subscriber_name = DEFAULT_SUBSCRIBER_NAME, options = { })
|
42
54
|
wait_for_destination(options[:startup_timeout]) do
|
43
55
|
with_session do |session|
|
@@ -17,40 +17,37 @@
|
|
17
17
|
|
18
18
|
module TorqueBox
|
19
19
|
module Messaging
|
20
|
-
class XaConnection
|
20
|
+
class XaConnection < Connection
|
21
21
|
|
22
|
-
def
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
@
|
22
|
+
def with_session(&block)
|
23
|
+
# Re-use a single XaSession per XaConnection
|
24
|
+
# This session gets closed by the afterCompletion
|
25
|
+
# callback on XaSession
|
26
|
+
@session ||= create_session
|
27
|
+
block.call( @session )
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
31
|
-
|
30
|
+
def create_session(auto_enlist = true)
|
31
|
+
jms_session = jms_connection.create_xa_session
|
32
|
+
session = XaSession.new( jms_session, transaction, self )
|
33
|
+
if auto_enlist
|
34
|
+
transaction.enlist_resource( jms_session.xa_resource )
|
35
|
+
transaction.registerSynchronization( session )
|
36
|
+
end
|
37
|
+
session
|
32
38
|
end
|
33
39
|
|
34
|
-
def
|
35
|
-
@
|
40
|
+
def session_transaction
|
41
|
+
@session.nil? ? nil : @session.transaction
|
36
42
|
end
|
37
43
|
|
38
|
-
def
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
def with_session(&block)
|
43
|
-
session = self.create_session()
|
44
|
-
begin
|
45
|
-
result = block.call( session )
|
46
|
-
ensure
|
47
|
-
session.close
|
48
|
-
end
|
49
|
-
return result
|
44
|
+
def close
|
45
|
+
super if @complete
|
50
46
|
end
|
51
47
|
|
52
|
-
def
|
53
|
-
|
48
|
+
def complete!
|
49
|
+
@complete = true
|
50
|
+
close
|
54
51
|
end
|
55
52
|
|
56
53
|
end
|
@@ -20,22 +20,11 @@ require 'torquebox/messaging/connection'
|
|
20
20
|
|
21
21
|
module TorqueBox
|
22
22
|
module Messaging
|
23
|
-
class XaConnectionFactory
|
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?( XaConnectionFactory )
|
29
|
-
super
|
30
|
-
end
|
31
|
-
|
32
|
-
def initialize(internal_connection_factory = nil)
|
33
|
-
@internal_connection_factory = internal_connection_factory
|
34
|
-
end
|
23
|
+
class XaConnectionFactory < ConnectionFactory
|
35
24
|
|
36
25
|
def with_new_connection(options, &block)
|
37
26
|
client_id = options[:client_id]
|
38
|
-
connection =
|
27
|
+
connection = create_xa_connection( options )
|
39
28
|
connection.client_id = client_id
|
40
29
|
connection.start
|
41
30
|
begin
|
@@ -46,10 +35,6 @@ module TorqueBox
|
|
46
35
|
return result
|
47
36
|
end
|
48
37
|
|
49
|
-
def create_connection()
|
50
|
-
XaConnection.new( @internal_connection_factory.create_xa_connection )
|
51
|
-
end
|
52
|
-
|
53
38
|
|
54
39
|
def to_s
|
55
40
|
"[XaConnectionFactory: internal_connection_factory=#{internal_connection_factory}]"
|
@@ -19,6 +19,27 @@ module TorqueBox
|
|
19
19
|
module Messaging
|
20
20
|
|
21
21
|
class XaSession < Session
|
22
|
+
include javax.transaction.Synchronization
|
23
|
+
attr_reader :transaction
|
24
|
+
|
25
|
+
def initialize( jms_session, transaction, connection )
|
26
|
+
super( jms_session )
|
27
|
+
@transaction = transaction
|
28
|
+
@connection = connection
|
29
|
+
end
|
30
|
+
|
31
|
+
def close
|
32
|
+
# eat the close, until tx completes
|
33
|
+
end
|
34
|
+
|
35
|
+
def beforeCompletion
|
36
|
+
# required interface
|
37
|
+
end
|
38
|
+
|
39
|
+
def afterCompletion(status)
|
40
|
+
@connection.deactivate
|
41
|
+
@connection.complete!
|
42
|
+
end
|
22
43
|
|
23
44
|
def xa_resource
|
24
45
|
@jms_session.xa_resource
|
data/lib/torquebox-messaging.jar
CHANGED
Binary file
|
data/lib/torquebox-messaging.rb
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
module TorqueboxMessaging
|
2
|
-
VERSION = '
|
3
|
-
MAVEN_VERSION = '
|
2
|
+
VERSION = '3.0.0.beta1'
|
3
|
+
MAVEN_VERSION = '3.0.0.beta1'
|
4
4
|
end
|
5
5
|
begin
|
6
6
|
require 'java'
|
7
7
|
require File.dirname(__FILE__) + '/torquebox-messaging.jar'
|
8
8
|
require File.dirname(__FILE__) + '/jboss-jms-api_1.1_spec-1.0.1.Final.jar'
|
9
9
|
require File.dirname(__FILE__) + '/jboss-transaction-api_1.1_spec-1.0.1.Final.jar'
|
10
|
-
require File.dirname(__FILE__) + '/hornetq-core-2.
|
11
|
-
require File.dirname(__FILE__) + '/hornetq-
|
12
|
-
require File.dirname(__FILE__) + '/
|
10
|
+
require File.dirname(__FILE__) + '/hornetq-core-client-2.3.0.CR1.jar'
|
11
|
+
require File.dirname(__FILE__) + '/hornetq-commons-2.3.0.CR1.jar'
|
12
|
+
require File.dirname(__FILE__) + '/jboss-logging-3.1.2.GA.jar'
|
13
|
+
require File.dirname(__FILE__) + '/netty-3.6.2.Final.jar'
|
14
|
+
require File.dirname(__FILE__) + '/hornetq-journal-2.3.0.CR1.jar'
|
15
|
+
require File.dirname(__FILE__) + '/jboss-logmanager-1.4.0.Final.jar'
|
16
|
+
require File.dirname(__FILE__) + '/hornetq-jms-client-2.3.0.CR1.jar'
|
13
17
|
rescue LoadError
|
14
18
|
puts 'JAR-based gems require JRuby to load. Please visit www.jruby.org.'
|
15
19
|
raise
|
@@ -0,0 +1,121 @@
|
|
1
|
+
Creative Commons Legal Code
|
2
|
+
|
3
|
+
CC0 1.0 Universal
|
4
|
+
|
5
|
+
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
6
|
+
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
7
|
+
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
8
|
+
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
9
|
+
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
10
|
+
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
11
|
+
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
12
|
+
HEREUNDER.
|
13
|
+
|
14
|
+
Statement of Purpose
|
15
|
+
|
16
|
+
The laws of most jurisdictions throughout the world automatically confer
|
17
|
+
exclusive Copyright and Related Rights (defined below) upon the creator
|
18
|
+
and subsequent owner(s) (each and all, an "owner") of an original work of
|
19
|
+
authorship and/or a database (each, a "Work").
|
20
|
+
|
21
|
+
Certain owners wish to permanently relinquish those rights to a Work for
|
22
|
+
the purpose of contributing to a commons of creative, cultural and
|
23
|
+
scientific works ("Commons") that the public can reliably and without fear
|
24
|
+
of later claims of infringement build upon, modify, incorporate in other
|
25
|
+
works, reuse and redistribute as freely as possible in any form whatsoever
|
26
|
+
and for any purposes, including without limitation commercial purposes.
|
27
|
+
These owners may contribute to the Commons to promote the ideal of a free
|
28
|
+
culture and the further production of creative, cultural and scientific
|
29
|
+
works, or to gain reputation or greater distribution for their Work in
|
30
|
+
part through the use and efforts of others.
|
31
|
+
|
32
|
+
For these and/or other purposes and motivations, and without any
|
33
|
+
expectation of additional consideration or compensation, the person
|
34
|
+
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
35
|
+
is an owner of Copyright and Related Rights in the Work, voluntarily
|
36
|
+
elects to apply CC0 to the Work and publicly distribute the Work under its
|
37
|
+
terms, with knowledge of his or her Copyright and Related Rights in the
|
38
|
+
Work and the meaning and intended legal effect of CC0 on those rights.
|
39
|
+
|
40
|
+
1. Copyright and Related Rights. A Work made available under CC0 may be
|
41
|
+
protected by copyright and related or neighboring rights ("Copyright and
|
42
|
+
Related Rights"). Copyright and Related Rights include, but are not
|
43
|
+
limited to, the following:
|
44
|
+
|
45
|
+
i. the right to reproduce, adapt, distribute, perform, display,
|
46
|
+
communicate, and translate a Work;
|
47
|
+
ii. moral rights retained by the original author(s) and/or performer(s);
|
48
|
+
iii. publicity and privacy rights pertaining to a person's image or
|
49
|
+
likeness depicted in a Work;
|
50
|
+
iv. rights protecting against unfair competition in regards to a Work,
|
51
|
+
subject to the limitations in paragraph 4(a), below;
|
52
|
+
v. rights protecting the extraction, dissemination, use and reuse of data
|
53
|
+
in a Work;
|
54
|
+
vi. database rights (such as those arising under Directive 96/9/EC of the
|
55
|
+
European Parliament and of the Council of 11 March 1996 on the legal
|
56
|
+
protection of databases, and under any national implementation
|
57
|
+
thereof, including any amended or successor version of such
|
58
|
+
directive); and
|
59
|
+
vii. other similar, equivalent or corresponding rights throughout the
|
60
|
+
world based on applicable law or treaty, and any national
|
61
|
+
implementations thereof.
|
62
|
+
|
63
|
+
2. Waiver. To the greatest extent permitted by, but not in contravention
|
64
|
+
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
65
|
+
irrevocably and unconditionally waives, abandons, and surrenders all of
|
66
|
+
Affirmer's Copyright and Related Rights and associated claims and causes
|
67
|
+
of action, whether now known or unknown (including existing as well as
|
68
|
+
future claims and causes of action), in the Work (i) in all territories
|
69
|
+
worldwide, (ii) for the maximum duration provided by applicable law or
|
70
|
+
treaty (including future time extensions), (iii) in any current or future
|
71
|
+
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
72
|
+
including without limitation commercial, advertising or promotional
|
73
|
+
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
74
|
+
member of the public at large and to the detriment of Affirmer's heirs and
|
75
|
+
successors, fully intending that such Waiver shall not be subject to
|
76
|
+
revocation, rescission, cancellation, termination, or any other legal or
|
77
|
+
equitable action to disrupt the quiet enjoyment of the Work by the public
|
78
|
+
as contemplated by Affirmer's express Statement of Purpose.
|
79
|
+
|
80
|
+
3. Public License Fallback. Should any part of the Waiver for any reason
|
81
|
+
be judged legally invalid or ineffective under applicable law, then the
|
82
|
+
Waiver shall be preserved to the maximum extent permitted taking into
|
83
|
+
account Affirmer's express Statement of Purpose. In addition, to the
|
84
|
+
extent the Waiver is so judged Affirmer hereby grants to each affected
|
85
|
+
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
86
|
+
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
87
|
+
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
88
|
+
maximum duration provided by applicable law or treaty (including future
|
89
|
+
time extensions), (iii) in any current or future medium and for any number
|
90
|
+
of copies, and (iv) for any purpose whatsoever, including without
|
91
|
+
limitation commercial, advertising or promotional purposes (the
|
92
|
+
"License"). The License shall be deemed effective as of the date CC0 was
|
93
|
+
applied by Affirmer to the Work. Should any part of the License for any
|
94
|
+
reason be judged legally invalid or ineffective under applicable law, such
|
95
|
+
partial invalidity or ineffectiveness shall not invalidate the remainder
|
96
|
+
of the License, and in such case Affirmer hereby affirms that he or she
|
97
|
+
will not (i) exercise any of his or her remaining Copyright and Related
|
98
|
+
Rights in the Work or (ii) assert any associated claims and causes of
|
99
|
+
action with respect to the Work, in either case contrary to Affirmer's
|
100
|
+
express Statement of Purpose.
|
101
|
+
|
102
|
+
4. Limitations and Disclaimers.
|
103
|
+
|
104
|
+
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
105
|
+
surrendered, licensed or otherwise affected by this document.
|
106
|
+
b. Affirmer offers the Work as-is and makes no representations or
|
107
|
+
warranties of any kind concerning the Work, express, implied,
|
108
|
+
statutory or otherwise, including without limitation warranties of
|
109
|
+
title, merchantability, fitness for a particular purpose, non
|
110
|
+
infringement, or the absence of latent or other defects, accuracy, or
|
111
|
+
the present or absence of errors, whether or not discoverable, all to
|
112
|
+
the greatest extent permissible under applicable law.
|
113
|
+
c. Affirmer disclaims responsibility for clearing rights of other persons
|
114
|
+
that may apply to the Work or any use thereof, including without
|
115
|
+
limitation any person's Copyright and Related Rights in the Work.
|
116
|
+
Further, Affirmer disclaims responsibility for obtaining any necessary
|
117
|
+
consents, permissions or other rights required for any use of the
|
118
|
+
Work.
|
119
|
+
d. Affirmer understands and acknowledges that Creative Commons is not a
|
120
|
+
party to this document and has no duty or obligation with respect to
|
121
|
+
this CC0 or use of the Work.
|
data/spec/backgroundable_spec.rb
CHANGED
@@ -176,6 +176,7 @@ describe TorqueBox::Messaging::Backgroundable do
|
|
176
176
|
:future_id => '1234',
|
177
177
|
:future_queue => "/queues/torquebox//tasks/torquebox_backgroundable",
|
178
178
|
:method => '__sync_an_async_action',
|
179
|
+
:future_ttl => nil,
|
179
180
|
:args => [:a, :b]
|
180
181
|
},
|
181
182
|
anything)
|
@@ -221,6 +222,16 @@ describe TorqueBox::Messaging::Backgroundable do
|
|
221
222
|
@object.background.foo(1,2)
|
222
223
|
end
|
223
224
|
|
225
|
+
it "should use default future ttl" do
|
226
|
+
@queue.should_receive(:publish).with(hash_including(:future_ttl => nil), anything)
|
227
|
+
@object.background.foo
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should use custom future ttl" do
|
231
|
+
@queue.should_receive(:publish).with(hash_including(:future_ttl => 100_000), anything)
|
232
|
+
@object.background(:future_ttl => 100_000).foo
|
233
|
+
end
|
234
|
+
|
224
235
|
it "should raise when given a block" do
|
225
236
|
lambda {
|
226
237
|
@object.background.foo { }
|
@@ -270,6 +281,16 @@ describe TorqueBox::Messaging::Backgroundable do
|
|
270
281
|
@object.background.foo(1,2)
|
271
282
|
end
|
272
283
|
|
284
|
+
it "should use default future ttl" do
|
285
|
+
@queue.should_receive(:publish).with(hash_including(:future_ttl => nil), anything)
|
286
|
+
@object.background.foo
|
287
|
+
end
|
288
|
+
|
289
|
+
it "should use custom future ttl" do
|
290
|
+
@queue.should_receive(:publish).with(hash_including(:future_ttl => 100_000), anything)
|
291
|
+
@object.background(:future_ttl => 100_000).foo
|
292
|
+
end
|
293
|
+
|
273
294
|
it "should raise when given a block" do
|
274
295
|
lambda {
|
275
296
|
@object.background.foo { }
|
data/spec/destination_spec.rb
CHANGED
@@ -77,33 +77,98 @@ describe TorqueBox::Messaging::Destination do
|
|
77
77
|
queue.with_session { }
|
78
78
|
end
|
79
79
|
|
80
|
+
it "should return nil if the queue start times out" do
|
81
|
+
latch = mock("StartLatch")
|
82
|
+
latch.should_receive(:await).with(kind_of(Numeric), java.util.concurrent.TimeUnit::SECONDS).and_raise("boom")
|
83
|
+
|
84
|
+
destinationizer = mock("Destinationizer")
|
85
|
+
destinationizer.should_receive(:create_queue).with("my_queue", true, "", false).and_return(latch)
|
86
|
+
|
87
|
+
TorqueBox::Messaging::Destination.should_receive(:with_destinationizer).and_yield(destinationizer)
|
88
|
+
|
89
|
+
queue = TorqueBox::Messaging::Queue.start("my_queue")
|
90
|
+
queue.should be_nil
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should return nil if the topic start times out" do
|
94
|
+
latch = mock("StartLatch")
|
95
|
+
latch.should_receive(:await).with(kind_of(Numeric), java.util.concurrent.TimeUnit::SECONDS).and_raise("boom")
|
96
|
+
|
97
|
+
destinationizer = mock("Destinationizer")
|
98
|
+
destinationizer.should_receive(:create_topic).with("my_topic", false).and_return(latch)
|
99
|
+
|
100
|
+
TorqueBox::Messaging::Destination.should_receive(:with_destinationizer).and_yield(destinationizer)
|
101
|
+
|
102
|
+
topic = TorqueBox::Messaging::Topic.start( "my_topic" )
|
103
|
+
topic.should be_nil
|
104
|
+
end
|
105
|
+
|
80
106
|
it "should start and stop a queue" do
|
81
|
-
|
82
|
-
|
107
|
+
latch = mock("StartLatch")
|
108
|
+
latch.should_receive(:await).with(kind_of(Numeric), java.util.concurrent.TimeUnit::SECONDS)
|
109
|
+
|
110
|
+
destinationizer = mock("Destinationizer")
|
111
|
+
destinationizer.should_receive(:create_queue).with("my_queue", true, "", false).and_return(latch)
|
112
|
+
destinationizer.should_receive(:remove_destination).with("my_queue")
|
83
113
|
|
84
|
-
|
114
|
+
TorqueBox::Messaging::Destination.should_receive(:with_destinationizer).twice.and_yield(destinationizer)
|
115
|
+
|
116
|
+
queue = TorqueBox::Messaging::Queue.start("my_queue")
|
117
|
+
queue.should_not be_nil
|
85
118
|
queue.name.should == "my_queue"
|
86
119
|
queue.stop
|
87
|
-
|
88
|
-
Mockito.verify(server).createQueue(Matchers.anyBoolean,
|
89
|
-
Matchers.eq("my_queue"),
|
90
|
-
Matchers.anyString,
|
91
|
-
Matchers.anyBoolean)
|
92
|
-
Mockito.verify(server).destroyQueue("my_queue")
|
93
120
|
end
|
94
121
|
|
95
122
|
it "should start and stop a topic" do
|
96
|
-
|
97
|
-
|
123
|
+
latch = mock("StartLatch")
|
124
|
+
latch.should_receive(:await).with(kind_of(Numeric), java.util.concurrent.TimeUnit::SECONDS)
|
125
|
+
|
126
|
+
destinationizer = mock("Destinationizer")
|
127
|
+
destinationizer.should_receive(:create_topic).with("my_topic", false).and_return(latch)
|
128
|
+
destinationizer.should_receive(:remove_destination).with("my_topic")
|
129
|
+
|
130
|
+
TorqueBox::Messaging::Destination.should_receive(:with_destinationizer).twice.and_yield(destinationizer)
|
98
131
|
|
99
132
|
topic = TorqueBox::Messaging::Topic.start( "my_topic" )
|
100
133
|
topic.name.should == "my_topic"
|
101
134
|
topic.stop
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should start a queue and stop it in an synchronous way" do
|
138
|
+
start_latch = mock("StartLatch")
|
139
|
+
start_latch.should_receive(:await).with(kind_of(Numeric), java.util.concurrent.TimeUnit::SECONDS)
|
140
|
+
|
141
|
+
stop_latch = mock("StopLatch")
|
142
|
+
stop_latch.should_receive(:await).with(kind_of(Numeric), java.util.concurrent.TimeUnit::SECONDS)
|
143
|
+
|
144
|
+
destinationizer = mock("Destinationizer")
|
145
|
+
destinationizer.should_receive(:create_queue).with("my_queue", true, "", false).and_return(start_latch)
|
146
|
+
destinationizer.should_receive(:remove_destination).with("my_queue").and_return(stop_latch)
|
147
|
+
|
148
|
+
TorqueBox::Messaging::Destination.should_receive(:with_destinationizer).twice.and_yield(destinationizer)
|
149
|
+
|
150
|
+
queue = TorqueBox::Messaging::Queue.start("my_queue")
|
151
|
+
queue.should_not be_nil
|
152
|
+
queue.name.should == "my_queue"
|
153
|
+
queue.stop_sync
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should start a topic and stop it in an synchronous way" do
|
157
|
+
start_latch = mock("StartLatch")
|
158
|
+
start_latch.should_receive(:await).with(kind_of(Numeric), java.util.concurrent.TimeUnit::SECONDS)
|
159
|
+
|
160
|
+
stop_latch = mock("StopLatch")
|
161
|
+
stop_latch.should_receive(:await).with(kind_of(Numeric), java.util.concurrent.TimeUnit::SECONDS)
|
102
162
|
|
103
|
-
|
104
|
-
|
163
|
+
destinationizer = mock("Destinationizer")
|
164
|
+
destinationizer.should_receive(:create_topic).with("my_topic", false).and_return(start_latch)
|
165
|
+
destinationizer.should_receive(:remove_destination).with("my_topic").and_return(stop_latch)
|
105
166
|
|
106
|
-
|
167
|
+
TorqueBox::Messaging::Destination.should_receive(:with_destinationizer).twice.and_yield(destinationizer)
|
168
|
+
|
169
|
+
topic = TorqueBox::Messaging::Topic.start( "my_topic" )
|
170
|
+
topic.name.should == "my_topic"
|
171
|
+
topic.stop_sync
|
107
172
|
end
|
108
173
|
|
109
174
|
it "should raise ArgumentError if destination is nil" do
|
@@ -187,6 +252,8 @@ describe TorqueBox::Messaging::Destination do
|
|
187
252
|
jms_manager = mock('JMSManager')
|
188
253
|
@server_control = mock('ServerControl')
|
189
254
|
|
255
|
+
TorqueBox::Registry.merge!("connection-factory" => Object.new)
|
256
|
+
TorqueBox::Registry.merge!("transaction-manager" => Object.new)
|
190
257
|
TorqueBox::ServiceRegistry.stub!(:lookup).with("jboss.messaging.default.jms.manager").and_yield(jms_manager)
|
191
258
|
Java::org.hornetq.jms.management.impl.JMSServerControlImpl.stub!(:new).with(jms_manager).and_return(@server_control)
|
192
259
|
end
|