jruby-hornetq 0.4.0 → 0.5.0.alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. data/Gemfile +9 -0
  2. data/Gemfile.lock +30 -0
  3. data/HISTORY.md +6 -0
  4. data/README.md +33 -35
  5. data/Rakefile +14 -9
  6. data/examples/advanced/batch_client.rb +8 -8
  7. data/examples/advanced/batch_requestor_pattern.rb +34 -34
  8. data/examples/advanced/bytes_producer.rb +3 -3
  9. data/examples/advanced/client.rb +5 -5
  10. data/examples/advanced/client_session_pooling.rb +3 -3
  11. data/examples/advanced/consume_on_message.rb +5 -5
  12. data/examples/advanced/consumer.rb +2 -2
  13. data/examples/advanced/multi_client.rb +3 -3
  14. data/examples/advanced/producer.rb +3 -3
  15. data/examples/advanced/server.rb +4 -4
  16. data/examples/client-server/client.rb +4 -4
  17. data/examples/client-server/server.rb +4 -4
  18. data/examples/producer-consumer/consume_all.rb +2 -2
  19. data/examples/producer-consumer/consume_on_message.rb +5 -5
  20. data/examples/producer-consumer/consumer.rb +2 -2
  21. data/examples/producer-consumer/producer.rb +3 -3
  22. data/examples/resque/hornetq_job.rb +19 -19
  23. data/examples/resque/processor.rb +4 -4
  24. data/examples/resque/sleep_job.rb +3 -3
  25. data/lib/hornetq.rb +3 -2
  26. data/lib/hornetq/client.rb +4 -2
  27. data/lib/hornetq/client/connection.rb +86 -86
  28. data/lib/hornetq/client/message_handler.rb +1 -1
  29. data/lib/hornetq/client/org_hornetq_api_core_client_client_session.rb +67 -67
  30. data/lib/hornetq/client/org_hornetq_core_client_impl_client_consumer_impl.rb +11 -11
  31. data/lib/hornetq/client/org_hornetq_core_client_impl_client_message_impl.rb +126 -126
  32. data/lib/hornetq/client/org_hornetq_core_client_impl_client_producer_impl.rb +14 -14
  33. data/lib/hornetq/client/org_hornetq_utils_typed_properties.rb +6 -6
  34. data/lib/hornetq/client/requestor_pattern.rb +24 -24
  35. data/lib/hornetq/client/server_pattern.rb +4 -4
  36. data/lib/hornetq/client/session_pool.rb +18 -18
  37. data/lib/hornetq/common/logging.rb +1 -14
  38. data/lib/hornetq/java/hornetq-bootstrap.jar +0 -0
  39. data/lib/hornetq/java/hornetq-commons.jar +0 -0
  40. data/lib/hornetq/java/hornetq-core-client.jar +0 -0
  41. data/lib/hornetq/java/hornetq-journal.jar +0 -0
  42. data/lib/hornetq/java/hornetq-server.jar +0 -0
  43. data/lib/hornetq/java/jnp-client.jar +0 -0
  44. data/lib/hornetq/java/netty.jar +0 -0
  45. data/lib/hornetq/server.rb +4 -1
  46. data/lib/hornetq/version.rb +3 -0
  47. data/nbproject/private/private.properties +4 -0
  48. data/nbproject/private/private.xml +4 -0
  49. data/nbproject/private/rake-d.txt +4 -0
  50. data/nbproject/project.properties +11 -0
  51. data/nbproject/project.xml +17 -0
  52. data/test/client_connection_test.rb +25 -25
  53. data/test/logging_test.rb +3 -3
  54. metadata +131 -125
  55. data/bin/data/bindings/hornetq-bindings-1.bindings +0 -0
  56. data/bin/data/bindings/hornetq-bindings-2.bindings +0 -0
  57. data/bin/data/journal/hornetq-data-1.hq +0 -0
  58. data/bin/data/journal/hornetq-data-2.hq +0 -0
  59. data/lib/hornetq/common/log_delegate.rb +0 -48
  60. data/lib/hornetq/common/org_hornetq_core_logging_logger.rb +0 -60
  61. data/lib/hornetq/java/hornetq-core.jar +0 -0
@@ -2,30 +2,30 @@
2
2
  # TODO Support send(:data => string, :durable=>true, :address=>'MyAddress')
3
3
  #
4
4
  # See: http://hornetq.sourceforge.net/docs/hornetq-2.1.2.Final/api/index.html?org/hornetq/api/core/client/ClientProducer.html
5
- #
5
+ #
6
6
  # Other methods still directly accessible through this class:
7
7
  #
8
- # void send(Message message)
8
+ # void send(Message message)
9
9
  # Sends a message to an address
10
- # void send(String address, Message message)
10
+ # void send(String address, Message message)
11
11
  # Sends a message to the specified address instead of the ClientProducer's address
12
- #
13
- # close()
12
+ #
13
+ # close()
14
14
  # Closes the ClientProducer
15
- # boolean closed?
15
+ # boolean closed?
16
16
  # Returns whether the producer is closed or not
17
- #
18
- # SimpleString address()
17
+ #
18
+ # SimpleString address()
19
19
  # Returns the address where messages will be sent
20
- #
21
- # int max_rate()
20
+ #
21
+ # int max_rate()
22
22
  # Returns the maximum rate at which a ClientProducer can send messages per second
23
- #
24
- # boolean block_on_durable_send?
23
+ #
24
+ # boolean block_on_durable_send?
25
25
  # Returns whether the producer will block when sending durable messages
26
- # boolean block_on_non_durable_send?
26
+ # boolean block_on_non_durable_send?
27
27
  # Returns whether the producer will block when sending non-durable messages
28
- #
28
+ #
29
29
  class Java::org.hornetq.core.client.impl::ClientProducerImpl
30
30
  def send_with_retry(message)
31
31
  first_time = true
@@ -1,6 +1,6 @@
1
1
  # Used by HornetQ to move around HashMap messages
2
2
  # Ruby methods added to make it behave like a Ruby Hash
3
- class Java::org.hornetq.utils::TypedProperties
3
+ class Java::org.hornetq.utils::TypedProperties
4
4
  # Get a property
5
5
  def [](key)
6
6
  value = getProperty(key)
@@ -28,7 +28,7 @@ class Java::org.hornetq.utils::TypedProperties
28
28
  putSimpleStringProperty(key,val.to_s)
29
29
  end
30
30
  end
31
-
31
+
32
32
  # Iterate through each key,value pair
33
33
  def each_pair(&proc)
34
34
  it = property_names.iterator
@@ -37,23 +37,23 @@ class Java::org.hornetq.utils::TypedProperties
37
37
  proc.call(key.to_string, self[key])
38
38
  end
39
39
  end
40
-
40
+
41
41
  # Convert Properties to a Ruby Hash
42
42
  def to_h
43
43
  h = {}
44
- each_pair do |key, value|
44
+ each_pair do |key, value|
45
45
  h[key] = value
46
46
  end
47
47
  h
48
48
  end
49
-
49
+
50
50
  # Write Hash values into this TyedProperties instance
51
51
  def from_h(hash)
52
52
  hash.each_pair do |key,value|
53
53
  self[key] = value
54
54
  end
55
55
  end
56
-
56
+
57
57
  def inspect
58
58
  "#{self.class.name}: #{to_h.inspect}"
59
59
  end
@@ -1,6 +1,6 @@
1
1
  module HornetQ::Client
2
2
 
3
- # Implements the Requestor Pattern
3
+ # Implements the Requestor Pattern
4
4
  # Send a request to a server and wait for a reply
5
5
  # Parameters
6
6
  # * session
@@ -10,12 +10,12 @@ module HornetQ::Client
10
10
  # Address to send requests to.
11
11
  # It is expected that process listening to requests at this address has
12
12
  # implemented the ServerPattern
13
- # * reply_address
14
- # If supplied the reply_address must already exist and will be used for
13
+ # * reply_address
14
+ # If supplied the reply_address must already exist and will be used for
15
15
  # receiving responses
16
16
  # If not supplied a temporary queue will be created and used by this instance
17
17
  # of the RequestorPattern
18
- # This optional parameter is normally not used
18
+ # This optional parameter is normally not used
19
19
  # * reply_queue
20
20
  # If a reply_address is supplied, the reply_queue name can be supplied if it
21
21
  # differs from reply_address
@@ -37,26 +37,26 @@ module HornetQ::Client
37
37
  end
38
38
  end
39
39
  end
40
-
40
+
41
41
  # Synchronous Request and wait for reply
42
- #
42
+ #
43
43
  # Returns the message received, or nil if no message was received in the
44
44
  # specified timeout.
45
- #
45
+ #
46
46
  # The supplied request_message is updated as follows
47
47
  # * The property JMSReplyTo is set to the name of the reply to address
48
48
  # * Creates and sets the message user_id if not already set
49
49
  # * #TODO: The expiry is set to the message timeout if not already set
50
- #
51
- # Note:
50
+ #
51
+ # Note:
52
52
  # * The request will only look for a reply message with the same
53
53
  # user_id (message id) as the message that was sent. This is critical
54
54
  # since a previous receive may have timed out and we do not want
55
- # to pickup the reponse to an earlier request
56
- #
55
+ # to pickup the reponse to an earlier request
56
+ #
57
57
  # To receive a message after a timeout, call wait_for_reply with a nil message
58
58
  # id to receive any message on the queue
59
- #
59
+ #
60
60
  # Use: submit_request & then wait_for_reply to break it into
61
61
  # two separate calls
62
62
  def request(request_message, timeout)
@@ -64,19 +64,19 @@ module HornetQ::Client
64
64
  message_id = submit_request(request_message)
65
65
  wait_for_reply(message_id, timeout)
66
66
  end
67
-
67
+
68
68
  # Asynchronous Request
69
69
  # Use: submit_request & then wait_for_reply to break the request into
70
70
  # two separate calls.
71
- #
71
+ #
72
72
  # For example, submit the request now, do some work, then later on
73
73
  # in the same thread wait for the reply.
74
- #
74
+ #
75
75
  # The supplied request_message is updated as follows
76
76
  # * The property JMSReplyTo is set to the name of the reply to address
77
77
  # * Creates and sets the message user_id if not already set
78
78
  # * #TODO: The expiry is set to the message timeout if not already set
79
- #
79
+ #
80
80
  # Returns Message id of the message that was sent
81
81
  def submit_request(request_message)
82
82
  request_message.reply_to_address = @reply_address
@@ -84,16 +84,16 @@ module HornetQ::Client
84
84
  @producer.send(request_message)
85
85
  request_message.user_id
86
86
  end
87
-
87
+
88
88
  # Asynchronous wait for reply
89
- #
89
+ #
90
90
  # Parameters:
91
- # user_id: the user defined id to correlate a response for
92
- #
91
+ # user_id: the user defined id to correlate a response for
92
+ #
93
93
  # Supply a nil user_id to receive any message from the queue
94
- #
94
+ #
95
95
  # Returns the message received
96
- #
96
+ #
97
97
  # Note: Call submit_request before calling this method
98
98
  def wait_for_reply(user_id, timeout)
99
99
  # We only want the reply to the supplied message_id, so set filter on message id
@@ -102,11 +102,11 @@ module HornetQ::Client
102
102
  consumer.receive(timeout)
103
103
  end
104
104
  end
105
-
105
+
106
106
  def close
107
107
  @session.delete_queue(@reply_queue) if @destroy_temp_queue
108
108
  @producer.close if @producer
109
109
  end
110
110
  end
111
-
111
+
112
112
  end
@@ -1,5 +1,5 @@
1
1
  module HornetQ::Client
2
- # Create a Server following the ServerPattern for receiving requests and
2
+ # Create a Server following the ServerPattern for receiving requests and
3
3
  # replying to arbitrary queues
4
4
  # Create an instance of this class per thread
5
5
  class ServerPattern
@@ -9,13 +9,13 @@ module HornetQ::Client
9
9
  @producer = session.create_producer
10
10
  @timeout = timeout
11
11
  end
12
-
12
+
13
13
  def run(&block)
14
14
  while request_message = @consumer.receive(@timeout)
15
15
  # Block should return a message reply object, pass in request
16
16
  # TODO: ensure..
17
17
  reply_message = block.call(request_message)
18
-
18
+
19
19
  # Send a reply?
20
20
  reply(request_message, reply_message) if request_message.request?
21
21
  request_message.acknowledge
@@ -42,7 +42,7 @@ module HornetQ::Client
42
42
  end
43
43
  request_message.acknowledge
44
44
  end
45
-
45
+
46
46
  # Close out resources
47
47
  def close
48
48
  @consumer.close if @consumer
@@ -58,11 +58,11 @@ module HornetQ::Client
58
58
  @pool.with_connection &block
59
59
  end
60
60
 
61
- # Obtain a session from the pool and create a ClientConsumer.
62
- # Pass both into the supplied block.
61
+ # Obtain a session from the pool and create a ClientConsumer.
62
+ # Pass both into the supplied block.
63
63
  # Once the block is complete the consumer is closed and the session is
64
64
  # returned to the pool.
65
- #
65
+ #
66
66
  # See HornetQ::Client::ClientConsumer for more information on the consumer
67
67
  # parameters
68
68
  #
@@ -82,12 +82,12 @@ module HornetQ::Client
82
82
  end
83
83
  end
84
84
  end
85
-
86
- # Obtain a session from the pool and create a ClientProducer.
87
- # Pass both into the supplied block.
85
+
86
+ # Obtain a session from the pool and create a ClientProducer.
87
+ # Pass both into the supplied block.
88
88
  # Once the block is complete the consumer is closed and the session is
89
89
  # returned to the pool.
90
- #
90
+ #
91
91
  # See HornetQ::Client::ClientProducer for more information on the producer
92
92
  # parameters
93
93
  #
@@ -108,12 +108,12 @@ module HornetQ::Client
108
108
  end
109
109
  end
110
110
  end
111
-
111
+
112
112
  # Obtain a session from the pool and create a Client::Requestor.
113
- # Pass both into the supplied block.
113
+ # Pass both into the supplied block.
114
114
  # Once the block is complete the requestor is closed and the session is
115
115
  # returned to the pool.
116
- #
116
+ #
117
117
  # See HornetQ::Client::Requestor for more information on the requestor
118
118
  #
119
119
  # Example
@@ -131,12 +131,12 @@ module HornetQ::Client
131
131
  end
132
132
  end
133
133
  end
134
-
134
+
135
135
  # Obtain a session from the pool and create a Client::Server.
136
- # Pass both into the supplied block.
136
+ # Pass both into the supplied block.
137
137
  # Once the block is complete the requestor is closed and the session is
138
138
  # returned to the pool.
139
- #
139
+ #
140
140
  # See HornetQ::Client::Server for more information on the server
141
141
  #
142
142
  # Example
@@ -154,10 +154,10 @@ module HornetQ::Client
154
154
  end
155
155
  end
156
156
  end
157
-
157
+
158
158
  # Immediately Close all sessions in the pool and release from the pool
159
- #
160
- # TODO: Allow an option to wait for active sessions to be returned before
159
+ #
160
+ # TODO: Allow an option to wait for active sessions to be returned before
161
161
  # closing
162
162
  def close
163
163
  @pool.each do |s|
@@ -166,9 +166,9 @@ module HornetQ::Client
166
166
  #@pool.remove(s)
167
167
  end
168
168
  end
169
-
169
+
170
170
  end
171
-
171
+
172
172
  end
173
173
 
174
174
  end
@@ -2,20 +2,13 @@
2
2
  module HornetQ
3
3
  # Returns the logger being used by both HornetQ and jruby-hornetq
4
4
  def self.logger
5
- @logger ||= (self.rails_logger || self.default_logger)
5
+ @logger ||= (self.rails_logger || self.ruby_logger)
6
6
  end
7
7
 
8
8
  # Replace the logger for both HornetQ and jruby-hornetq
9
9
  # TODO Directly support Log4J as logger since HornetQ has direct support for Log4J
10
10
  def self.logger=(logger)
11
11
  @logger = logger
12
- # Also replace the HornetQ logger
13
- if @logger
14
- Java::org.hornetq.core.logging::Logger.setDelegateFactory(HornetQ::LogDelegateFactory.new)
15
- else
16
- Java::org.hornetq.core.logging::Logger.reset
17
- end
18
- # TODO org.hornetq.core.logging.Logger.setDelegateFactory(org.hornetq.integration.logging.Log4jLogDelegateFactory.new)
19
12
  end
20
13
 
21
14
  # Use the ruby logger, but add needed trace level logging which will result
@@ -36,10 +29,4 @@ module HornetQ
36
29
  (defined?(RAILS_DEFAULT_LOGGER) && RAILS_DEFAULT_LOGGER.respond_to?(:debug) && RAILS_DEFAULT_LOGGER)
37
30
  end
38
31
 
39
- # By default we use the HornetQ Logger
40
- def self.default_logger
41
- # Needs an actual Java class, so give it: org.hornetq.api.core.client::HornetQClient
42
- Java::org.hornetq.core.logging::Logger.getLogger(org.hornetq.api.core.client::HornetQClient)
43
- end
44
-
45
32
  end
Binary file
Binary file
Binary file
@@ -2,8 +2,11 @@ module HornetQ
2
2
  module Server
3
3
  # Only load as needed
4
4
  def self.load_requirements
5
- HornetQ.require_jar 'hornetq-core'
5
+ HornetQ.require_jar 'jnp-client'
6
6
  HornetQ.require_jar 'netty'
7
+ HornetQ.require_jar 'hornetq-commons'
8
+ HornetQ.require_jar 'hornetq-journal'
9
+ HornetQ.require_jar 'hornetq-server'
7
10
  require 'hornetq/server/org_hornetq_core_server_hornet_q_server'
8
11
  end
9
12
 
@@ -0,0 +1,3 @@
1
+ module HornetQ
2
+ VERSION = "0.5.0.alpha"
3
+ end
@@ -0,0 +1,4 @@
1
+ file.reference.jruby-hornetq-bin=/Users/rmorrison/Sandbox/jruby-hornetq/bin
2
+ file.reference.jruby-hornetq-examples=/Users/rmorrison/Sandbox/jruby-hornetq/examples
3
+ file.reference.jruby-hornetq-lib=/Users/rmorrison/Sandbox/jruby-hornetq/lib
4
+ file.reference.jruby-hornetq-test=/Users/rmorrison/Sandbox/jruby-hornetq/test
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project-private xmlns="http://www.netbeans.org/ns/project-private/1">
3
+ <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
4
+ </project-private>
@@ -0,0 +1,4 @@
1
+ clean=Remove any temporary products.
2
+ clobber=Remove any generated file.
3
+ gem=Build gem
4
+ test=Run Test Suite
@@ -0,0 +1,11 @@
1
+ bin.dir=${file.reference.jruby-hornetq-bin}
2
+ examples.dir=${file.reference.jruby-hornetq-examples}
3
+ file.reference.jruby-hornetq-bin=bin
4
+ file.reference.jruby-hornetq-examples=examples
5
+ file.reference.jruby-hornetq-lib=lib
6
+ file.reference.jruby-hornetq-test=test
7
+ main.file=
8
+ platform.active=JRuby
9
+ source.encoding=UTF-8
10
+ src.dir=${file.reference.jruby-hornetq-lib}
11
+ test.src.dir=${file.reference.jruby-hornetq-test}
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project xmlns="http://www.netbeans.org/ns/project/1">
3
+ <type>org.netbeans.modules.ruby.rubyproject</type>
4
+ <configuration>
5
+ <data xmlns="http://www.netbeans.org/ns/ruby-project/1">
6
+ <name>jruby-hornetq</name>
7
+ <source-roots>
8
+ <root id="src.dir"/>
9
+ <root id="examples.dir"/>
10
+ <root id="bin.dir"/>
11
+ </source-roots>
12
+ <test-roots>
13
+ <root id="test.src.dir"/>
14
+ </test-roots>
15
+ </data>
16
+ </configuration>
17
+ </project>