jruby-hornetq 0.2.0.alpha → 0.2.1.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.
- data/HISTORY.md +8 -0
- data/README.md +88 -5
- data/Rakefile +4 -4
- data/bin/hornetq_server +26 -55
- data/examples/{batch_client.rb → client/advanced/batch_client.rb} +11 -4
- data/examples/{client.rb → client/advanced/client.rb} +8 -10
- data/examples/{consumer.rb → client/advanced/consumer.rb} +2 -2
- data/examples/{hornetq.yml → client/advanced/hornetq.yml} +11 -10
- data/examples/{multi_client.rb → client/advanced/multi_client.rb} +6 -3
- data/examples/{multi_consumer.rb → client/advanced/multi_consumer.rb} +2 -2
- data/examples/{producer.rb → client/advanced/producer.rb} +3 -4
- data/examples/{server.rb → client/advanced/server.rb} +6 -9
- data/examples/client/client.rb +31 -0
- data/examples/client/consumer.rb +22 -0
- data/examples/client/invm.rb +38 -0
- data/examples/client/producer.rb +21 -0
- data/examples/client/server.rb +31 -0
- data/examples/server/backup_server.yml +6 -0
- data/examples/server/live_server.yml +1 -0
- data/examples/server/standalone_server.yml +1 -0
- data/lib/data/bindings/hornetq-bindings-1.bindings +0 -0
- data/lib/data/bindings/hornetq-bindings-2.bindings +0 -0
- data/lib/hornetq.rb +30 -9
- data/lib/hornetq/client.rb +19 -0
- data/lib/hornetq/{hornet_q_client.rb → client/factory.rb} +85 -88
- data/lib/hornetq/{org_hornetq_api_core_client_client_session.rb → client/org_hornetq_api_core_client_client_session.rb} +2 -2
- data/lib/hornetq/{org_hornetq_core_client_impl_client_message_impl.rb → client/org_hornetq_core_client_impl_client_message_impl.rb} +62 -2
- data/lib/hornetq/{org_hornetq_core_client_impl_client_producer_impl.rb → client/org_hornetq_core_client_impl_client_producer_impl.rb} +0 -0
- data/lib/hornetq/{org_hornetq_utils_typed_properties.rb → client/org_hornetq_utils_typed_properties.rb} +0 -0
- data/lib/hornetq/{client_requestor.rb → client/requestor.rb} +2 -2
- data/lib/hornetq/{client_server.rb → client/server.rb} +2 -2
- data/lib/hornetq/{session_pool.rb → client/session_pool.rb} +20 -20
- data/lib/hornetq/{lib → java}/hornetq-core-client.jar +0 -0
- data/lib/hornetq/{lib → java}/hornetq-core.jar +0 -0
- data/lib/hornetq/{lib → java}/netty.jar +0 -0
- data/lib/hornetq/org_hornetq_core_server_hornet_q_server.rb +13 -0
- data/lib/hornetq/server.rb +12 -0
- data/lib/hornetq/server/factory.rb +86 -0
- data/lib/hornetq/uri.rb +59 -0
- data/test/server_factory_test.rb +184 -0
- data/test/uri_test.rb +74 -0
- metadata +44 -28
- data/examples/backup_server.yml +0 -4
- data/examples/live_server.yml +0 -5
- data/examples/run_broker.rb +0 -59
- data/examples/standalone_server.yml +0 -3
data/HISTORY.md
CHANGED
data/README.md
CHANGED
@@ -111,14 +111,96 @@ Producer-Consumer
|
|
111
111
|
|
112
112
|
Producer: Write messages to a queue:
|
113
113
|
|
114
|
-
|
114
|
+
require 'rubygems'
|
115
|
+
require 'hornetq'
|
116
|
+
|
117
|
+
HornetQ::Client::Factory.create_session(:connector=> {:uri => 'hornetq://localhost'}) do |session|
|
118
|
+
# Create Producer so that we can send messages to the Address 'jms.queue.ExampleQueue'
|
119
|
+
producer = session.create_producer('jms.queue.ExampleQueue')
|
120
|
+
|
121
|
+
# Create a non-durable message to send
|
122
|
+
message = session.create_message(HornetQ::Client::Message::TEXT_TYPE,false)
|
123
|
+
message << "#{Time.now}: ### Hello, World ###"
|
124
|
+
|
125
|
+
producer.send(message)
|
126
|
+
end
|
127
|
+
|
115
128
|
|
116
129
|
Consumer: Read message from a queue:
|
117
|
-
|
130
|
+
|
131
|
+
require 'rubygems'
|
132
|
+
require 'hornetq'
|
133
|
+
|
134
|
+
HornetQ::Client::Factory.start(:connector=> {:uri => 'hornetq://localhost'}) do |session|
|
135
|
+
consumer = session.create_consumer('jms.queue.ExampleQueue')
|
136
|
+
|
137
|
+
# Receive a single message, return immediately if no message available
|
138
|
+
if message = consumer.receive_immediate
|
139
|
+
puts "Received:[#{message.body}]"
|
140
|
+
message.acknowledge
|
141
|
+
else
|
142
|
+
puts "No message found"
|
143
|
+
end
|
144
|
+
end
|
118
145
|
|
119
146
|
Client-Server
|
120
147
|
-------------
|
121
148
|
|
149
|
+
Server: Receive requests and send back a reply
|
150
|
+
|
151
|
+
require 'rubygems'
|
152
|
+
require 'hornetq'
|
153
|
+
|
154
|
+
# Shutdown Server after 5 minutes of inactivity, set to 0 to wait forever
|
155
|
+
timeout = 300000
|
156
|
+
|
157
|
+
HornetQ::Client::Factory.start(:connector=> {:uri => 'hornetq://localhost'}) do |session|
|
158
|
+
server = session.create_server('jms.queue.ExampleQueue', timeout)
|
159
|
+
|
160
|
+
puts "Waiting for Requests..."
|
161
|
+
server.run do |request_message|
|
162
|
+
puts "Received:[#{request_message.body}]"
|
163
|
+
|
164
|
+
# Create Reply Message
|
165
|
+
reply_message = session.create_message(HornetQ::Client::Message::TEXT_TYPE, false)
|
166
|
+
reply_message.body = "Echo [#{request_message.body}]"
|
167
|
+
|
168
|
+
# The result of the block is the message to be sent back to the client
|
169
|
+
reply_message
|
170
|
+
end
|
171
|
+
|
172
|
+
# Server will stop after timeout period after no messages received
|
173
|
+
server.close
|
174
|
+
end
|
175
|
+
|
176
|
+
|
177
|
+
Client: Send a request and wait for a reply
|
178
|
+
|
179
|
+
require 'rubygems'
|
180
|
+
require 'hornetq'
|
181
|
+
|
182
|
+
# Wait 5 seconds for a reply
|
183
|
+
timeout = 5000
|
184
|
+
|
185
|
+
HornetQ::Client::Factory.start(:connector=> {:uri => 'hornetq://localhost'}) do |session|
|
186
|
+
requestor = session.create_requestor('jms.queue.ExampleQueue')
|
187
|
+
|
188
|
+
# Create non-durable message
|
189
|
+
message = session.create_message(HornetQ::Client::Message::TEXT_TYPE,false)
|
190
|
+
message.body = "Request Current Time"
|
191
|
+
|
192
|
+
# Send message to the queue
|
193
|
+
puts "Send request message and wait for Reply"
|
194
|
+
if reply = requestor.request(message, timeout)
|
195
|
+
puts "Received Response: #{reply.inspect}"
|
196
|
+
puts " Message: #{reply.body.inspect}"
|
197
|
+
else
|
198
|
+
puts "Time out, No reply received after #{timeout/1000} seconds"
|
199
|
+
end
|
200
|
+
|
201
|
+
requestor.close
|
202
|
+
end
|
203
|
+
|
122
204
|
|
123
205
|
Threading
|
124
206
|
---------
|
@@ -164,12 +246,12 @@ client, it also supports using JRuby to launch a Broker instance
|
|
164
246
|
|
165
247
|
#### Starting up a standalone hornetq server:
|
166
248
|
|
167
|
-
bin/hornetq_server examples/standalone_server.yml
|
249
|
+
bin/hornetq_server examples/server/standalone_server.yml
|
168
250
|
|
169
251
|
#### Starting up a backup/live combination
|
170
252
|
|
171
|
-
bin/hornetq_server examples/backup_server.yml
|
172
|
-
bin/hornetq_server examples/live_server.yml
|
253
|
+
bin/hornetq_server examples/server/backup_server.yml
|
254
|
+
bin/hornetq_server examples/server/live_server.yml
|
173
255
|
|
174
256
|
Development
|
175
257
|
-----------
|
@@ -222,6 +304,7 @@ Authors
|
|
222
304
|
-------
|
223
305
|
|
224
306
|
Reid Morrison :: rubywmq@gmail.com :: @reidmorrison
|
307
|
+
|
225
308
|
Brad Pardee :: bpardee@gmail.com
|
226
309
|
|
227
310
|
[1]: http://help.github.com/forking/
|
data/Rakefile
CHANGED
@@ -8,10 +8,10 @@ desc "Build gem"
|
|
8
8
|
task :gem do |t|
|
9
9
|
gemspec = Gem::Specification.new do |s|
|
10
10
|
s.name = 'jruby-hornetq'
|
11
|
-
s.version = '0.2.
|
12
|
-
s.
|
13
|
-
s.email = 'rubywmq@gmail.com'
|
14
|
-
s.homepage = '
|
11
|
+
s.version = '0.2.1.alpha'
|
12
|
+
s.authors = ['Reid Morrison', 'Brad Pardee']
|
13
|
+
s.email = ['rubywmq@gmail.com', 'bpardee@gmail.com']
|
14
|
+
s.homepage = 'https://github.com/ClarityServices/jruby-hornetq'
|
15
15
|
s.date = Date.today.to_s
|
16
16
|
s.description = 'JRuby-HornetQ is a Java and Ruby library that exposes the HornetQ Java API in a ruby friendly way. For JRuby only.'
|
17
17
|
s.summary = 'JRuby interface into HornetQ'
|
data/bin/hornetq_server
CHANGED
@@ -1,70 +1,41 @@
|
|
1
1
|
#!/usr/bin/env jruby
|
2
2
|
|
3
|
+
require 'rubygems'
|
3
4
|
require 'yaml'
|
4
|
-
|
5
|
-
raise 'Environment variable HORNETQ_HOME not set' unless ENV['HORNETQ_HOME']
|
6
|
-
require "#{ENV['HORNETQ_HOME']}/lib/hornetq-core.jar"
|
7
|
-
require "#{ENV['HORNETQ_HOME']}/lib/netty.jar"
|
5
|
+
require 'hornetq'
|
8
6
|
|
9
7
|
unless ARGV[0]
|
10
|
-
$stderr.puts
|
11
|
-
exit 1
|
12
|
-
end
|
13
|
-
yaml = YAML.load_file(ARGV[0])
|
14
|
-
data_directory = yaml['data_directory'] || './data'
|
15
|
-
host = yaml['host'] || 'localhost'
|
16
|
-
port = yaml['port'] || 5445
|
8
|
+
$stderr.puts <<EOF
|
17
9
|
|
18
|
-
|
19
|
-
config.persistence_enabled = false
|
20
|
-
config.security_enabled = false
|
21
|
-
config.paging_directory = "#{data_directory}/paging"
|
22
|
-
config.bindings_directory = "#{data_directory}/bindings"
|
23
|
-
config.journal_directory = "#{data_directory}/journal"
|
24
|
-
config.journal_min_files = 10
|
25
|
-
config.large_messages_directory = "#{data_directory}/large-messages"
|
10
|
+
Usage: hornetq_server <uri-or-yml-file>
|
26
11
|
|
27
|
-
|
28
|
-
config.journal_type = Java::org.hornetq.core.server.JournalType::ASYNCIO
|
29
|
-
else
|
30
|
-
puts("AIO wasn't located on this platform, it will fall back to using pure Java NIO. If your platform is Linux, install LibAIO to enable the AIO journal");
|
31
|
-
config.journal_type = Java::org.hornetq.core.server.JournalType::NIO
|
32
|
-
end
|
12
|
+
Examples:
|
33
13
|
|
34
|
-
|
35
|
-
|
14
|
+
# start standalone server on port #{HornetQ::DEFAULT_NETTY_PORT}
|
15
|
+
hornetq_server hornetq://0.0.0.0/?data_directory=./data
|
36
16
|
|
37
|
-
|
38
|
-
|
39
|
-
transport_conf_params.put('port', java.lang.Integer.new(port))
|
40
|
-
transport_conf = Java::org.hornetq.api.core.TransportConfiguration.new(netty_acceptor_class_name, transport_conf_params);
|
17
|
+
# start backup server
|
18
|
+
hornetq_server hornetq://0.0.0.0:5446/?backup=true\\&data_directory=./data_backup
|
41
19
|
|
42
|
-
|
43
|
-
|
20
|
+
# start live server attached to backup on same server
|
21
|
+
hornetq_server hornetq://0.0.0.0:5445,localhost:5446/?data_directory=./data
|
44
22
|
|
45
|
-
|
23
|
+
EOF
|
24
|
+
exit 1
|
25
|
+
end
|
46
26
|
|
47
|
-
if yaml
|
48
|
-
|
49
|
-
config
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
backup_params.put('port', java.lang.Integer.new(backup_port))
|
57
|
-
#backup_params.put('reconnectAttempts', -1)
|
58
|
-
backup_connector_conf = Java::org.hornetq.api.core.TransportConfiguration.new(netty_connector_class_name, backup_params);
|
59
|
-
|
60
|
-
connector_conf_map = java.util.HashMap.new
|
61
|
-
connector_conf_map.put('backup-connector', backup_connector_conf)
|
62
|
-
|
63
|
-
config.connector_configurations = connector_conf_map
|
64
|
-
config.backup_connector_name = 'backup-connector'
|
27
|
+
# Check if the argument is a yaml file or a uri
|
28
|
+
if ARGV[0] =~ /\.ya?ml$/
|
29
|
+
config = YAML.load_file(ARGV[0])
|
30
|
+
# Allow sub items
|
31
|
+
(1...ARGV.size).each do |i|
|
32
|
+
config = config[ARGV[i]] || config[ARGV[i].to_sym]
|
33
|
+
end
|
34
|
+
puts "config=#{config.inspect}"
|
35
|
+
server = HornetQ::Server::Factory.create_server(config)
|
65
36
|
else
|
66
|
-
|
37
|
+
uri = ARGV[0]
|
38
|
+
server = HornetQ::Server::Factory.create_server(uri)
|
67
39
|
end
|
68
|
-
|
69
|
-
server = Java::org.hornetq.core.server.HornetQServers.newHornetQServer(config)
|
40
|
+
server.enable_shutdown_on_signal
|
70
41
|
server.start
|
@@ -2,9 +2,17 @@
|
|
2
2
|
# HornetQ Batch Requestor:
|
3
3
|
# Submit a batch of requests and wait for replies
|
4
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
|
5
13
|
|
6
14
|
# Allow examples to be run in-place without requiring a gem install
|
7
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '
|
15
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../../lib'
|
8
16
|
|
9
17
|
require 'rubygems'
|
10
18
|
require 'yaml'
|
@@ -13,7 +21,6 @@ require 'sync'
|
|
13
21
|
|
14
22
|
total_count = (ARGV[0] || 100).to_i
|
15
23
|
batching_size = (ARGV[1] || 10).to_i
|
16
|
-
timeout = (ARGV[2] || 10000).to_i
|
17
24
|
request_address = 'jms.queue.ExampleQueue'
|
18
25
|
|
19
26
|
config = YAML.load_file(File.dirname(__FILE__) + '/hornetq.yml')['development']
|
@@ -55,7 +62,7 @@ class BatchClient
|
|
55
62
|
#print "Sending #{total_count} messages"
|
56
63
|
start_time = Time.now
|
57
64
|
total_count.times do |i|
|
58
|
-
message = @session.create_message(
|
65
|
+
message = @session.create_message(HornetQ::Client::Message::TEXT_TYPE,false)
|
59
66
|
message.reply_to_queue_name = @consumer.queue_name
|
60
67
|
message << "Request Current Time. #{i}"
|
61
68
|
@producer.send(message)
|
@@ -89,7 +96,7 @@ class BatchClient
|
|
89
96
|
end
|
90
97
|
|
91
98
|
# Create a HornetQ session
|
92
|
-
|
99
|
+
HornetQ::Client::Factory.create_session(config) do |session|
|
93
100
|
batching_size = total_count if batching_size > total_count
|
94
101
|
|
95
102
|
client = BatchClient.new(session, request_address)
|
@@ -4,7 +4,7 @@
|
|
4
4
|
#
|
5
5
|
|
6
6
|
# Allow examples to be run in-place without requiring a gem install
|
7
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '
|
7
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../../lib'
|
8
8
|
|
9
9
|
require 'rubygems'
|
10
10
|
require 'yaml'
|
@@ -16,29 +16,27 @@ timeout = (ARGV[1] || 30000).to_i
|
|
16
16
|
config = YAML.load_file(File.dirname(__FILE__) + '/hornetq.yml')['development']
|
17
17
|
|
18
18
|
# Create a HornetQ session
|
19
|
-
|
19
|
+
HornetQ::Client::Factory.create_session(config) do |session|
|
20
20
|
#session.create_queue('Example', 'Example', true)
|
21
21
|
requestor = session.create_requestor('jms.queue.ExampleQueue')
|
22
22
|
session.start
|
23
23
|
start_time = Time.now
|
24
24
|
|
25
25
|
puts "Sending messages"
|
26
|
-
count.
|
27
|
-
message = session.create_message(
|
26
|
+
(1..count).each do |i|
|
27
|
+
message = session.create_message(HornetQ::Client::Message::TEXT_TYPE,false)
|
28
28
|
# Set the message body text
|
29
29
|
message << "Request Current Time"
|
30
30
|
# Set the user managed message id
|
31
31
|
message.user_id = Java::org.hornetq.utils::UUIDGenerator.getInstance.generateUUID
|
32
|
-
# Send message
|
33
|
-
puts "Sending Request"
|
32
|
+
# Send request message and wait for reply
|
34
33
|
if reply = requestor.request(message, timeout)
|
35
|
-
puts "Received Response: #{reply.inspect}"
|
36
|
-
puts " Message:[#{reply.body.inspect}]"
|
37
|
-
|
34
|
+
puts "Received Response: #{reply.inspect}" if count < 10
|
35
|
+
puts " Message:[#{reply.body.inspect}]" if count < 10
|
36
|
+
print "." if count >= 10
|
38
37
|
else
|
39
38
|
puts "Time out, No reply received after #{timeout/1000} seconds"
|
40
39
|
end
|
41
|
-
#p message
|
42
40
|
puts "#{i}" if i%1000 == 0
|
43
41
|
puts "Durable" if message.durable
|
44
42
|
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
#
|
5
5
|
|
6
6
|
# Allow examples to be run in-place without requiring a gem install
|
7
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '
|
7
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../../lib'
|
8
8
|
|
9
9
|
require 'rubygems'
|
10
10
|
require 'yaml'
|
@@ -15,7 +15,7 @@ timeout = (ARGV[0] || 1000).to_i
|
|
15
15
|
config = YAML.load_file(File.dirname(__FILE__) + '/hornetq.yml')['development']
|
16
16
|
|
17
17
|
# Create a HornetQ session
|
18
|
-
|
18
|
+
HornetQ::Client::Factory.create_session(config) do |session|
|
19
19
|
consumer = session.create_consumer('jms.queue.ExampleQueue')
|
20
20
|
session.start
|
21
21
|
|
@@ -15,22 +15,23 @@ full_example:
|
|
15
15
|
:connector:
|
16
16
|
# The uri is written as follows for the NettyConnectorFactory.
|
17
17
|
# protocol=netty is the default and therefore not required
|
18
|
-
:uri: hornetq://localhost:5445,
|
18
|
+
:uri: hornetq://localhost:5445,backuphost:5445/?protocol=netty
|
19
19
|
# Or, the uri is written as follows for the InVM
|
20
|
-
:uri: hornetq://
|
20
|
+
:uri: hornetq://invm
|
21
21
|
# Or, the uri is written as follows for auto-discovery
|
22
|
-
:uri: hornetq://
|
22
|
+
:uri: hornetq://discoveryhost:5445/?protocol=discovery
|
23
23
|
|
24
24
|
# For a static cluster list as an array of URI's
|
25
25
|
:uri:
|
26
|
-
-
|
27
|
-
-
|
26
|
+
- hornetq://server1:5445,server1backup:5445
|
27
|
+
- hornetq://server2:5445,server2backup:5445
|
28
28
|
# URI format:
|
29
|
-
#
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
# hornetq://host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]
|
30
|
+
# where options can be any of
|
31
|
+
# protocol=[netty|invm|discovery]
|
32
|
+
:failover_on_initial_connection: true
|
33
|
+
:failover_on_server_shutdown: true
|
34
|
+
:reconnect_attempts: -1
|
34
35
|
:session:
|
35
36
|
:username: guest
|
36
37
|
:password: guest
|
@@ -4,9 +4,12 @@
|
|
4
4
|
# Typical scenario is in a Rails app when we need to do a call to a
|
5
5
|
# remote server and block until a response is received
|
6
6
|
#
|
7
|
+
# Shows how to use the session pool so that not every thread has to have its
|
8
|
+
# own session
|
9
|
+
#
|
7
10
|
|
8
11
|
# Allow examples to be run in-place without requiring a gem install
|
9
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '
|
12
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../../lib'
|
10
13
|
|
11
14
|
require 'rubygems'
|
12
15
|
require 'yaml'
|
@@ -22,7 +25,7 @@ def worker_thread(id, session_pool)
|
|
22
25
|
begin
|
23
26
|
# Obtain a session from the pool and return when complete
|
24
27
|
session_pool.requestor('jms.queue.ExampleQueue') do |session, requestor|
|
25
|
-
message = session.create_message(
|
28
|
+
message = session.create_message(HornetQ::Client::Message::TEXT_TYPE,false)
|
26
29
|
message << "Request Current Time"
|
27
30
|
|
28
31
|
# Send message to the queue
|
@@ -42,7 +45,7 @@ def worker_thread(id, session_pool)
|
|
42
45
|
end
|
43
46
|
|
44
47
|
# Create a HornetQ Factory
|
45
|
-
|
48
|
+
HornetQ::Client::Factory.create_factory(config[:connector]) do |factory|
|
46
49
|
|
47
50
|
# Create a pool of session connections, all with the same session parameters
|
48
51
|
# The pool is thread-safe and can be accessed concurrently by multiple threads
|
@@ -4,7 +4,7 @@
|
|
4
4
|
#
|
5
5
|
|
6
6
|
# Allow examples to be run in-place without requiring a gem install
|
7
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '
|
7
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../../lib'
|
8
8
|
|
9
9
|
require 'rubygems'
|
10
10
|
require 'yaml'
|
@@ -44,7 +44,7 @@ def worker(id, session)
|
|
44
44
|
end
|
45
45
|
|
46
46
|
# Create a HornetQ session
|
47
|
-
|
47
|
+
HornetQ::Client::Factory.create_factory(config[:connector]) do |factory|
|
48
48
|
threads = []
|
49
49
|
$thread_count.times do |i|
|
50
50
|
session = factory.create_session(config[:session])
|
@@ -4,7 +4,7 @@
|
|
4
4
|
#
|
5
5
|
|
6
6
|
# Allow examples to be run in-place without requiring a gem install
|
7
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '
|
7
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../../lib'
|
8
8
|
|
9
9
|
require 'rubygems'
|
10
10
|
require 'yaml'
|
@@ -14,14 +14,13 @@ count = (ARGV[0] || 1).to_i
|
|
14
14
|
config = YAML.load_file(File.dirname(__FILE__) + '/hornetq.yml')['development']
|
15
15
|
|
16
16
|
# Create a HornetQ session
|
17
|
-
|
18
|
-
#session.create_queue('Example', 'Example', true)
|
17
|
+
HornetQ::Client::Factory.create_session(config) do |session|
|
19
18
|
producer = session.create_producer('jms.queue.ExampleQueue')
|
20
19
|
start_time = Time.now
|
21
20
|
|
22
21
|
puts "Sending messages"
|
23
22
|
(1..count).each do |i|
|
24
|
-
message = session.create_message(
|
23
|
+
message = session.create_message(HornetQ::Client::Message::TEXT_TYPE,false)
|
25
24
|
# Set the message body text
|
26
25
|
message << "#{Time.now}: ### Hello, World ###"
|
27
26
|
# Send message to the queue
|