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
@@ -1,28 +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
- unless defined?(ActiveSupport)
19
- $stderr.puts "WARN: Defining const_missing"
20
-
21
- def Object.const_missing(name)
22
- file = org.torquebox.core.util.StringUtils.underscore(name)
23
- require file
24
- result = const_get(name)
25
- return result if result
26
- raise "Class not found: #{name}"
27
- end
28
- end
@@ -1,27 +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/core/connection_factory'
19
- require 'torquebox/messaging/core/connection'
20
- require 'torquebox/messaging/core/session'
21
- require 'torquebox/messaging/core/message'
22
- require 'torquebox/messaging/core/destination'
23
- require 'torquebox/messaging/core/queue'
24
- require 'torquebox/messaging/core/topic'
25
- require 'torquebox/messaging/core/live_destination'
26
- require 'torquebox/messaging/core/live_queue'
27
- require 'torquebox/messaging/core/live_topic'
@@ -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
- # DataMapper::Resource uses Procs for default values and Marshal.dump
19
- # does not like that. So, when sending or receiving a DataMapper::Resource
20
- # we need to override _dump and _load to just serialize the ID and
21
- # class name of the resource, and use Resource.get to _load it.
22
- module TorqueBox
23
- module Messaging
24
- # @api private
25
- module DataMapper
26
-
27
- def self.included(base)
28
- base.extend(ClassMethods)
29
- end
30
-
31
- def _dump( level )
32
- [id, self.class].join(':')
33
- end
34
-
35
- module ClassMethods
36
- def _load( string )
37
- id, clazz = string.split(':')
38
- Kernel.const_get(clazz).get(id)
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -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
- # @api private
19
- module Torquebox
20
- module Messaging
21
- # A message processor that echos any messages sent to it back to
22
- # another queue specified by the response_queue configuration option
23
- class EchoProcessor < TorqueBox::Messaging::MessageProcessor
24
-
25
- def initialize(options={})
26
- @response_queue = TorqueBox::Messaging::Queue.new(options['response_queue'])
27
- end
28
-
29
- def on_message(body)
30
- @response_queue.publish(body)
31
- end
32
-
33
- end
34
- end
35
- 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 EdnMessage < Message
21
- ENCODING = :edn
22
- JMS_TYPE = :text
23
- end
24
- Message.register_encoding( EdnMessage )
25
- end
26
- end
@@ -1,25 +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 javax.jms::QueueBrowser
19
- include Enumerable
20
-
21
- def each(&block)
22
- enumeration.map{ |m| TorqueBox::Messaging::Message.new(m) }.each(&block)
23
- end
24
- end
25
-
@@ -1,131 +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
- # A Future encapsulates the result of a long running
21
- # process, and is used in conjunction with a {FutureResponder}.
22
- class Future
23
- # We can't really do no timeout - 1ms is as close as we can get.
24
- NO_TIMEOUT = 1
25
-
26
- # Returns the remote error (if any)
27
- attr_reader :error
28
- attr_reader :correlation_id
29
- attr_accessor :default_result_timeout
30
-
31
- # Returns all of the statuses seen by this future as an array.
32
- attr_reader :all_statuses
33
-
34
- # @param [TorqueBox::Messaging::Queue] response_queue The queue
35
- # where response messages are to be received.
36
- # @param [Hash] options Additional options
37
- # @option options [String] :correlation_id (Future.unique_id) The correlation_id used on
38
- # the messages to uniquely identify the call they are for.
39
- # @option options [Integer] :default_result_timeout (30_000) The timeout
40
- # used by default for the receive call. The processing must at
41
- # least start before the timeout expires, and finish before 2x
42
- # this timeout.
43
- def initialize(response_queue, options = { })
44
- @queue = response_queue
45
- @correlation_id = options[:correlation_id] || self.class.unique_id
46
- @default_result_timeout = options[:default_result_timeout] || 30_000
47
- @all_statuses = []
48
- end
49
-
50
- def started?
51
- receive unless @started
52
- !!@started
53
- end
54
-
55
- def complete?
56
- receive unless @complete || @error
57
- !!@complete
58
- end
59
-
60
- def error?
61
- receive unless @complete || @error
62
- !!@error
63
- end
64
-
65
- # Returns the latest response from the remote processor, if
66
- # any. Status reporting is optional, and must be handled by the
67
- # processed task itself.
68
- # @see FutureResponder#status
69
- def status
70
- @prior_status = retrieve_status
71
- end
72
-
73
- # Returns true if the status has changed since the last call to
74
- # {#status}.
75
- def status_changed?
76
- @prior_status != retrieve_status
77
- end
78
-
79
- # Attempts to return the remote result.
80
- # @param [Integer] timeout The processing must at least start
81
- # before the timeout expires, and finish before 2x this timeout.
82
- # @raise [TimeoutException] if the timeout expires when
83
- # receiving the result
84
- # @return the remote result
85
- def result(timeout = default_result_timeout)
86
- receive( timeout ) unless @started
87
- raise TimeoutException.new( "timeout expired waiting for processing to start" ) unless @started
88
- receive( timeout ) unless @complete || @error
89
- raise TimeoutException.new( "timeout expired waiting for processing to finish" ) unless @complete || @error
90
- raise @error if @error
91
- @result
92
- end
93
-
94
- # Delegates to {#result} with the default timeout.
95
- def method_missing(method, *args, &block)
96
- result.send( method, *args, &block )
97
- end
98
-
99
- # @return [String] a unique id useful for correlating a
100
- # result to its call
101
- def self.unique_id
102
- java.util.UUID.randomUUID.to_s
103
- end
104
-
105
- protected
106
- def retrieve_status
107
- receive unless @complete || @error
108
- @status
109
- end
110
-
111
- def receive(timeout = NO_TIMEOUT)
112
- response = @queue.receive( :timeout => timeout, :selector => "JMSCorrelationID = '#{@correlation_id}'" )
113
-
114
- if response
115
- @started = true
116
- if response.has_key?( :status )
117
- @status = response[:status]
118
- @all_statuses << @status
119
- end
120
- @complete = response.has_key?( :result )
121
- @result ||= response[:result]
122
- @error ||= response[:error]
123
- end
124
- end
125
-
126
- end
127
-
128
- class TimeoutException < RuntimeError; end
129
-
130
- end
131
- end
@@ -1,109 +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
- # A FutureResponder encapsulates sending the results of a long
21
- # running process to a {Future}.
22
- class FutureResponder
23
-
24
- # @param [TorqueBox::Messaging::Queue] response_queue The queue
25
- # where response messages are to be published.
26
- # @param [String] correlation_id The correlation_id used on
27
- # the messages to uniquely identify the call they are for.
28
- # @param [Integer] message_ttl The time-to-live used on messages
29
- # to prevent them from staying in the queue indefinately if
30
- # the result is never accessed.
31
- def initialize(response_queue, correlation_id, message_ttl = nil)
32
- @queue = response_queue
33
- @correlation_id = correlation_id
34
- @message_ttl = message_ttl || 600_000
35
- end
36
-
37
- # Signal that processing has started.
38
- def started
39
- send_response(:low)
40
- end
41
-
42
- # Report the current status back to the client. The status value
43
- # is application specific.
44
- def status=(status)
45
- @status_set = true
46
- @status = status
47
- send_response
48
- end
49
-
50
- # Signal that processing has completed.
51
- # @param The result of the operation.
52
- def result=(result)
53
- @result_set = true
54
- @result = result
55
- send_response :high
56
- end
57
-
58
- # Signal that an error occurred during processing.
59
- # @param [Exception] The error!
60
- def error=(error)
61
- @error = error
62
- send_response :high
63
- end
64
-
65
- # Handles started/complete/error for you around the given
66
- # block. The current responder is avaiable inside the block via
67
- # {.current}, which is useful for sending {#status} messages.
68
- def respond
69
- started
70
- Thread.current[:future_responder] = self
71
- self.result = yield
72
- rescue Exception => e
73
- self.error = e
74
- $stderr.puts "FutureResponder#respond: An error occured: ", e
75
- $stderr.puts e.backtrace.join( "\n" )
76
- end
77
-
78
- # Convenience method that returns the thread local
79
- # responder. Only valid inside a block passed to {#respond}.
80
- def self.current
81
- Thread.current[:future_responder]
82
- end
83
-
84
- # Convenience method that allows you to send a status message
85
- # via the {.current} responder. Only valid inside a block passed
86
- # to {#respond}.
87
- def self.status=(status)
88
- current.status = status if current
89
- end
90
-
91
- protected
92
- def send_response(priority = :normal)
93
- message = {}
94
- message[:status] = @status if @status_set
95
- message[:error] = @error if @error
96
- message[:result] = @result if @result_set
97
- @queue.publish( message,
98
- :correlation_id => @correlation_id,
99
- :ttl => @message_ttl,
100
- :priority => priority,
101
- :encoding => :marshal,
102
- :tx => false # can't be a part of the task's tx!
103
- )
104
- rescue TypeError => ex
105
- $stderr.puts "FutureResponder#send_response: Warning: unable to marshal #{@result.inspect}"
106
- end
107
- end
108
- end
109
- end
@@ -1,37 +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/future_responder'
19
-
20
- module TorqueBox
21
- module Messaging
22
- module FutureStatus
23
-
24
- def __future
25
- @__future ||= FutureProxy.new
26
- end
27
- alias_method :future, :__future
28
-
29
- class FutureProxy
30
- def status=(status)
31
- FutureResponder.status = status
32
- end
33
- end
34
- end
35
- end
36
- end
37
-