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,26 +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 JSONMessage < Message
|
21
|
-
ENCODING = :json
|
22
|
-
JMS_TYPE = :text
|
23
|
-
end
|
24
|
-
Message.register_encoding( JSONMessage )
|
25
|
-
end
|
26
|
-
end
|
@@ -1,26 +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 MarshalBase64Message < Message
|
21
|
-
ENCODING = :marshal_base64
|
22
|
-
JMS_TYPE = :text
|
23
|
-
end
|
24
|
-
Message.register_encoding( MarshalBase64Message )
|
25
|
-
end
|
26
|
-
end
|
@@ -1,43 +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/codecs'
|
19
|
-
|
20
|
-
module TorqueBox
|
21
|
-
module Messaging
|
22
|
-
class MarshalMessage < Message
|
23
|
-
ENCODING = :marshal
|
24
|
-
JMS_TYPE = :bytes
|
25
|
-
|
26
|
-
def encode(message)
|
27
|
-
@jms_message.write_bytes(TorqueBox::Codecs.encode(message, ENCODING).to_java_bytes)
|
28
|
-
end
|
29
|
-
|
30
|
-
def decode
|
31
|
-
if (length = @jms_message.get_body_length) > 0
|
32
|
-
bytes = Java::byte[length].new
|
33
|
-
@jms_message.read_bytes( bytes )
|
34
|
-
@jms_message.reset
|
35
|
-
TorqueBox::Codecs.decode(String.from_java_bytes(bytes), ENCODING)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
Message.register_encoding( MarshalMessage )
|
42
|
-
end
|
43
|
-
end
|
@@ -1,137 +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/codecs'
|
19
|
-
|
20
|
-
module TorqueBox
|
21
|
-
module Messaging
|
22
|
-
class Message
|
23
|
-
|
24
|
-
attr_reader :jms_message
|
25
|
-
|
26
|
-
# if no encoding specified in the message itself assume the legacy encoding
|
27
|
-
DEFAULT_DECODE_ENCODING = :marshal_base64
|
28
|
-
|
29
|
-
# if no encoding specified when creating a message and no global
|
30
|
-
# defaut set use :marshal
|
31
|
-
DEFAULT_ENCODE_ENCODING = :marshal
|
32
|
-
|
33
|
-
ENCODING_PROPERTY = "__ContentEncoding__"
|
34
|
-
|
35
|
-
def initialize(jms_session, payload)
|
36
|
-
@jms_message = self.class::JMS_TYPE == :text ? jms_session.create_text_message :
|
37
|
-
jms_session.create_bytes_message
|
38
|
-
set_encoding
|
39
|
-
encode( payload )
|
40
|
-
end
|
41
|
-
|
42
|
-
def initialize_from_message(jms_message)
|
43
|
-
@jms_message = jms_message
|
44
|
-
end
|
45
|
-
|
46
|
-
def set_encoding
|
47
|
-
@jms_message.set_string_property( ENCODING_PROPERTY, self.class::ENCODING.to_s )
|
48
|
-
end
|
49
|
-
|
50
|
-
def populate_message_headers(options)
|
51
|
-
return if options.nil?
|
52
|
-
options.each do |key, value|
|
53
|
-
case key.to_s
|
54
|
-
when 'correlation_id' then @jms_message.setJMSCorrelationID(value)
|
55
|
-
when 'reply_to' then @jms_message.setJMSReplyTo(value)
|
56
|
-
when 'type' then @jms_message.setJMSType(value)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def populate_message_properties(properties)
|
62
|
-
return if properties.nil? or properties.empty?
|
63
|
-
properties.each do |key, value|
|
64
|
-
case value
|
65
|
-
when Integer
|
66
|
-
@jms_message.set_long_property(key.to_s, value)
|
67
|
-
when Float
|
68
|
-
@jms_message.set_double_property(key.to_s, value)
|
69
|
-
when TrueClass, FalseClass
|
70
|
-
@jms_message.set_boolean_property(key.to_s, value)
|
71
|
-
else
|
72
|
-
@jms_message.set_string_property(key.to_s, value.to_s)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def method_missing(*args)
|
78
|
-
@jms_message.send(*args)
|
79
|
-
end
|
80
|
-
|
81
|
-
def respond_to?(symbol, include_private = false)
|
82
|
-
super || @jms_message.respond_to?(symbol, include_private)
|
83
|
-
end
|
84
|
-
|
85
|
-
def encode(message)
|
86
|
-
@jms_message.text = TorqueBox::Codecs.encode(message, self.class::ENCODING)
|
87
|
-
end
|
88
|
-
|
89
|
-
def decode
|
90
|
-
TorqueBox::Codecs.decode(@jms_message.text, self.class::ENCODING)
|
91
|
-
end
|
92
|
-
|
93
|
-
class << self
|
94
|
-
alias :__new__ :new
|
95
|
-
|
96
|
-
def inherited(subclass)
|
97
|
-
class << subclass
|
98
|
-
alias :new :__new__
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def new(jms_message_or_session, payload = nil, encoding = nil)
|
103
|
-
if jms_message_or_session.is_a?( javax.jms::Session )
|
104
|
-
encoding ||= ENV['DEFAULT_MESSAGE_ENCODING'] || DEFAULT_ENCODE_ENCODING
|
105
|
-
klass = class_for_encoding( encoding.to_sym )
|
106
|
-
klass.new( jms_message_or_session, payload )
|
107
|
-
else
|
108
|
-
encoding = extract_encoding_from_message( jms_message_or_session ) || DEFAULT_DECODE_ENCODING
|
109
|
-
klass = class_for_encoding( encoding )
|
110
|
-
msg = klass.allocate
|
111
|
-
msg.initialize_from_message( jms_message_or_session )
|
112
|
-
msg
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
def encoding_map
|
117
|
-
@encoding_map ||= { }
|
118
|
-
end
|
119
|
-
|
120
|
-
def register_encoding(klass)
|
121
|
-
encoding_map[klass::ENCODING] = klass
|
122
|
-
end
|
123
|
-
|
124
|
-
def class_for_encoding(encoding)
|
125
|
-
klass = encoding_map[encoding.to_sym]
|
126
|
-
raise ArgumentError.new( "No message class found for encoding '#{encoding}'" ) unless klass
|
127
|
-
klass
|
128
|
-
end
|
129
|
-
|
130
|
-
def extract_encoding_from_message(jms_message)
|
131
|
-
jms_message.get_string_property( ENCODING_PROPERTY )
|
132
|
-
end
|
133
|
-
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
@@ -1,209 +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/default_middleware'
|
19
|
-
|
20
|
-
module TorqueBox
|
21
|
-
module Messaging
|
22
|
-
class MessageProcessor
|
23
|
-
include ProcessorMiddleware::DefaultMiddleware
|
24
|
-
|
25
|
-
attr_accessor :message
|
26
|
-
|
27
|
-
def initialize
|
28
|
-
@message = nil
|
29
|
-
@proxy = nil
|
30
|
-
end
|
31
|
-
|
32
|
-
def initialize_proxy(group)
|
33
|
-
@proxy = MessageProcessorProxy.new(group)
|
34
|
-
end
|
35
|
-
|
36
|
-
def method_missing(method, *args, &block)
|
37
|
-
@proxy.send( method, *args, &block )
|
38
|
-
end
|
39
|
-
|
40
|
-
def on_message(body)
|
41
|
-
throw "Your subclass must implement on_message(body)"
|
42
|
-
end
|
43
|
-
|
44
|
-
def on_error(error)
|
45
|
-
raise error
|
46
|
-
end
|
47
|
-
|
48
|
-
def process!(message)
|
49
|
-
@message = message
|
50
|
-
begin
|
51
|
-
value = on_message(message.decode)
|
52
|
-
reply(value) if synchronous?
|
53
|
-
rescue Exception => e
|
54
|
-
on_error( e )
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def reply(value)
|
59
|
-
TorqueBox::Messaging::Queue.new(@message.jms_message.jms_destination.queue_name).publish(value, :correlation_id => @message.jms_message.jms_message_id)
|
60
|
-
end
|
61
|
-
|
62
|
-
class << self
|
63
|
-
|
64
|
-
# List all available message processors for current application.
|
65
|
-
#
|
66
|
-
# @return [Array<TorqueBox::Messaging::MessageProcessorProxy>] List of
|
67
|
-
# proxy objets to read and manage state of selected message
|
68
|
-
# processor
|
69
|
-
def list
|
70
|
-
processors = []
|
71
|
-
|
72
|
-
TorqueBox::MSC.get_services(/^#{messaging_service_name.canonical_name}\.\".*\"$/) do |service|
|
73
|
-
processors << MessageProcessorProxy.new(service.value)
|
74
|
-
end
|
75
|
-
|
76
|
-
processors
|
77
|
-
end
|
78
|
-
|
79
|
-
# Lookup a message processor by its destination and class name.
|
80
|
-
#
|
81
|
-
# @param [String] The destination name (queue, topic) to which
|
82
|
-
# a message processor is bound.
|
83
|
-
#
|
84
|
-
# @param [String] The class name of the message processor
|
85
|
-
# implementation.
|
86
|
-
def lookup(destination_name, class_name)
|
87
|
-
sn = messaging_service_name.append("#{destination_name}.#{class_name}")
|
88
|
-
|
89
|
-
# Try to find a message procesor for specified parameters
|
90
|
-
group = TorqueBox::ServiceRegistry::lookup(sn)
|
91
|
-
|
92
|
-
return MessageProcessorProxy.new(group) if group
|
93
|
-
|
94
|
-
# Ooops, no processor is found. Most probably wrong data.
|
95
|
-
return nil
|
96
|
-
end
|
97
|
-
|
98
|
-
protected
|
99
|
-
|
100
|
-
def messaging_service_name
|
101
|
-
TorqueBox::MSC.deployment_unit.service_name.append('torquebox').append('messaging')
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
class MessageProcessorProxy
|
107
|
-
def initialize(group)
|
108
|
-
@group = group
|
109
|
-
|
110
|
-
raise "Cannot create MessageProcessorProxy for non-existing MessageProcessorGroup" if @group.nil?
|
111
|
-
end
|
112
|
-
|
113
|
-
attr_reader :destination_name, :class_name
|
114
|
-
|
115
|
-
# Updates the concurrency,
|
116
|
-
#
|
117
|
-
# @note This method sets the concurrency and changes immediately
|
118
|
-
# the number of consumers for specified destination.
|
119
|
-
def concurrency=(size)
|
120
|
-
raise "Setting concurrency for '#{name}' to value < 0 is not allowed. You tried '#{size}'." if size < 0
|
121
|
-
|
122
|
-
return size if size == @group.concurrency
|
123
|
-
|
124
|
-
@group.update_concurrency(size)
|
125
|
-
|
126
|
-
concurrency
|
127
|
-
end
|
128
|
-
|
129
|
-
# Returns the concurrency
|
130
|
-
#
|
131
|
-
# @return Integer
|
132
|
-
def concurrency
|
133
|
-
@group.concurrency
|
134
|
-
end
|
135
|
-
|
136
|
-
# Returns the group name
|
137
|
-
#
|
138
|
-
# @return String
|
139
|
-
def name
|
140
|
-
@group.name
|
141
|
-
end
|
142
|
-
|
143
|
-
# Returns the destination (queue or topic) name
|
144
|
-
#
|
145
|
-
# @return String
|
146
|
-
def destination_name
|
147
|
-
@group.destination_name
|
148
|
-
end
|
149
|
-
|
150
|
-
# Returns the message processor implementation
|
151
|
-
# class name
|
152
|
-
#
|
153
|
-
# @return String
|
154
|
-
def class_name
|
155
|
-
@group.message_processor_class.name
|
156
|
-
end
|
157
|
-
|
158
|
-
# Returns the message selector
|
159
|
-
#
|
160
|
-
# If there is no message selector specified,
|
161
|
-
# returns empty string
|
162
|
-
#
|
163
|
-
# @return String
|
164
|
-
def message_selector
|
165
|
-
@group.message_selector
|
166
|
-
end
|
167
|
-
|
168
|
-
# Returns true if the message processor is a durable
|
169
|
-
# subscriber, false otherwise
|
170
|
-
#
|
171
|
-
# @return Boolean
|
172
|
-
def durable?
|
173
|
-
@group.durable
|
174
|
-
end
|
175
|
-
|
176
|
-
# Returns true if the message processor is synchronous,
|
177
|
-
# false otherwise
|
178
|
-
#
|
179
|
-
# @return Boolean
|
180
|
-
def synchronous?
|
181
|
-
@group.synchronous
|
182
|
-
end
|
183
|
-
|
184
|
-
# Returns true if the message processor is started,
|
185
|
-
# false otherwise
|
186
|
-
#
|
187
|
-
# @return Boolean
|
188
|
-
def started?
|
189
|
-
@group.status.eql?("STARTED")
|
190
|
-
end
|
191
|
-
|
192
|
-
# Starts the message processor
|
193
|
-
#
|
194
|
-
def start
|
195
|
-
@group.start
|
196
|
-
end
|
197
|
-
|
198
|
-
# Stops the message processor
|
199
|
-
#
|
200
|
-
def stop
|
201
|
-
@group.stop
|
202
|
-
end
|
203
|
-
|
204
|
-
def to_s
|
205
|
-
"<MessageProcessorProxy: #{name}>"
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|
209
|
-
end
|
@@ -1,89 +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
|
-
# @api private
|
21
|
-
module ProcessorMiddleware
|
22
|
-
class Chain
|
23
|
-
|
24
|
-
def prepend(klass, *args)
|
25
|
-
chain.unshift(MWare.new(klass, args)) unless locate(klass)
|
26
|
-
self
|
27
|
-
end
|
28
|
-
|
29
|
-
def append(klass, *args)
|
30
|
-
chain << MWare.new(klass, args) unless locate(klass)
|
31
|
-
self
|
32
|
-
end
|
33
|
-
|
34
|
-
alias_method :add, :append
|
35
|
-
|
36
|
-
def remove(klass)
|
37
|
-
loc = locate(klass)
|
38
|
-
chain.delete_at(loc) if loc
|
39
|
-
self
|
40
|
-
end
|
41
|
-
|
42
|
-
def inspect
|
43
|
-
chain.map(&:klass).inspect
|
44
|
-
end
|
45
|
-
|
46
|
-
def invoke(session, message, processor)
|
47
|
-
realized_chain = realize
|
48
|
-
walker = lambda do
|
49
|
-
mware = realized_chain.shift
|
50
|
-
if mware
|
51
|
-
mware.call(session, message, &walker)
|
52
|
-
else
|
53
|
-
processor.process!(message)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
walker.call
|
57
|
-
end
|
58
|
-
|
59
|
-
protected
|
60
|
-
|
61
|
-
def chain
|
62
|
-
@chain ||= []
|
63
|
-
end
|
64
|
-
|
65
|
-
def locate(klass)
|
66
|
-
chain.index { |m| m.klass == klass }
|
67
|
-
end
|
68
|
-
|
69
|
-
def realize
|
70
|
-
chain.map(&:instance)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
class MWare
|
75
|
-
attr_reader :klass
|
76
|
-
|
77
|
-
def initialize(klass, args)
|
78
|
-
@klass = klass
|
79
|
-
@args = args
|
80
|
-
end
|
81
|
-
|
82
|
-
def instance
|
83
|
-
@klass.new(*@args)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|