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.
- checksums.yaml +4 -4
- data/lib/torquebox-messaging.rb +19 -20
- data/lib/torquebox/messaging.rb +80 -20
- data/lib/torquebox/messaging/context.rb +174 -0
- data/lib/torquebox/messaging/destination.rb +164 -215
- data/lib/torquebox/messaging/helpers.rb +34 -0
- data/lib/torquebox/messaging/hornetq.rb +70 -0
- data/lib/torquebox/messaging/hornetq/address_settings.rb +228 -0
- data/lib/torquebox/messaging/queue.rb +139 -301
- data/lib/torquebox/messaging/topic.rb +84 -46
- data/lib/wunderboss-jars/hornetq-commons-2.4.5.Final.jar +0 -0
- data/lib/wunderboss-jars/hornetq-core-client-2.4.5.Final.jar +0 -0
- data/lib/wunderboss-jars/hornetq-jms-client-2.4.5.Final.jar +0 -0
- data/lib/wunderboss-jars/hornetq-jms-server-2.4.5.Final.jar +0 -0
- data/lib/wunderboss-jars/hornetq-journal-2.4.5.Final.jar +0 -0
- data/lib/wunderboss-jars/hornetq-native-2.4.5.Final.jar +0 -0
- data/lib/wunderboss-jars/hornetq-server-2.4.5.Final.jar +0 -0
- data/lib/wunderboss-jars/javax.inject-1.jar +0 -0
- data/lib/wunderboss-jars/jboss-common-core-2.2.10.GA.jar +0 -0
- data/lib/wunderboss-jars/jboss-connector-api_1.5_spec-1.0.0.Final.jar +0 -0
- data/lib/wunderboss-jars/jboss-jms-api_2.0_spec-1.0.0.Final.jar +0 -0
- data/lib/wunderboss-jars/jboss-transaction-api_1.1_spec-1.0.0.Final.jar +0 -0
- data/lib/wunderboss-jars/jboss-transaction-spi-7.0.0.Final.jar +0 -0
- data/lib/wunderboss-jars/jnpserver-5.0.3.GA.jar +0 -0
- data/lib/wunderboss-jars/netty-all-4.0.13.Final.jar +0 -0
- data/lib/wunderboss-jars/wunderboss-messaging-1.x.incremental.174.jar +0 -0
- metadata +88 -98
- data/lib/gem_hook.rb +0 -51
- data/lib/hornetq-commons-2.3.1.Final.jar +0 -0
- data/lib/hornetq-core-client-2.3.1.Final.jar +0 -0
- data/lib/hornetq-jms-client-2.3.1.Final.jar +0 -0
- data/lib/hornetq-journal-2.3.1.Final.jar +0 -0
- data/lib/jboss-jms-api_1.1_spec-1.0.1.Final.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/jboss-transaction-api_1.1_spec-1.0.1.Final.jar +0 -0
- data/lib/netty-3.6.2.Final.jar +0 -0
- data/lib/org.torquebox.messaging-client.rb +0 -20
- data/lib/torquebox-messaging.jar +0 -0
- data/lib/torquebox/messaging/backgroundable.rb +0 -250
- data/lib/torquebox/messaging/backgroundable_processor.rb +0 -52
- data/lib/torquebox/messaging/connection.rb +0 -74
- data/lib/torquebox/messaging/connection_factory.rb +0 -115
- data/lib/torquebox/messaging/const_missing.rb +0 -28
- data/lib/torquebox/messaging/core.rb +0 -27
- data/lib/torquebox/messaging/datamapper_marshaling.rb +0 -43
- data/lib/torquebox/messaging/echo_processor.rb +0 -35
- data/lib/torquebox/messaging/edn_message.rb +0 -26
- data/lib/torquebox/messaging/ext/javax_jms_queue_browser.rb +0 -25
- data/lib/torquebox/messaging/future.rb +0 -131
- data/lib/torquebox/messaging/future_responder.rb +0 -109
- data/lib/torquebox/messaging/future_status.rb +0 -37
- data/lib/torquebox/messaging/json_message.rb +0 -26
- data/lib/torquebox/messaging/marshal_base64_message.rb +0 -26
- data/lib/torquebox/messaging/marshal_message.rb +0 -43
- data/lib/torquebox/messaging/message.rb +0 -137
- data/lib/torquebox/messaging/message_processor.rb +0 -209
- data/lib/torquebox/messaging/processor_middleware/chain.rb +0 -89
- data/lib/torquebox/messaging/processor_middleware/default_middleware.rb +0 -39
- data/lib/torquebox/messaging/processor_middleware/with_transaction.rb +0 -35
- data/lib/torquebox/messaging/session.rb +0 -173
- data/lib/torquebox/messaging/task.rb +0 -66
- data/lib/torquebox/messaging/text_message.rb +0 -36
- data/lib/torquebox/messaging/xa_connection.rb +0 -55
- data/lib/torquebox/messaging/xa_connection_factory.rb +0 -45
- data/lib/torquebox/messaging/xa_session.rb +0 -51
- data/licenses/cc0-1.0.txt +0 -121
- data/spec/backgroundable_spec.rb +0 -319
- data/spec/chain_spec.rb +0 -160
- data/spec/datamapper_marshaling_spec.rb +0 -25
- data/spec/default_middleware_spec.rb +0 -21
- data/spec/destination_spec.rb +0 -248
- data/spec/future_responder_spec.rb +0 -81
- data/spec/future_spec.rb +0 -163
- data/spec/message_processor_spec.rb +0 -211
- data/spec/message_spec.rb +0 -135
- data/spec/task_spec.rb +0 -111
@@ -1,39 +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/processor_middleware/chain'
|
19
|
-
require 'torquebox/messaging/processor_middleware/with_transaction'
|
20
|
-
|
21
|
-
module TorqueBox
|
22
|
-
module Messaging
|
23
|
-
# @api private
|
24
|
-
module ProcessorMiddleware
|
25
|
-
module DefaultMiddleware
|
26
|
-
|
27
|
-
def self.default
|
28
|
-
ProcessorMiddleware::Chain.new.append(WithTransaction)
|
29
|
-
end
|
30
|
-
|
31
|
-
def middleware
|
32
|
-
@middleware ||= DefaultMiddleware.default
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
@@ -1,35 +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/transactions'
|
19
|
-
|
20
|
-
module TorqueBox
|
21
|
-
module Messaging
|
22
|
-
# @api private
|
23
|
-
module ProcessorMiddleware
|
24
|
-
class WithTransaction
|
25
|
-
|
26
|
-
def call(session, message)
|
27
|
-
# This middleware is now a no-op and should be removed
|
28
|
-
yield
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,173 +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
|
-
module TorqueBox
|
19
|
-
module Messaging
|
20
|
-
|
21
|
-
class Session
|
22
|
-
|
23
|
-
AUTO_ACK = javax.jms::Session::AUTO_ACKNOWLEDGE
|
24
|
-
CLIENT_ACK = javax.jms::Session::CLIENT_ACKNOWLEDGE
|
25
|
-
DUPS_OK_ACK = javax.jms::Session::DUPS_OK_ACKNOWLEDGE
|
26
|
-
SESSION_TRANSACTED = javax.jms::Session::SESSION_TRANSACTED
|
27
|
-
|
28
|
-
attr_accessor :jms_session
|
29
|
-
|
30
|
-
def initialize(jms_session)
|
31
|
-
@jms_session = jms_session
|
32
|
-
end
|
33
|
-
|
34
|
-
def close
|
35
|
-
@jms_session.close
|
36
|
-
end
|
37
|
-
|
38
|
-
def queue_for(name)
|
39
|
-
Queue.new( @jms_session.create_queue( name ) )
|
40
|
-
end
|
41
|
-
|
42
|
-
def publish(destination, payload, options={})
|
43
|
-
producer = @jms_session.create_producer( java_destination( destination ) )
|
44
|
-
message = Message.new( @jms_session, payload, options[:encoding] )
|
45
|
-
|
46
|
-
options[:properties] ||= {}
|
47
|
-
|
48
|
-
# This will let us create messages to be scheduled later like this:
|
49
|
-
#
|
50
|
-
# queue.publish(:ham => :biscuit, :scheduled => Time.now + 10)
|
51
|
-
# queue.publish(:ham => :biscuit, :scheduled => Time.now + 2.5)
|
52
|
-
#
|
53
|
-
# In Rails it is possible to do:
|
54
|
-
#
|
55
|
-
# queue.publish(:ham => :biscuit, :scheduled => 3.minutes.from_now)
|
56
|
-
#
|
57
|
-
# Please note that the :scheduled parameter takes a Time object.
|
58
|
-
if options.has_key?(:scheduled)
|
59
|
-
options[:properties][Java::org.hornetq.api.core.Message::HDR_SCHEDULED_DELIVERY_TIME.to_s] = (options[:scheduled].to_f * 1000).to_i
|
60
|
-
end
|
61
|
-
|
62
|
-
message.populate_message_headers(options)
|
63
|
-
message.populate_message_properties(options[:properties])
|
64
|
-
|
65
|
-
producer.send( message.jms_message,
|
66
|
-
options.fetch(:delivery_mode, producer.delivery_mode),
|
67
|
-
options.fetch(:priority, producer.priority),
|
68
|
-
options.fetch(:ttl, producer.time_to_live) )
|
69
|
-
message
|
70
|
-
end
|
71
|
-
|
72
|
-
# Returns decoded message, by default. Pass :decode=>false to
|
73
|
-
# return the original JMS TextMessage. Pass :timeout to give up
|
74
|
-
# after a number of milliseconds
|
75
|
-
def receive(destination, options={})
|
76
|
-
decode = options.fetch(:decode, true)
|
77
|
-
timeout = options.fetch(:timeout, 0)
|
78
|
-
selector = options[:selector]
|
79
|
-
|
80
|
-
java_destination = java_destination( destination )
|
81
|
-
if options[:durable] && java_destination.class.name =~ /Topic/
|
82
|
-
consumer = @jms_session.createDurableSubscriber( java_destination,
|
83
|
-
options.fetch(:subscriber_name, Topic::DEFAULT_SUBSCRIBER_NAME),
|
84
|
-
selector,
|
85
|
-
false )
|
86
|
-
else
|
87
|
-
consumer = @jms_session.createConsumer( java_destination, selector )
|
88
|
-
end
|
89
|
-
begin
|
90
|
-
jms_message = consumer.receive( timeout )
|
91
|
-
if jms_message
|
92
|
-
message = decode ? Message.new( jms_message ).decode : jms_message
|
93
|
-
block_given? ? yield(message) : message
|
94
|
-
end
|
95
|
-
ensure
|
96
|
-
consumer.close unless consumer.nil?
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
# Implement the request-response pattern. Sends a message to the
|
101
|
-
# request destination and waits for a reply on the response
|
102
|
-
# destination.
|
103
|
-
#
|
104
|
-
# Options:
|
105
|
-
#
|
106
|
-
# :timeout - specifies the time in miliseconds to wait for answer,
|
107
|
-
# default: 10000 (10s)
|
108
|
-
# :decode - pass false to return the original JMS TextMessage,
|
109
|
-
# default: true
|
110
|
-
#
|
111
|
-
def publish_and_receive(destination, message, options = {})
|
112
|
-
options[:timeout] ||= 10_000 # 10s
|
113
|
-
options[:properties] ||= {}
|
114
|
-
options[:properties]["synchronous"] = "true"
|
115
|
-
message = publish(destination, message, options)
|
116
|
-
|
117
|
-
options[:selector] = "JMSCorrelationID='#{message.jms_message.jms_message_id}'"
|
118
|
-
receive(destination, options)
|
119
|
-
end
|
120
|
-
|
121
|
-
# Receiving end of the request-response pattern. The return value of
|
122
|
-
# the block passed to this method is the response sent back to the
|
123
|
-
# client. If no block is given then request is returned as the
|
124
|
-
# response.
|
125
|
-
def receive_and_publish(destination, options = {})
|
126
|
-
selector = "synchronous = 'true'"
|
127
|
-
selector = "#{selector} and (#{options[:selector]})" if options[:selector]
|
128
|
-
receive_options = options.merge(:decode => false,
|
129
|
-
:selector => selector)
|
130
|
-
|
131
|
-
request = receive(destination, receive_options)
|
132
|
-
unless request.nil?
|
133
|
-
request_message = Message.new( request ).decode
|
134
|
-
options[:ttl] ||= 60_000 # 1m
|
135
|
-
options[:encoding] ||= Message.extract_encoding_from_message( request )
|
136
|
-
|
137
|
-
response = block_given? ? yield(request_message) : request_message
|
138
|
-
|
139
|
-
options[:correlation_id] = request.jms_message_id
|
140
|
-
publish(destination, response, options)
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
def unsubscribe(subscriber_name = Topic::DEFAULT_SUBSCRIBER_NAME)
|
145
|
-
@jms_session.unsubscribe( subscriber_name )
|
146
|
-
end
|
147
|
-
|
148
|
-
def create_browser(*args)
|
149
|
-
jms_session.create_browser( *args )
|
150
|
-
end
|
151
|
-
|
152
|
-
def java_destination(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 )
|
156
|
-
end
|
157
|
-
|
158
|
-
def self.canonical_ack_mode(ack_mode)
|
159
|
-
case ( ack_mode )
|
160
|
-
when Fixnum
|
161
|
-
return ack_mode
|
162
|
-
when :auto
|
163
|
-
return AUTO_ACK
|
164
|
-
when :client
|
165
|
-
return CLIENT_ACK
|
166
|
-
when :dups_ok
|
167
|
-
return DUPS_OK_ACK
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
end
|
173
|
-
end
|
@@ -1,66 +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_responder'
|
20
|
-
require 'torquebox/messaging/future'
|
21
|
-
require 'torquebox/messaging/future_status'
|
22
|
-
require 'torquebox/messaging/processor_middleware/default_middleware'
|
23
|
-
|
24
|
-
module TorqueBox
|
25
|
-
module Messaging
|
26
|
-
|
27
|
-
# @api private
|
28
|
-
class Task
|
29
|
-
include FutureStatus
|
30
|
-
include ProcessorMiddleware::DefaultMiddleware
|
31
|
-
|
32
|
-
def self.queue_name( name = self.name[0...-4] )
|
33
|
-
suffix = org.torquebox.core.util.StringUtils.underscore(name)
|
34
|
-
"/queues/torquebox/#{ENV['TORQUEBOX_APP_NAME']}/tasks/#{suffix}"
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.async(method, payload = {}, options = {})
|
38
|
-
queue = Queue.new( queue_name )
|
39
|
-
future = Future.new( queue )
|
40
|
-
message = {
|
41
|
-
:method => method,
|
42
|
-
:payload => payload,
|
43
|
-
:future_id => future.correlation_id,
|
44
|
-
:future_queue => queue_name,
|
45
|
-
:future_ttl => options[:future_ttl]
|
46
|
-
}
|
47
|
-
options[:encoding] = :marshal
|
48
|
-
queue.publish( message, options )
|
49
|
-
|
50
|
-
future
|
51
|
-
rescue javax.naming.NameNotFoundException => ex
|
52
|
-
raise RuntimeError.new("The queue for #{self.name} is not available. Did you disable it by setting its concurrency to 0?")
|
53
|
-
end
|
54
|
-
|
55
|
-
def process!(message)
|
56
|
-
hash = message.decode
|
57
|
-
FutureResponder.new( Queue.new( hash[:future_queue] ), hash[:future_id], hash[:future_ttl] ).respond do
|
58
|
-
self.send hash[:method].to_sym, hash[:payload]
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
@@ -1,36 +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
|
-
module TorqueBox
|
19
|
-
module Messaging
|
20
|
-
class TextMessage < Message
|
21
|
-
ENCODING = :text
|
22
|
-
JMS_TYPE = :text
|
23
|
-
|
24
|
-
def encode(message)
|
25
|
-
@jms_message.text = message || ''
|
26
|
-
end
|
27
|
-
|
28
|
-
def decode
|
29
|
-
@jms_message.text
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
Message.register_encoding( TextMessage )
|
35
|
-
end
|
36
|
-
end
|
@@ -1,55 +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
|
-
module TorqueBox
|
19
|
-
module Messaging
|
20
|
-
class XaConnection < Connection
|
21
|
-
|
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
|
-
end
|
29
|
-
|
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
|
38
|
-
end
|
39
|
-
|
40
|
-
def session_transaction
|
41
|
-
@session.nil? ? nil : @session.transaction
|
42
|
-
end
|
43
|
-
|
44
|
-
def close
|
45
|
-
super if @complete
|
46
|
-
end
|
47
|
-
|
48
|
-
def complete!
|
49
|
-
@complete = true
|
50
|
-
close
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,45 +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 XaConnectionFactory < ConnectionFactory
|
24
|
-
|
25
|
-
def with_new_connection(options, &block)
|
26
|
-
client_id = options[:client_id]
|
27
|
-
connection = create_xa_connection( options )
|
28
|
-
connection.client_id = client_id
|
29
|
-
connection.start
|
30
|
-
begin
|
31
|
-
result = block.call( connection )
|
32
|
-
ensure
|
33
|
-
connection.close
|
34
|
-
end
|
35
|
-
return result
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
def to_s
|
40
|
-
"[XaConnectionFactory: internal_connection_factory=#{internal_connection_factory}]"
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|