jruby-hornetq 0.3.1 → 0.3.2
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.
- data/README.md +4 -4
- data/Rakefile +1 -1
- data/bin/data/bindings/hornetq-bindings-1.bindings +0 -0
- data/bin/data/bindings/hornetq-bindings-2.bindings +0 -0
- data/bin/data/journal/hornetq-data-1.hq +0 -0
- data/bin/data/journal/hornetq-data-2.hq +0 -0
- data/examples/advanced/batch_client.rb +39 -82
- data/examples/advanced/batch_requestor_pattern.rb +163 -0
- data/examples/advanced/producer.rb +4 -3
- data/examples/producer-consumer/consume_all.rb +6 -3
- data/examples/resque/hornetq_job.rb +1 -1
- data/examples/worker/hornetq.yml +1 -1
- data/lib/hornetq/client/connection.rb +10 -3
- data/lib/hornetq/client/org_hornetq_core_client_impl_client_message_impl.rb +6 -5
- data/lib/hornetq/client/org_hornetq_core_client_impl_client_producer_impl.rb +25 -0
- data/lib/hornetq/client/server_pattern.rb +6 -2
- data/lib/hornetq/client/session_pool.rb +1 -1
- data/lib/hornetq/server.rb +13 -1
- data/lib/hornetq/uri.rb +1 -1
- metadata +8 -3
data/README.md
CHANGED
@@ -116,7 +116,7 @@ Producer: Write messages to a queue:
|
|
116
116
|
require 'rubygems'
|
117
117
|
require 'hornetq'
|
118
118
|
|
119
|
-
HornetQ::Client::Factory.create_session(:
|
119
|
+
HornetQ::Client::Factory.create_session(:connection => {:uri => 'hornetq://localhost'}) do |session|
|
120
120
|
# Create Producer so that we can send messages to the Address 'jms.queue.ExampleQueue'
|
121
121
|
producer = session.create_producer('jms.queue.ExampleQueue')
|
122
122
|
|
@@ -133,7 +133,7 @@ Consumer: Read message from a queue:
|
|
133
133
|
require 'rubygems'
|
134
134
|
require 'hornetq'
|
135
135
|
|
136
|
-
HornetQ::Client::Factory.start(:
|
136
|
+
HornetQ::Client::Factory.start(:connection => {:uri => 'hornetq://localhost'}) do |session|
|
137
137
|
consumer = session.create_consumer('jms.queue.ExampleQueue')
|
138
138
|
|
139
139
|
# Receive a single message, return immediately if no message available
|
@@ -156,7 +156,7 @@ Server: Receive requests and send back a reply
|
|
156
156
|
# Shutdown Server after 5 minutes of inactivity, set to 0 to wait forever
|
157
157
|
timeout = 300000
|
158
158
|
|
159
|
-
HornetQ::Client::Factory.start(:
|
159
|
+
HornetQ::Client::Factory.start(:connection => {:uri => 'hornetq://localhost'}) do |session|
|
160
160
|
server = session.create_server('jms.queue.ExampleQueue', timeout)
|
161
161
|
|
162
162
|
puts "Waiting for Requests..."
|
@@ -184,7 +184,7 @@ Client: Send a request and wait for a reply
|
|
184
184
|
# Wait 5 seconds for a reply
|
185
185
|
timeout = 5000
|
186
186
|
|
187
|
-
HornetQ::Client::Factory.start(:
|
187
|
+
HornetQ::Client::Factory.start(:connection => {:uri => 'hornetq://localhost'}) do |session|
|
188
188
|
requestor = session.create_requestor('jms.queue.ExampleQueue')
|
189
189
|
|
190
190
|
# Create non-durable message
|
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ desc "Build gem"
|
|
9
9
|
task :gem do |t|
|
10
10
|
gemspec = Gem::Specification.new do |s|
|
11
11
|
s.name = 'jruby-hornetq'
|
12
|
-
s.version = '0.3.
|
12
|
+
s.version = '0.3.2'
|
13
13
|
s.authors = ['Reid Morrison', 'Brad Pardee']
|
14
14
|
s.email = ['rubywmq@gmail.com', 'bpardee@gmail.com']
|
15
15
|
s.homepage = 'https://github.com/ClarityServices/jruby-hornetq'
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -10,6 +10,9 @@
|
|
10
10
|
# This sample sends a total of 100 requests in batches of 10.
|
11
11
|
# One thread sends requests and the other processes replies.
|
12
12
|
# Once 80% of the replies are back, it will send the next batch
|
13
|
+
#
|
14
|
+
# Before running this sample, start server.rb first
|
15
|
+
#
|
13
16
|
|
14
17
|
# Allow examples to be run in-place without requiring a gem install
|
15
18
|
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
|
@@ -17,99 +20,53 @@ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
|
|
17
20
|
require 'rubygems'
|
18
21
|
require 'yaml'
|
19
22
|
require 'hornetq'
|
20
|
-
require '
|
23
|
+
require 'batch_requestor_pattern'
|
21
24
|
|
22
|
-
|
23
|
-
|
25
|
+
batch_size = (ARGV[0] || 100).to_i
|
26
|
+
window_size = (ARGV[1] || 10).to_i
|
24
27
|
|
25
|
-
|
26
|
-
config = YAML.load_file(File.dirname(__FILE__) + '/hornetq.yml')['development']
|
28
|
+
server_address = 'ServerAddress'
|
27
29
|
|
28
|
-
|
29
|
-
def initialize(connection, request_address)
|
30
|
-
@session = connection.create_session
|
31
|
-
@producer = @session.create_producer(request_address)
|
32
|
-
@reply_queue = "#{request_address}.#{Java::java.util::UUID.randomUUID.toString}"
|
33
|
-
@session.create_temporary_queue(@reply_queue, @reply_queue)
|
34
|
-
@counter_sync = Sync.new
|
35
|
-
@counter = 0
|
36
|
-
|
37
|
-
# Start consuming replies
|
38
|
-
connection.on_message(:queue_name => @reply_queue) {|message| process_reply(message) }
|
39
|
-
end
|
40
|
-
|
41
|
-
# Increment Message Counter
|
42
|
-
def inc_counter(total_count=1)
|
43
|
-
@counter_sync.synchronize(:EX) { @counter += total_count }
|
44
|
-
end
|
30
|
+
config = YAML.load_file(File.dirname(__FILE__) + '/hornetq.yml')['development']
|
45
31
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
#
|
52
|
-
|
53
|
-
|
54
|
-
end
|
32
|
+
# Create a HornetQ session
|
33
|
+
HornetQ::Client::Connection.connection(config[:connection]) do |connection|
|
34
|
+
window_size = batch_size if window_size > batch_size
|
35
|
+
# * :batch_size Total size of batch
|
36
|
+
# * :window_size Size of the sliding window. This also indicates the maximimum
|
37
|
+
# number of outstanding requests to have open at any time
|
38
|
+
# Default: 0.8
|
39
|
+
# (:max_outstanding_responses)
|
55
40
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
message = @session.create_message(HornetQ::Client::Message::TEXT_TYPE,true)
|
62
|
-
message.reply_to_queue_name = @reply_queue
|
63
|
-
message.body = "Request Current Time. #{i}"
|
64
|
-
@producer.send(message)
|
65
|
-
print "."
|
66
|
-
#puts "Sent:#{message}"
|
67
|
-
end
|
68
|
-
duration = Time.now - start_time
|
69
|
-
#printf "\nSend %5d msg, %5.2f s, %10.2f msg/s\n", total_count, duration, total_count/duration
|
70
|
-
end
|
41
|
+
pattern_config = {
|
42
|
+
:connection => connection,
|
43
|
+
:server_address => server_address,
|
44
|
+
:completion_ratio => 0.8
|
45
|
+
}
|
71
46
|
|
72
|
-
|
73
|
-
|
47
|
+
requestor = BatchRequestorPattern.new(connection, server_address) do |message|
|
48
|
+
# Display an @ symbol for every reply received
|
74
49
|
print '@'
|
75
|
-
inc_counter(1)
|
76
|
-
message.acknowledge
|
77
50
|
end
|
78
51
|
|
79
|
-
|
80
|
-
@producer.close
|
81
|
-
@session.close
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
# Create a HornetQ session
|
86
|
-
HornetQ::Client::Connection.connection(config[:connection]) do |connection|
|
87
|
-
batching_size = total_count if batching_size > total_count
|
88
|
-
|
89
|
-
client = BatchClientPattern.new(connection, request_address)
|
90
|
-
|
91
|
-
times = (total_count/batching_size).to_i
|
52
|
+
times = (batch_size/window_size).to_i
|
92
53
|
puts "Performing #{times} loops"
|
93
|
-
|
54
|
+
|
94
55
|
times.times do |i|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
#puts "\nReceived #{received_count} messages"
|
103
|
-
if received_count >= 0.8 * count
|
104
|
-
puts ""
|
105
|
-
break
|
106
|
-
end
|
56
|
+
|
57
|
+
window_size.times do |i|
|
58
|
+
message = @session.create_message(true)
|
59
|
+
message.type = :text
|
60
|
+
message.body = "Request Current Time. #{i}"
|
61
|
+
requestor.send(message)
|
62
|
+
print "."
|
107
63
|
end
|
64
|
+
|
65
|
+
# Wait for at least 80% of responses before sending more requests
|
66
|
+
requestor.wait_for_outstanding_replies
|
67
|
+
|
108
68
|
end
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
print "*"
|
113
|
-
end
|
114
|
-
client.close
|
69
|
+
puts "Done sending requests, waiting for remaining replies"
|
70
|
+
requestor.wait_for_all_outstanding_replies
|
71
|
+
requestor.close
|
115
72
|
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
#
|
2
|
+
# HornetQ Batch Requestor Pattern:
|
3
|
+
# Submit a batch of requests and wait for replies
|
4
|
+
#
|
5
|
+
# This is an advanced use case where the client submits requests in a controlled
|
6
|
+
# fashion. The alternative would be just to submit all requests at the same time,
|
7
|
+
# however then it becomes extremely difficult to pull back submitted requests
|
8
|
+
# if say 80% of the first say 100 requests fail.
|
9
|
+
#
|
10
|
+
# This sample sends a total of 100 requests in batches of 10.
|
11
|
+
# One thread sends requests and the other processes replies.
|
12
|
+
# Once 80% of the replies are back, it will send the next batch
|
13
|
+
#
|
14
|
+
# Maybe one day this pattern can make it out of examples and into the product :)
|
15
|
+
#
|
16
|
+
require 'sync'
|
17
|
+
|
18
|
+
class BatchRequestorPattern
|
19
|
+
|
20
|
+
attr_accessor :batch_size, :window_size, :completion_ratio
|
21
|
+
attr_reader :reply_address, :reply_count, :send_count
|
22
|
+
|
23
|
+
#
|
24
|
+
# Returns a new BatchRequestorPattern
|
25
|
+
#
|
26
|
+
# Parameters:
|
27
|
+
# * connection: The HornetQ connection. Used for creating sessions for the
|
28
|
+
# pattern to run
|
29
|
+
# * server_address: The address to send requests to
|
30
|
+
# * An optional block can be passed in that will be called with every reply
|
31
|
+
# It can be used to perform specialized handling such as:
|
32
|
+
# ** Aborting a batch process
|
33
|
+
# ** Moving the response to another queue for re-queuing later
|
34
|
+
#
|
35
|
+
# Implementation:
|
36
|
+
#
|
37
|
+
# Creates a temporary reply to queue for receiving responses from the server
|
38
|
+
# Consists of the server_address following by a '.' and a UUID
|
39
|
+
#
|
40
|
+
# Uses Connection#on_message to process replies in a separate thread
|
41
|
+
#
|
42
|
+
# If the connection is started, it will start consuming replies immediately,
|
43
|
+
# otherwise it will only start processing replies once the connection has
|
44
|
+
# been started.
|
45
|
+
#
|
46
|
+
# Sending of messages should be done by only one thread at a time since
|
47
|
+
# this pattern shares the same session and producer for sending messages
|
48
|
+
#
|
49
|
+
# Parameters
|
50
|
+
# * :connection Connection to create session and response queue with
|
51
|
+
# * :server_address Address to send requests to
|
52
|
+
# * :completion_ratio Percentage of responses to wait for before sending
|
53
|
+
# further requests
|
54
|
+
# Must be a number between 0 and 1 inclusive
|
55
|
+
# Default: 0.8
|
56
|
+
#
|
57
|
+
def initialize(params, &reply_block)
|
58
|
+
params = params.dup
|
59
|
+
connection = params.delete(:connection)
|
60
|
+
server_address = params.delete(:server_address)
|
61
|
+
@completion_ratio = params.delete(:completion_ratio).to_f
|
62
|
+
|
63
|
+
raise "Invalid :completion_ratio of #{@completion_ratio}. Must be between 0 and 1 inclusive" unless @completion_ratio.between?(0,1)
|
64
|
+
|
65
|
+
@session = connection.create_session
|
66
|
+
@producer = @session.create_producer(server_address)
|
67
|
+
@reply_address = "#{server_address}.#{Java::java.util::UUID.randomUUID.toString}"
|
68
|
+
@session.create_temporary_queue(@reply_address, @reply_address)
|
69
|
+
@reply_count_sync = Sync.new
|
70
|
+
@reply_count = 0
|
71
|
+
@send_count = 0
|
72
|
+
@reply_block = reply_block
|
73
|
+
|
74
|
+
# Start consuming replies. The Address and Queue names are the same
|
75
|
+
connection.on_message(:queue_name => @reply_address) {|message| process_reply(message) }
|
76
|
+
end
|
77
|
+
|
78
|
+
# Return the current message count
|
79
|
+
def reply_count
|
80
|
+
@reply_count_sync.synchronize(:SH) { @reply_count }
|
81
|
+
end
|
82
|
+
|
83
|
+
# Send a message to the server, setting the reply to address to the temporary
|
84
|
+
# address created by this pattern
|
85
|
+
#
|
86
|
+
# Sending of messages should be done by only one thread at a time since
|
87
|
+
# this pattern shares the same session and producer for sending messages
|
88
|
+
#
|
89
|
+
# Returns the total number of messages sent so far in this batch
|
90
|
+
def send(message)
|
91
|
+
message.reply_to_address = @reply_address
|
92
|
+
@producer.send(message)
|
93
|
+
@send_count += 1
|
94
|
+
end
|
95
|
+
|
96
|
+
# Retry Sending a message to the server, setting the reply to address to the
|
97
|
+
# temporary address created by this pattern
|
98
|
+
#
|
99
|
+
# Only call this method when a reply is received and we want to resend a
|
100
|
+
# previous request
|
101
|
+
#
|
102
|
+
# Note: This method will decrement the number of messages received by 1
|
103
|
+
# and will Not increment the number of messages sent, since it is
|
104
|
+
# considered to have already been sent
|
105
|
+
#
|
106
|
+
# ReSending and Sending of messages should be done by only one thread at a time since
|
107
|
+
# this pattern shares the same session and producer for sending messages
|
108
|
+
# #TODO Should we rather just add a Sync around the producer?
|
109
|
+
# What if a resend is being done in the reply handler?
|
110
|
+
#
|
111
|
+
# Returns the total number of messages sent so far in this batch
|
112
|
+
def resend(message)
|
113
|
+
message.reply_to_address = @reply_address
|
114
|
+
|
115
|
+
# Decrement Reply Message counter
|
116
|
+
@reply_count_sync.synchronize(:EX) { @reply_count -= 1 }
|
117
|
+
@producer.send(message)
|
118
|
+
end
|
119
|
+
|
120
|
+
# Receive Reply messages, calling the supplied reply handler block to support
|
121
|
+
# custom error handling
|
122
|
+
#
|
123
|
+
# Returns result of reply block supplied to constructor
|
124
|
+
def process_reply(message)
|
125
|
+
# Increment reply message counter
|
126
|
+
@reply_count_sync.synchronize(:EX) { @reply_count += 1 }
|
127
|
+
|
128
|
+
result = @reply_block.call(message) if @reply_block
|
129
|
+
message.acknowledge
|
130
|
+
result
|
131
|
+
end
|
132
|
+
|
133
|
+
# Release resources used by this pattern
|
134
|
+
def close
|
135
|
+
@producer.close
|
136
|
+
@session.close
|
137
|
+
end
|
138
|
+
|
139
|
+
# Wait for replies from server until the required number of responses has been
|
140
|
+
# received based on the completion ratio
|
141
|
+
#
|
142
|
+
# For example a completion ration of 0.8 will wait for at least 80% of replies
|
143
|
+
# to be received. So if 10 requests were sent this method would only return
|
144
|
+
# once 8 or more replies have been received
|
145
|
+
#
|
146
|
+
# #TODO Need a Timeout here
|
147
|
+
def wait_for_outstanding_replies
|
148
|
+
while self.reply_count >= self.completion_ratio * self.send_count
|
149
|
+
sleep 0.1
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
# Wait for replies from server until the required number of responses has been
|
154
|
+
# received based on the completion ratio
|
155
|
+
#
|
156
|
+
# #TODO Need a Timeout here
|
157
|
+
def wait_for_all_outstanding_replies
|
158
|
+
while self.reply_count >= self.send_count
|
159
|
+
sleep 0.1
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
@@ -18,14 +18,15 @@ config = YAML.load_file(File.dirname(__FILE__) + '/hornetq.yml')['development']
|
|
18
18
|
# Create a HornetQ session
|
19
19
|
HornetQ::Client::Connection.session(config) do |session|
|
20
20
|
# Create a non-durable TestQueue to receive messages sent to the TestAddress
|
21
|
-
session.create_queue_ignore_exists('
|
21
|
+
session.create_queue_ignore_exists('jms.queue.SampleQueue', 'jms.queue.SampleQueue', false)
|
22
22
|
start_time = Time.now
|
23
23
|
|
24
|
-
session.producer('
|
24
|
+
session.producer('jms.queue.SampleQueue') do |producer|
|
25
25
|
puts "Sending messages"
|
26
26
|
(1..count).each do |i|
|
27
27
|
message = session.create_message(HornetQ::Client::Message::TEXT_TYPE,false)
|
28
|
-
message.body = "#{Time.now}: ### Hello, World ###"
|
28
|
+
message.body = "#{Time.now}: #{i} : ### Hello, World ###"
|
29
|
+
message.user_id = Java::org.hornetq.utils::UUIDGenerator.getInstance.generateUUID
|
29
30
|
|
30
31
|
producer.send(message)
|
31
32
|
puts "#{i}\n" if i%1000 == 0
|
@@ -10,13 +10,16 @@ require 'rubygems'
|
|
10
10
|
require 'hornetq'
|
11
11
|
|
12
12
|
# Using Connect.start since a session must be started in order to consume messages
|
13
|
-
HornetQ::Client::Connection.start_session(
|
13
|
+
HornetQ::Client::Connection.start_session(
|
14
|
+
:connection => {:uri => 'hornetq://stage1'} ,
|
15
|
+
:session => { :username => 'clarity', :password => 'clarityrul3s'}) do |session|
|
14
16
|
|
15
17
|
# Create a non-durable TestQueue to receive messages sent to the TestAddress
|
16
|
-
session.create_queue_ignore_exists('
|
18
|
+
session.create_queue_ignore_exists('jms.queue.SampleQueue', 'jms.queue.SampleQueue', false)
|
17
19
|
|
18
20
|
# Consume All messages from the queue and gather statistics
|
19
|
-
stats = session.consume(:queue_name => '
|
21
|
+
stats = session.consume(:queue_name => 'jms.queue.SampleQueue', :timeout=> 0, :statistics=>true) do |message|
|
22
|
+
puts "Body Size:#{message.body_size}"
|
20
23
|
p message
|
21
24
|
puts "=================================="
|
22
25
|
message.acknowledge
|
@@ -77,7 +77,7 @@ class BatchClientPattern
|
|
77
77
|
start_time = Time.now
|
78
78
|
total_count.times do |i|
|
79
79
|
message = @session.create_message(HornetQ::Client::Message::TEXT_TYPE,false)
|
80
|
-
message.
|
80
|
+
message.reply_to_address = @consumer.queue_name
|
81
81
|
message.body = "Request Current Time. #{i}"
|
82
82
|
@producer.send(message)
|
83
83
|
print "."
|
data/examples/worker/hornetq.yml
CHANGED
@@ -174,7 +174,8 @@ module HornetQ
|
|
174
174
|
@sessions = []
|
175
175
|
@consumers = []
|
176
176
|
# In-VM Transport has no fail-over or additional parameters
|
177
|
-
|
177
|
+
@is_invm = uri.host == 'invm'
|
178
|
+
if @is_invm
|
178
179
|
transport = Java::org.hornetq.api.core.TransportConfiguration.new(HornetQ::INVM_CONNECTOR_CLASS_NAME)
|
179
180
|
@connection = Java::org.hornetq.api.core.client.HornetQClient.create_client_session_factory(transport)
|
180
181
|
elsif params[:protocol]
|
@@ -212,6 +213,11 @@ module HornetQ
|
|
212
213
|
end
|
213
214
|
end
|
214
215
|
|
216
|
+
# Return true if this connection was configured in INVM transport protocol
|
217
|
+
def invm?
|
218
|
+
@is_invm
|
219
|
+
end
|
220
|
+
|
215
221
|
# Create a new HornetQ session
|
216
222
|
#
|
217
223
|
# Note: Remember to close the session once it is no longer used.
|
@@ -316,6 +322,7 @@ module HornetQ
|
|
316
322
|
#
|
317
323
|
def create_session(params={})
|
318
324
|
raise "HornetQ::Client::Connection Already Closed" unless @connection
|
325
|
+
params ||= {}
|
319
326
|
session = @connection.create_session(
|
320
327
|
params[:username],
|
321
328
|
params[:password],
|
@@ -487,11 +494,11 @@ module HornetQ
|
|
487
494
|
# Start all sessions managed by this connection
|
488
495
|
#
|
489
496
|
# Sessions created via #create_session are not managed unless
|
490
|
-
# :
|
497
|
+
# :managed => true was specified when the session was created
|
491
498
|
#
|
492
499
|
# Session are Only managed when created through the following methods:
|
493
500
|
# Connection#on_message
|
494
|
-
# Connection#create_session And :
|
501
|
+
# Connection#create_session And :managed => true
|
495
502
|
#
|
496
503
|
# This call does not do anything to sessions in a session pool
|
497
504
|
def start_managed_sessions
|
@@ -123,18 +123,19 @@ class Java::OrgHornetqCoreClientImpl::ClientMessageImpl
|
|
123
123
|
contains_property(Java::OrgHornetqCoreClientImpl::ClientMessageImpl::REPLYTO_HEADER_NAME)
|
124
124
|
end
|
125
125
|
|
126
|
-
# Return the Reply To
|
127
|
-
def
|
126
|
+
# Return the Reply To Address as a string
|
127
|
+
def reply_to_address
|
128
128
|
get_string_property(Java::OrgHornetqCoreClientImpl::ClientMessageImpl::REPLYTO_HEADER_NAME)
|
129
129
|
end
|
130
130
|
|
131
|
-
# Set the Reply To
|
131
|
+
# Set the Reply To Address
|
132
132
|
# When supplied, the consumer of the message is expected to send a response to the
|
133
|
-
# specified
|
133
|
+
# specified address. However, this is by convention, so no response is guaranteed
|
134
|
+
#
|
134
135
|
# Note: Rather than set this directly, consider creating a Client::Requestor:
|
135
136
|
# requestor = session.create_requestor('Request Queue')
|
136
137
|
#
|
137
|
-
def
|
138
|
+
def reply_to_address=(name)
|
138
139
|
val = nil
|
139
140
|
if name.is_a? Java::org.hornetq.api.core::SimpleString
|
140
141
|
val = name
|
@@ -1,5 +1,30 @@
|
|
1
1
|
# TODO Support send(String)
|
2
2
|
# TODO Support send(:data => string, :durable=>true, :address=>'MyAddress')
|
3
3
|
#
|
4
|
+
# See: http://hornetq.sourceforge.net/docs/hornetq-2.1.2.Final/api/index.html?org/hornetq/api/core/client/ClientProducer.html
|
5
|
+
#
|
6
|
+
# Other methods still directly accessible through this class:
|
7
|
+
#
|
8
|
+
# void send(Message message)
|
9
|
+
# Sends a message to an address
|
10
|
+
# void send(String address, Message message)
|
11
|
+
# Sends a message to the specified address instead of the ClientProducer's address
|
12
|
+
#
|
13
|
+
# close()
|
14
|
+
# Closes the ClientProducer
|
15
|
+
# boolean closed?
|
16
|
+
# Returns whether the producer is closed or not
|
17
|
+
#
|
18
|
+
# SimpleString address()
|
19
|
+
# Returns the address where messages will be sent
|
20
|
+
#
|
21
|
+
# int max_rate()
|
22
|
+
# Returns the maximum rate at which a ClientProducer can send messages per second
|
23
|
+
#
|
24
|
+
# boolean block_on_durable_send?
|
25
|
+
# Returns whether the producer will block when sending durable messages
|
26
|
+
# boolean block_on_non_durable_send?
|
27
|
+
# Returns whether the producer will block when sending non-durable messages
|
28
|
+
#
|
4
29
|
class Java::org.hornetq.core.client.impl::ClientProducerImpl
|
5
30
|
end
|
@@ -25,14 +25,18 @@ module HornetQ::Client
|
|
25
25
|
# Send a reply to the received request message
|
26
26
|
# request: is the message received
|
27
27
|
# reply: is the message to send to the client
|
28
|
+
#
|
29
|
+
# Note: A reply is only sent if it is a request message. This means that
|
30
|
+
# the message must have a property named Java::OrgHornetqCoreClientImpl::ClientMessageImpl::REPLYTO_HEADER_NAME
|
31
|
+
# containing the name of the address to which the response should be sent
|
28
32
|
def reply(request_message, reply_message)
|
29
33
|
if request_message.request?
|
30
34
|
# Reply should have same durability as request
|
31
35
|
reply_message.durable = request_message.durable?
|
32
|
-
reply_to = request_message.getSimpleStringProperty(Java::OrgHornetqCoreClientImpl::ClientMessageImpl::REPLYTO_HEADER_NAME);
|
33
36
|
# Send request message id back in reply message for correlation purposes
|
34
37
|
reply_message.user_id = request_message.user_id
|
35
|
-
|
38
|
+
# Send to Reply to address supplied by the caller
|
39
|
+
@producer.send(request_message.reply_to_address, reply_message)
|
36
40
|
#puts "Sent reply to #{reply_to.to_s}: #{reply_message.inspect}"
|
37
41
|
end
|
38
42
|
request_message.acknowledge
|
data/lib/hornetq/server.rb
CHANGED
@@ -41,12 +41,24 @@ module HornetQ
|
|
41
41
|
acceptor_conf_set.add(acceptor)
|
42
42
|
config.acceptor_configurations = acceptor_conf_set
|
43
43
|
|
44
|
+
more_acceptors = params.delete(:acceptor)
|
45
|
+
if more_acceptors
|
46
|
+
more_acceptors = [more_acceptors] unless more_acceptors.kind_of?(Array)
|
47
|
+
more_acceptors.each do |uri_str|
|
48
|
+
uri = HornetQ::URI.new(uri_str)
|
49
|
+
p = uri.params.merge('host' => uri.host, 'port' => uri.port)
|
50
|
+
puts p.inspect
|
51
|
+
accept = Java::org.hornetq.api.core.TransportConfiguration.new(HornetQ::NETTY_ACCEPTOR_CLASS_NAME, p)
|
52
|
+
acceptor_conf_set.add(accept)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
44
56
|
if Java::org.hornetq.core.journal.impl.AIOSequentialFileFactory.isSupported
|
45
57
|
config.journal_type = Java::org.hornetq.core.server.JournalType::ASYNCIO
|
46
58
|
else
|
47
59
|
require 'rbconfig'
|
48
60
|
if Config::CONFIG['target_os'] == 'linux'
|
49
|
-
HornetQ.logger.info("AIO wasn't located on this platform, it will fall back to using pure Java NIO. Install
|
61
|
+
HornetQ.logger.info("AIO wasn't located on this platform, it will fall back to using pure Java NIO. Install libaio and libHornetQAIO to enable the AIO journal")
|
50
62
|
end
|
51
63
|
config.journal_type = Java::org.hornetq.core.server.JournalType::NIO
|
52
64
|
end
|
data/lib/hornetq/uri.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 2
|
9
|
+
version: 0.3.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Reid Morrison
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-03-09 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -48,8 +48,13 @@ files:
|
|
48
48
|
- Rakefile
|
49
49
|
- README.md
|
50
50
|
- bin/hornetq_server
|
51
|
+
- bin/data/bindings/hornetq-bindings-1.bindings
|
52
|
+
- bin/data/bindings/hornetq-bindings-2.bindings
|
53
|
+
- bin/data/journal/hornetq-data-1.hq
|
54
|
+
- bin/data/journal/hornetq-data-2.hq
|
51
55
|
- examples/README
|
52
56
|
- examples/advanced/batch_client.rb
|
57
|
+
- examples/advanced/batch_requestor_pattern.rb
|
53
58
|
- examples/advanced/bytes_producer.rb
|
54
59
|
- examples/advanced/client.rb
|
55
60
|
- examples/advanced/client_session_pooling.rb
|