jruby-hornetq 0.4.0 → 0.5.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +9 -0
- data/Gemfile.lock +30 -0
- data/HISTORY.md +6 -0
- data/README.md +33 -35
- data/Rakefile +14 -9
- data/examples/advanced/batch_client.rb +8 -8
- data/examples/advanced/batch_requestor_pattern.rb +34 -34
- data/examples/advanced/bytes_producer.rb +3 -3
- data/examples/advanced/client.rb +5 -5
- data/examples/advanced/client_session_pooling.rb +3 -3
- data/examples/advanced/consume_on_message.rb +5 -5
- data/examples/advanced/consumer.rb +2 -2
- data/examples/advanced/multi_client.rb +3 -3
- data/examples/advanced/producer.rb +3 -3
- data/examples/advanced/server.rb +4 -4
- data/examples/client-server/client.rb +4 -4
- data/examples/client-server/server.rb +4 -4
- data/examples/producer-consumer/consume_all.rb +2 -2
- data/examples/producer-consumer/consume_on_message.rb +5 -5
- data/examples/producer-consumer/consumer.rb +2 -2
- data/examples/producer-consumer/producer.rb +3 -3
- data/examples/resque/hornetq_job.rb +19 -19
- data/examples/resque/processor.rb +4 -4
- data/examples/resque/sleep_job.rb +3 -3
- data/lib/hornetq.rb +3 -2
- data/lib/hornetq/client.rb +4 -2
- data/lib/hornetq/client/connection.rb +86 -86
- data/lib/hornetq/client/message_handler.rb +1 -1
- data/lib/hornetq/client/org_hornetq_api_core_client_client_session.rb +67 -67
- data/lib/hornetq/client/org_hornetq_core_client_impl_client_consumer_impl.rb +11 -11
- data/lib/hornetq/client/org_hornetq_core_client_impl_client_message_impl.rb +126 -126
- data/lib/hornetq/client/org_hornetq_core_client_impl_client_producer_impl.rb +14 -14
- data/lib/hornetq/client/org_hornetq_utils_typed_properties.rb +6 -6
- data/lib/hornetq/client/requestor_pattern.rb +24 -24
- data/lib/hornetq/client/server_pattern.rb +4 -4
- data/lib/hornetq/client/session_pool.rb +18 -18
- data/lib/hornetq/common/logging.rb +1 -14
- data/lib/hornetq/java/hornetq-bootstrap.jar +0 -0
- data/lib/hornetq/java/hornetq-commons.jar +0 -0
- data/lib/hornetq/java/hornetq-core-client.jar +0 -0
- data/lib/hornetq/java/hornetq-journal.jar +0 -0
- data/lib/hornetq/java/hornetq-server.jar +0 -0
- data/lib/hornetq/java/jnp-client.jar +0 -0
- data/lib/hornetq/java/netty.jar +0 -0
- data/lib/hornetq/server.rb +4 -1
- data/lib/hornetq/version.rb +3 -0
- data/nbproject/private/private.properties +4 -0
- data/nbproject/private/private.xml +4 -0
- data/nbproject/private/rake-d.txt +4 -0
- data/nbproject/project.properties +11 -0
- data/nbproject/project.xml +17 -0
- data/test/client_connection_test.rb +25 -25
- data/test/logging_test.rb +3 -3
- metadata +131 -125
- 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/lib/hornetq/common/log_delegate.rb +0 -48
- data/lib/hornetq/common/org_hornetq_core_logging_logger.rb +0 -60
- data/lib/hornetq/java/hornetq-core.jar +0 -0
@@ -21,17 +21,17 @@ HornetQ::Client::Connection.start_session('hornetq://localhost') do |session|
|
|
21
21
|
rescue
|
22
22
|
# Ignore when queue already exists
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
server = session.create_server(q_name, timeout)
|
26
26
|
|
27
|
-
puts "Waiting for Requests..."
|
27
|
+
puts "Waiting for Requests..."
|
28
28
|
server.run do |request_message|
|
29
29
|
print "."
|
30
|
-
|
30
|
+
|
31
31
|
# Create Reply Message
|
32
32
|
reply_message = session.create_message(HornetQ::Client::Message::TEXT_TYPE, false)
|
33
33
|
reply_message.body = "Echo [#{request_message.body}]"
|
34
|
-
|
34
|
+
|
35
35
|
# The result of the block is the message to be sent back, or nil if no reply
|
36
36
|
reply_message
|
37
37
|
end
|
@@ -7,7 +7,7 @@ require 'resque/job_with_status' # in rails you would probably do this in an ini
|
|
7
7
|
# Create a Resque Job with the ability to report status
|
8
8
|
#
|
9
9
|
class SleepJob < Resque::JobWithStatus
|
10
|
-
|
10
|
+
|
11
11
|
# Set the name of the queue to use for this Job Worker
|
12
12
|
@queue = "sleep_job"
|
13
13
|
|
@@ -29,14 +29,14 @@ end
|
|
29
29
|
if __FILE__ == $0
|
30
30
|
# Make sure you have a worker running
|
31
31
|
# jruby resque_worker.rb
|
32
|
-
|
32
|
+
|
33
33
|
count = (ARGV[0] || 10).to_i
|
34
34
|
|
35
35
|
# running the job
|
36
36
|
puts "Creating the SleepJob"
|
37
37
|
job_id = SleepJob.create :length => count
|
38
38
|
puts "Got back #{job_id}"
|
39
|
-
|
39
|
+
|
40
40
|
# check the status until its complete
|
41
41
|
while status = Resque::Status.get(job_id) and !status.completed? && !status.failed?
|
42
42
|
sleep 1
|
data/lib/hornetq.rb
CHANGED
@@ -27,11 +27,12 @@ module HornetQ
|
|
27
27
|
|
28
28
|
# Convert string into a HornetQ SimpleString
|
29
29
|
def self.as_simple_string(str)
|
30
|
-
str.is_a?(Java::org.hornetq.api.core::SimpleString) ? str : Java::org.hornetq.api.core::SimpleString.new(str.to_s)
|
30
|
+
str.is_a?(Java::org.hornetq.api.core::SimpleString) ? str : Java::org.hornetq.api.core::SimpleString.new(str.to_s)
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
end
|
34
34
|
|
35
|
+
require 'hornetq/version'
|
35
36
|
require 'hornetq/server'
|
36
37
|
require 'hornetq/client'
|
37
38
|
require 'hornetq/uri'
|
data/lib/hornetq/client.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
HornetQ.require_jar 'jnp-client'
|
2
|
+
HornetQ.require_jar 'hornetq-commons'
|
1
3
|
HornetQ.require_jar 'hornetq-core-client'
|
2
4
|
HornetQ.require_jar 'netty'
|
3
5
|
|
@@ -9,14 +11,14 @@ module HornetQ
|
|
9
11
|
end
|
10
12
|
|
11
13
|
require 'hornetq/client/connection'
|
12
|
-
require 'hornetq/common/org_hornetq_core_logging_logger'
|
14
|
+
#require 'hornetq/common/org_hornetq_core_logging_logger'
|
13
15
|
require 'hornetq/client/org_hornetq_api_core_client_client_session'
|
14
16
|
require 'hornetq/client/org_hornetq_core_client_impl_client_message_impl'
|
15
17
|
require 'hornetq/client/org_hornetq_core_client_impl_client_consumer_impl'
|
16
18
|
require 'hornetq/client/org_hornetq_core_client_impl_client_producer_impl'
|
17
19
|
require 'hornetq/client/org_hornetq_utils_typed_properties'
|
18
20
|
require 'hornetq/common/logging'
|
19
|
-
require 'hornetq/common/log_delegate'
|
21
|
+
#require 'hornetq/common/log_delegate'
|
20
22
|
require 'hornetq/client/message_handler'
|
21
23
|
require 'hornetq/client/requestor_pattern'
|
22
24
|
require 'hornetq/client/server_pattern'
|
@@ -77,203 +77,203 @@ module HornetQ
|
|
77
77
|
# * To use HornetQ within the current JVM
|
78
78
|
# hornetq://invm
|
79
79
|
# Optional Parameters
|
80
|
-
#
|
80
|
+
#
|
81
81
|
# High Availability
|
82
|
-
#
|
82
|
+
#
|
83
83
|
# * :ha => true | false,
|
84
84
|
# true: Receives cluster topology updates from the cluster as
|
85
85
|
# servers leave or join and new backups are appointed or removed.
|
86
86
|
# false: Uses the suplied static list of hosts in :uri
|
87
87
|
# and no HA backup information is propagated to the client
|
88
88
|
# Default: false
|
89
|
-
#
|
89
|
+
#
|
90
90
|
# Flow Control
|
91
|
-
#
|
91
|
+
#
|
92
92
|
# :ack_batch_size => integer,
|
93
93
|
# Sets the acknowledgements batch size. Must be > 0
|
94
|
-
#
|
94
|
+
#
|
95
95
|
# :pre_acknowledge => true | false,
|
96
|
-
# Sets whether messages will pre-acknowledged on the server before
|
96
|
+
# Sets whether messages will pre-acknowledged on the server before
|
97
97
|
# they are sent to the consumers or not
|
98
98
|
# true : Pre-acknowledge consumed messages on the server before they are sent to consumers
|
99
|
-
# false: Clients acknowledge the message they consume.
|
99
|
+
# false: Clients acknowledge the message they consume.
|
100
100
|
# Default: false
|
101
|
-
#
|
101
|
+
#
|
102
102
|
# Grouping:
|
103
|
-
#
|
103
|
+
#
|
104
104
|
# :auto_group => true | false,
|
105
|
-
# Sets whether producers will automatically assign a group ID
|
105
|
+
# Sets whether producers will automatically assign a group ID
|
106
106
|
# to sent messages
|
107
|
-
# true: A random unique group ID is created and set on each message
|
107
|
+
# true: A random unique group ID is created and set on each message
|
108
108
|
# for the property Message.HDR_GROUP_ID
|
109
109
|
# Default: false
|
110
|
-
#
|
110
|
+
#
|
111
111
|
# :group_id => string,
|
112
112
|
# Sets the group ID that will be set on each message sent
|
113
113
|
# Default: nil (no goup id will be set)
|
114
|
-
#
|
114
|
+
#
|
115
115
|
# Blocking calls:
|
116
|
-
#
|
116
|
+
#
|
117
117
|
# :block_on_acknowledge => true | false,
|
118
|
-
# Sets whether consumers created through this factory will block
|
119
|
-
# while sending message acknowledgements or do it asynchronously.
|
118
|
+
# Sets whether consumers created through this factory will block
|
119
|
+
# while sending message acknowledgements or do it asynchronously.
|
120
120
|
# Default: false
|
121
|
-
#
|
121
|
+
#
|
122
122
|
# :block_on_durable_send => true | false,
|
123
|
-
# Sets whether producers will block while sending durable messages
|
123
|
+
# Sets whether producers will block while sending durable messages
|
124
124
|
# or do it asynchronously.
|
125
|
-
# If the session is configured to send durable message asynchronously,
|
126
|
-
# the client can set a SendAcknowledgementHandler on the ClientSession
|
127
|
-
# to be notified once the message has been handled by the server.
|
125
|
+
# If the session is configured to send durable message asynchronously,
|
126
|
+
# the client can set a SendAcknowledgementHandler on the ClientSession
|
127
|
+
# to be notified once the message has been handled by the server.
|
128
128
|
# Default: true
|
129
|
-
#
|
129
|
+
#
|
130
130
|
# :block_on_non_durable_send => true | false,
|
131
|
-
# Sets whether producers will block while sending non-durable messages
|
131
|
+
# Sets whether producers will block while sending non-durable messages
|
132
132
|
# or do it asynchronously.
|
133
|
-
# If the session is configured to send non-durable message asynchronously,
|
134
|
-
# the client can set a SendAcknowledgementHandler on the ClientSession
|
135
|
-
# to be notified once the message has been handled by the server.
|
133
|
+
# If the session is configured to send non-durable message asynchronously,
|
134
|
+
# the client can set a SendAcknowledgementHandler on the ClientSession
|
135
|
+
# to be notified once the message has been handled by the server.
|
136
136
|
# Default: false
|
137
|
-
#
|
137
|
+
#
|
138
138
|
# :call_timeout => long,
|
139
|
-
# Sets the blocking calls timeout in milliseconds. If client's blocking calls to the
|
140
|
-
# server take more than this timeout, the call will throw a
|
141
|
-
# HornetQException with the code HornetQException.CONNECTION_TIMEDOUT.
|
142
|
-
# Value is in milliseconds, default value is HornetQClient.DEFAULT_CALL_TIMEOUT.
|
139
|
+
# Sets the blocking calls timeout in milliseconds. If client's blocking calls to the
|
140
|
+
# server take more than this timeout, the call will throw a
|
141
|
+
# HornetQException with the code HornetQException.CONNECTION_TIMEDOUT.
|
142
|
+
# Value is in milliseconds, default value is HornetQClient.DEFAULT_CALL_TIMEOUT.
|
143
143
|
# Must be >= 0
|
144
|
-
#
|
144
|
+
#
|
145
145
|
# Client Reconnection Parameters:
|
146
|
-
#
|
146
|
+
#
|
147
147
|
# :connection_ttl => long,
|
148
|
-
# Set the connection time-to-live
|
148
|
+
# Set the connection time-to-live
|
149
149
|
# -1 : Disable
|
150
|
-
# >=0 : milliseconds the server will keep a connection alive in the
|
151
|
-
# absence of any data arriving from the client.
|
150
|
+
# >=0 : milliseconds the server will keep a connection alive in the
|
151
|
+
# absence of any data arriving from the client.
|
152
152
|
# Default: 60,000
|
153
|
-
#
|
153
|
+
#
|
154
154
|
# :client_failure_check_period => long,
|
155
|
-
# Sets the period in milliseconds used to check if a client has
|
156
|
-
# failed to receive pings from the server.
|
155
|
+
# Sets the period in milliseconds used to check if a client has
|
156
|
+
# failed to receive pings from the server.
|
157
157
|
# Value must be -1 (to disable) or greater than 0
|
158
158
|
# Default: 30,000
|
159
|
-
#
|
159
|
+
#
|
160
160
|
# :initial_connect_attempts => int,
|
161
161
|
# ?
|
162
|
-
#
|
162
|
+
#
|
163
163
|
# :failover_on_initial_connection => true | false,
|
164
|
-
# Sets whether the client will automatically attempt to connect to
|
164
|
+
# Sets whether the client will automatically attempt to connect to
|
165
165
|
# the backup server if the initial connection to the live server fails
|
166
166
|
# true : If live server is not reachable try to connect to backup server
|
167
167
|
# false: Fail to start if live server is not reachable
|
168
168
|
# Default: false
|
169
|
-
#
|
169
|
+
#
|
170
170
|
# :max_retry_interval => long,
|
171
171
|
# Sets the maximum retry interval in milliseconds.
|
172
172
|
# Only appicable if the retry interval multiplier has been specified
|
173
173
|
# Default: 2000 (2 seconds)
|
174
|
-
#
|
174
|
+
#
|
175
175
|
# :reconnect_attempts => 1,
|
176
176
|
# :retry_interval => long,
|
177
|
-
# Returns the time to retry the connection after failure.
|
177
|
+
# Returns the time to retry the connection after failure.
|
178
178
|
# Value is in milliseconds.
|
179
179
|
# Default: 2000 (2 seconds)
|
180
|
-
#
|
180
|
+
#
|
181
181
|
# :retry_interval_multiplier => double,
|
182
|
-
# Sets the multiplier to apply to successive retry intervals.
|
183
|
-
# Value must be positive.
|
182
|
+
# Sets the multiplier to apply to successive retry intervals.
|
183
|
+
# Value must be positive.
|
184
184
|
# Default: 1
|
185
|
-
#
|
185
|
+
#
|
186
186
|
# Large Message parameters:
|
187
|
-
#
|
187
|
+
#
|
188
188
|
# :cache_large_messages_client => true | false,
|
189
|
-
# Sets whether large messages received by consumers will be
|
190
|
-
# cached in temporary files or not.
|
191
|
-
# When true, consumers will create temporary files to cache large messages.
|
192
|
-
# There is 1 temporary file created for each large message.
|
189
|
+
# Sets whether large messages received by consumers will be
|
190
|
+
# cached in temporary files or not.
|
191
|
+
# When true, consumers will create temporary files to cache large messages.
|
192
|
+
# There is 1 temporary file created for each large message.
|
193
193
|
# Default: false
|
194
|
-
#
|
194
|
+
#
|
195
195
|
# :min_large_message_size => int,
|
196
196
|
# Sets the large message size threshold in bytes. Value must be > 0
|
197
197
|
# Messages whose size is if greater than this value will be handled as large messages
|
198
198
|
# Default: 102400 bytes (100 KBytes)
|
199
|
-
#
|
199
|
+
#
|
200
200
|
# :compress_large_message => true | false,
|
201
|
-
#
|
201
|
+
#
|
202
202
|
# Message Rate Management:
|
203
|
-
#
|
203
|
+
#
|
204
204
|
# :consumer_max_rate => int,
|
205
205
|
# Sets the maximum rate of message consumption for consumers.
|
206
206
|
# Controls the rate at which a consumer can consume messages.
|
207
207
|
# A consumer will never consume messages at a rate faster than the
|
208
|
-
# rate specified.
|
208
|
+
# rate specified.
|
209
209
|
# -1 : Disable
|
210
|
-
# >=0 : Maximum desired message consumption rate specified
|
211
|
-
# in units of messages per second.
|
210
|
+
# >=0 : Maximum desired message consumption rate specified
|
211
|
+
# in units of messages per second.
|
212
212
|
# Default: -1
|
213
|
-
#
|
213
|
+
#
|
214
214
|
# :producer_max_rate => int,
|
215
|
-
# Sets the maximum rate of message production for producers.
|
215
|
+
# Sets the maximum rate of message production for producers.
|
216
216
|
# Controls the rate at which a producer can produce messages.
|
217
217
|
# A producer will never produce messages at a rate faster than the rate specified.
|
218
218
|
# -1 : Disabled
|
219
219
|
# >0 : Maximum desired message production rate specified in units of messages per second.
|
220
220
|
# Default: -1 (Disabled)
|
221
|
-
#
|
221
|
+
#
|
222
222
|
# Thread Pools:
|
223
|
-
#
|
223
|
+
#
|
224
224
|
# :scheduled_thread_pool_max_size => int,
|
225
|
-
# Sets the maximum size of the scheduled thread pool.
|
226
|
-
# This setting is relevant only if this factory does not use global pools.
|
227
|
-
# Value must be greater than 0.
|
225
|
+
# Sets the maximum size of the scheduled thread pool.
|
226
|
+
# This setting is relevant only if this factory does not use global pools.
|
227
|
+
# Value must be greater than 0.
|
228
228
|
# Default: 5
|
229
|
-
#
|
229
|
+
#
|
230
230
|
# :thread_pool_max_size => int,
|
231
|
-
# Sets the maximum size of the thread pool.
|
232
|
-
# This setting is relevant only if this factory does not use
|
233
|
-
# global pools.
|
231
|
+
# Sets the maximum size of the thread pool.
|
232
|
+
# This setting is relevant only if this factory does not use
|
233
|
+
# global pools.
|
234
234
|
# -1 : Unlimited thread pool
|
235
235
|
# >0 : Number of threads in pool
|
236
236
|
# Default: -1 (Unlimited)
|
237
|
-
#
|
237
|
+
#
|
238
238
|
# :use_global_pools => true | false,
|
239
|
-
# Sets whether this factory will use global thread pools
|
239
|
+
# Sets whether this factory will use global thread pools
|
240
240
|
# (shared among all the factories in the same JVM) or its own pools.
|
241
241
|
# true: Uses global JVM thread pools across all HornetQ connections
|
242
242
|
# false: Use a thread pool just for this connection
|
243
243
|
# Default: true
|
244
|
-
#
|
244
|
+
#
|
245
245
|
# Window Sizes:
|
246
|
-
#
|
246
|
+
#
|
247
247
|
# :confirmation_window_size => int,
|
248
|
-
# Set the size in bytes for the confirmation window of this connection.
|
248
|
+
# Set the size in bytes for the confirmation window of this connection.
|
249
249
|
# -1 : Disable the window
|
250
250
|
# >0 : Size in bytes
|
251
251
|
# Default: -1 (Disabled)
|
252
|
-
#
|
252
|
+
#
|
253
253
|
# :consumer_window_size => int,
|
254
254
|
# Sets the window size for flow control for consumers.
|
255
255
|
# -1 : Disable flow control
|
256
256
|
# 0 : Do Not buffer any messages
|
257
257
|
# >0 : Set the maximum size of the buffer
|
258
258
|
# Default: 1048576 (1 MB)
|
259
|
-
#
|
259
|
+
#
|
260
260
|
# :producer_window_size => int,
|
261
|
-
# Sets the window size for flow control of the producers.
|
261
|
+
# Sets the window size for flow control of the producers.
|
262
262
|
# -1 : Disable flow control
|
263
|
-
# >0 : The maximum amount of bytes at any give time (to prevent overloading the connection).
|
263
|
+
# >0 : The maximum amount of bytes at any give time (to prevent overloading the connection).
|
264
264
|
# Default: 65536 (64 KBytes)
|
265
|
-
#
|
265
|
+
#
|
266
266
|
# Other:
|
267
|
-
#
|
267
|
+
#
|
268
268
|
# :connection_load_balancing_policy_class_name => string,
|
269
269
|
# Set the class name of the connection load balancing policy
|
270
270
|
# Value must be the name of a class implementing org.hornetq.api.core.client.loadbalance.ConnectionLoadBalancingPolicy
|
271
271
|
# Default: "org.hornetq.api.core.client.loadbalance.RoundRobinConnectionLoadBalancingPolicy"
|
272
|
-
#
|
272
|
+
#
|
273
273
|
# :initial_message_packet_size => int,
|
274
274
|
# Sets the initial size of messages in bytes
|
275
275
|
# Value must be greater than 0
|
276
|
-
#
|
276
|
+
#
|
277
277
|
def initialize(params={})
|
278
278
|
params =params.clone
|
279
279
|
uri = nil
|
@@ -310,7 +310,7 @@ module HornetQ
|
|
310
310
|
end
|
311
311
|
|
312
312
|
#TODO: Support: server_locator.addInterceptor
|
313
|
-
|
313
|
+
|
314
314
|
# Create server locator with or without HA. Without HA being the default
|
315
315
|
@server_locator = if params[:ha]
|
316
316
|
Java::org.hornetq.api.core.client::HornetQClient.createServerLocatorWithHA(*transport_list)
|
@@ -53,7 +53,7 @@ module HornetQ::Client
|
|
53
53
|
def statistics
|
54
54
|
raise "First call Consumer::on_message with :statistics=>true before calling MessageConsumer::statistics()" unless @message_count
|
55
55
|
duration =(@last_time || Time.now) - @start_time
|
56
|
-
{
|
56
|
+
{
|
57
57
|
:count => @message_count,
|
58
58
|
:duration => duration,
|
59
59
|
:messages_per_second => (@message_count/duration).to_i
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# For each thread that will be processing messages concurrently a separate
|
2
|
-
# session is required.
|
3
|
-
#
|
2
|
+
# session is required.
|
3
|
+
#
|
4
4
|
# Interface org.hornetq.api.core.client.ClientSession
|
5
|
-
#
|
5
|
+
#
|
6
6
|
# See: http://hornetq.sourceforge.net/docs/hornetq-2.1.0.Final/api/index.html?org/hornetq/api/core/client/ClientSession.html
|
7
|
-
#
|
7
|
+
#
|
8
8
|
# Other methods still directly accessible through this class:
|
9
9
|
#
|
10
10
|
# add_failure_listener(SessionFailureListener listener)
|
@@ -18,43 +18,43 @@
|
|
18
18
|
#
|
19
19
|
# commit()
|
20
20
|
# Commits the current transaction
|
21
|
-
#
|
22
|
-
# ClientMessage
|
21
|
+
#
|
22
|
+
# ClientMessage create_message(boolean durable)
|
23
23
|
# Creates a ClientMessage.
|
24
|
-
# ClientMessage
|
24
|
+
# ClientMessage create_message(byte type, boolean durable)
|
25
25
|
# Creates a ClientMessage.
|
26
|
-
# ClientMessage
|
26
|
+
# ClientMessage create_message(byte type, boolean durable, long expiration, long timestamp, byte priority)
|
27
27
|
# Creates a ClientMessage.
|
28
|
-
#
|
29
|
-
# ClientProducer
|
28
|
+
#
|
29
|
+
# ClientProducer create_producer()
|
30
30
|
# Creates a producer with no default address.
|
31
|
-
# ClientProducer
|
31
|
+
# ClientProducer create_producer(SimpleString address)
|
32
32
|
# Creates a producer which sends messages to the given address
|
33
|
-
# ClientProducer
|
33
|
+
# ClientProducer create_producer(SimpleString address, int rate)
|
34
34
|
# Creates a producer which sends messages to the given address
|
35
|
-
# ClientProducer
|
35
|
+
# ClientProducer create_producer(String address)
|
36
36
|
# Creates a producer which sends messages to the given address
|
37
37
|
#
|
38
|
-
# void
|
38
|
+
# void create_queue(String address, String queueName)
|
39
39
|
# Creates a non-temporary queue non-durable queue.
|
40
|
-
# void
|
40
|
+
# void create_queue(String address, String queueName, boolean durable)
|
41
41
|
# Creates a non-temporary queue.
|
42
|
-
# void
|
42
|
+
# void create_queue(String address, String queueName, String filter, boolean durable)
|
43
43
|
# Creates a non-temporaryqueue.
|
44
44
|
#
|
45
|
-
# void
|
45
|
+
# void create_temporary_queue(String address, String queueName)
|
46
46
|
# Creates a temporary queue.
|
47
|
-
# void
|
47
|
+
# void create_temporary_queue(String address, String queueName, String filter)
|
48
48
|
# Creates a temporary queue with a filter.
|
49
49
|
#
|
50
|
-
# void
|
50
|
+
# void delete_queue(String queueName)
|
51
51
|
# Deletes the queue.
|
52
|
-
# int
|
52
|
+
# int version()
|
53
53
|
# Returns the server's incrementingVersion.
|
54
54
|
#
|
55
|
-
# XAResource
|
55
|
+
# XAResource xa_resource()
|
56
56
|
# Returns the XAResource associated to the session.
|
57
|
-
#
|
57
|
+
#
|
58
58
|
# auto_commit_acks?
|
59
59
|
# Returns whether the session will automatically commit its transaction every time a message is acknowledged by a ClientConsumer created by this session, false else
|
60
60
|
# auto_commit_sends?
|
@@ -68,34 +68,34 @@
|
|
68
68
|
# xa?
|
69
69
|
# Return true if the session supports XA, false else
|
70
70
|
#
|
71
|
-
# ClientSession.QueueQuery
|
71
|
+
# ClientSession.QueueQuery queue_query(SimpleString queueName)
|
72
72
|
# Queries information on a queue
|
73
73
|
#
|
74
|
-
# boolean
|
74
|
+
# boolean removeFailureListener(SessionFailureListener listener)
|
75
75
|
# Removes a FailureListener to the session
|
76
|
-
#
|
77
|
-
# void
|
76
|
+
#
|
77
|
+
# void rollback()
|
78
78
|
# Rolls back the current transaction
|
79
|
-
# void
|
79
|
+
# void rollback(boolean considerLastMessageAsDelivered)
|
80
80
|
# Rolls back the current transaction
|
81
|
-
#
|
82
|
-
# void
|
81
|
+
#
|
82
|
+
# void set_send_acknowledgement_handler(SendAcknowledgementHandler handler)
|
83
83
|
# Sets a SendAcknowledgementHandler for this session
|
84
|
-
#
|
85
|
-
# void
|
84
|
+
#
|
85
|
+
# void start()
|
86
86
|
# Starts the session
|
87
|
-
# void
|
87
|
+
# void stop()
|
88
88
|
# Stops the session
|
89
89
|
|
90
90
|
module Java::org.hornetq.api.core.client::ClientSession
|
91
|
-
|
92
|
-
# Creates a ClientConsumer to consume or browse messages matching the filter
|
91
|
+
|
92
|
+
# Creates a ClientConsumer to consume or browse messages matching the filter
|
93
93
|
# from the queue with the given name, calls the supplied block, then close the
|
94
94
|
# consumer
|
95
|
-
#
|
95
|
+
#
|
96
96
|
# If the parameter is a String, then it must be the queue name to consume
|
97
97
|
# messages from. Otherwise, the parameters can be supplied in a Hash
|
98
|
-
#
|
98
|
+
#
|
99
99
|
# The parameters for creating the consumer are as follows:
|
100
100
|
# :queue_name => The name of the queue to consume messages from. Mandatory
|
101
101
|
# :filter => Only consume messages matching the filter: Default: nil
|
@@ -103,18 +103,18 @@ module Java::org.hornetq.api.core.client::ClientSession
|
|
103
103
|
# true | false. Default: false
|
104
104
|
# :window_size => The consumer window size.
|
105
105
|
# :max_rate => The maximum rate to consume messages.
|
106
|
-
#
|
106
|
+
#
|
107
107
|
# Note: If either :window_size or :max_rate is supplied, then BOTH are required
|
108
|
-
#
|
108
|
+
#
|
109
109
|
# Returns the result from the block
|
110
|
-
#
|
110
|
+
#
|
111
111
|
# Example
|
112
112
|
# session.consumer('my_queue') do |consumer|
|
113
113
|
# msg = consumer.receive_immediate
|
114
114
|
# p msg
|
115
115
|
# msg.acknowledge
|
116
116
|
# end
|
117
|
-
#
|
117
|
+
#
|
118
118
|
# Example
|
119
119
|
# # Just browse the messages without consuming them
|
120
120
|
# session.consumer(:queue_name => ##'my_queue', :browse_only => true) do |consumer|
|
@@ -132,11 +132,11 @@ module Java::org.hornetq.api.core.client::ClientSession
|
|
132
132
|
consumer.close if consumer
|
133
133
|
end
|
134
134
|
end
|
135
|
-
|
136
|
-
# Consume or browse all messages matching the filter from the queue with the
|
137
|
-
# given name, calls the supplied block for every message received from the
|
135
|
+
|
136
|
+
# Consume or browse all messages matching the filter from the queue with the
|
137
|
+
# given name, calls the supplied block for every message received from the
|
138
138
|
# queue. Once the timeout has been reached it closes the consumer
|
139
|
-
#
|
139
|
+
#
|
140
140
|
# Parameters:
|
141
141
|
# :timeout How to timeout waiting for messages
|
142
142
|
# -1 : Wait forever
|
@@ -157,9 +157,9 @@ module Java::org.hornetq.api.core.client::ClientSession
|
|
157
157
|
# and the time it took to process them.
|
158
158
|
# Statistics are cumulative between calls to ::each and will only be
|
159
159
|
# reset when ::each is called again with :statistics => true
|
160
|
-
#
|
160
|
+
#
|
161
161
|
# Note: If either :window_size or :max_rate is supplied, then BOTH are required
|
162
|
-
#
|
162
|
+
#
|
163
163
|
# Returns the statistics gathered when :statistics => true, otherwise nil
|
164
164
|
#
|
165
165
|
# Example
|
@@ -167,7 +167,7 @@ module Java::org.hornetq.api.core.client::ClientSession
|
|
167
167
|
# p message
|
168
168
|
# message.acknowledge
|
169
169
|
# end
|
170
|
-
#
|
170
|
+
#
|
171
171
|
# Example
|
172
172
|
# # Just browse the messages without consuming them
|
173
173
|
# session.consume(:queue_name => 'my_queue', :timeout => 1000, :browse_only => true) do |message|
|
@@ -183,7 +183,7 @@ module Java::org.hornetq.api.core.client::ClientSession
|
|
183
183
|
c.close
|
184
184
|
end
|
185
185
|
end
|
186
|
-
|
186
|
+
|
187
187
|
# Create a consumer using named parameters. The following Java create_consumer
|
188
188
|
# methods are still directly accessible:
|
189
189
|
# create_consumer(String queueName)
|
@@ -196,7 +196,7 @@ module Java::org.hornetq.api.core.client::ClientSession
|
|
196
196
|
# Creates a ClientConsumer to consume or browse messages matching the filter from the queue with the given name.
|
197
197
|
# create_consumer(String queueName, String filter, int windowSize, int maxRate, boolean browseOnly)
|
198
198
|
# Creates a ClientConsumer to consume or browse messages matching the filter from the queue with the given name.
|
199
|
-
#
|
199
|
+
#
|
200
200
|
# The parameters for creating the consumer are as follows:
|
201
201
|
# :queue_name => The name of the queue to consume messages from. Mandatory
|
202
202
|
# :filter => Only consume messages matching the filter: Default: nil
|
@@ -204,26 +204,26 @@ module Java::org.hornetq.api.core.client::ClientSession
|
|
204
204
|
# true | false. Default: false
|
205
205
|
# :window_size => The consumer window size.
|
206
206
|
# :max_rate => The maximum rate to consume messages.
|
207
|
-
#
|
207
|
+
#
|
208
208
|
# Note: If either :window_size or :max_rate is supplied, then BOTH are required
|
209
|
-
#
|
209
|
+
#
|
210
210
|
# Returns a new Consumer that can be used for consuming messages from
|
211
211
|
# the queue
|
212
212
|
def create_consumer_from_params(params={})
|
213
|
-
if params.kind_of?(Hash)
|
213
|
+
if params.kind_of?(Hash)
|
214
214
|
raise("Missing mandatory parameter :queue_name") unless queue_name = params[:queue_name]
|
215
|
-
|
215
|
+
|
216
216
|
if params[:max_rate] || params[:window_size]
|
217
217
|
self.create_consumer(
|
218
|
-
queue_name,
|
219
|
-
params[:filter],
|
218
|
+
queue_name,
|
219
|
+
params[:filter],
|
220
220
|
params[:window_size],
|
221
221
|
params[:max_rate],
|
222
222
|
params.fetch(:browse_only, false))
|
223
223
|
else
|
224
224
|
self.create_consumer(
|
225
|
-
queue_name,
|
226
|
-
params[:filter],
|
225
|
+
queue_name,
|
226
|
+
params[:filter],
|
227
227
|
params.fetch(:browse_only, false))
|
228
228
|
end
|
229
229
|
else
|
@@ -231,26 +231,26 @@ module Java::org.hornetq.api.core.client::ClientSession
|
|
231
231
|
end
|
232
232
|
end
|
233
233
|
|
234
|
-
# Creates a ClientProducer to send messages, calls the supplied block,
|
234
|
+
# Creates a ClientProducer to send messages, calls the supplied block,
|
235
235
|
# then close the consumer
|
236
|
-
#
|
236
|
+
#
|
237
237
|
# If the parameter is a String, then it must be the address to send messages to
|
238
238
|
# Otherwise, the parameters can be supplied in a Hash
|
239
|
-
#
|
239
|
+
#
|
240
240
|
# The parameters for creating the consumer are as follows:
|
241
241
|
# :address => The address to which to send messages. If not supplied here,
|
242
242
|
# then the destination address must be supplied with every message
|
243
243
|
# :rate => The producer rate
|
244
|
-
#
|
244
|
+
#
|
245
245
|
# Returns the result from the block
|
246
|
-
#
|
246
|
+
#
|
247
247
|
# Example
|
248
248
|
# session.producer('MyAddress') do |producer|
|
249
249
|
# msg = session.create_message
|
250
250
|
# msg.type = :text
|
251
251
|
# producer.send(msg)
|
252
252
|
# end
|
253
|
-
#
|
253
|
+
#
|
254
254
|
# Example
|
255
255
|
# # Send to a different address with each message
|
256
256
|
# session.producer do |producer|
|
@@ -267,7 +267,7 @@ module Java::org.hornetq.api.core.client::ClientSession
|
|
267
267
|
else
|
268
268
|
address = params
|
269
269
|
end
|
270
|
-
|
270
|
+
|
271
271
|
producer = nil
|
272
272
|
begin
|
273
273
|
producer = if rate
|
@@ -282,12 +282,12 @@ module Java::org.hornetq.api.core.client::ClientSession
|
|
282
282
|
producer.close if producer
|
283
283
|
end
|
284
284
|
end
|
285
|
-
|
285
|
+
|
286
286
|
# To be consistent create Requestor from Session
|
287
287
|
def create_requestor(request_address, reply_address=nil, reply_queue=nil)
|
288
288
|
HornetQ::Client::RequestorPattern.new(self, request_address, reply_address, reply_queue)
|
289
289
|
end
|
290
|
-
|
290
|
+
|
291
291
|
# Creates a RequestorPattern to send a request and to synchronously wait for
|
292
292
|
# the reply, call the supplied block, then close the requestor
|
293
293
|
# Returns the result from the block
|
@@ -299,7 +299,7 @@ module Java::org.hornetq.api.core.client::ClientSession
|
|
299
299
|
requestor.close if requestor
|
300
300
|
end
|
301
301
|
end
|
302
|
-
|
302
|
+
|
303
303
|
# Create a server handler for receiving requests and responding with
|
304
304
|
# replies to the supplied address
|
305
305
|
def create_server(input_queue, timeout=0)
|