下载地址:
官网地址:http://www.rabbitmq.com/java-tools.html
下载后进行解压即可:
使用方式
runjava com.rabbitmq.perf.PerfTest --help
usage:
-?,--help show usage
-a,--autoack auto ack
-A,--multi-ack-every multi ack every
-ad,--auto-delete should the queue be
auto-deleted, default is true
-b,--heartbeat heartbeat interval
-B,--body comma-separated list of files
to use in message bodies
-bc,--body-count number of pre-generated
message bodies. Use with
--json-body. Default is 100.
-bfc,--body-field-count number of pre-generated
fields and values for body.
Use with --json-body. Default
is 1000.
-c,--confirm max unconfirmed publishes
-C,--pmessages producer message count
-ca,--consumer-args consumer arguments as
key/values pairs, separated
by commas, e.g. x-priority=10
-cri,--connection-recovery-interval connection recovery interval
in seconds. Default is 5
seconds. Interval syntax,
e.g. 30-60, is supported to
specify an random interval
between 2 values between each
attempt.
-ct,--confirm-timeout waiting timeout for
unconfirmed publishes before
failing (in seconds)
-ctp,--consumers-thread-pools number of thread pools to use
for all consumers, default is
to use a thread pool for each
consumer
-d,--id test ID
-D,--cmessages consumer message count
-dcr,--disable-connection-recovery disable automatic connection
recovery
-e,--exchange exchange name
-E,--exclusive use server-named exclusive
queues. Such queues can only
be used by their declaring
connection!
-env,--environment-variables show usage with environment
variables
-f,--flag message flag(s), supported
values: persistent and
mandatory. Use the option
several times to specify
several values.
-h,--uri connection URI
-H,--uris connection URIs (separated by
commas)
-hst,--heartbeat-sender-threads number of threads for
producers and consumers
heartbeat senders
-i,--interval sampling interval in seconds
-jb,--json-body generate a random JSON
document for message body.
Use with --size.
-k,--routing-key routing key
-K,--random-routing-key use random routing key per
message
-l,--legacy-metrics display legacy metrics
(min/avg/max latency)
-L,--consumer-latency consumer latency in
microseconds
-m,--ptxsize producer tx size
-M,--framemax frame max
-mh,--metrics-help show metrics usage
-mp,--message-properties message properties as
key/value pairs, separated by
commas, e.g. priority=5
-ms,--use-millis should latency be collected
in milliseconds, default is
false. Set to true if
producers are consumers run
on different machines.
-n,--ctxsize consumer tx size
-na,--nack nack and requeue messages
-niot,--nio-threads number of NIO threads to use
-niotp,--nio-thread-pool size of NIO thread pool,
should be slightly higher
than number of NIO threads
-o,--output-file output file for timing
results
-p,--predeclared allow use of predeclared
objects
-P,--publishing-interval publishing interval in
seconds (opposite of producer
rate limit)
-pi,--polling-interval time to wait before polling
with basic.get, in
millisecond, default is 0.
-po,--polling use basic.get to consume
messages. Do not use this in
real applications.
-prsd,--producer-random-start-delay max random delay in seconds
to start producers
-pst,--producer-scheduler-threads number of threads to use when
using --publishing-interval
-q,--qos consumer prefetch count
-Q,--global-qos channel prefetch count
-qa,--queue-args queue arguments as key/value
pairs, separated by commas,
e.g. x-max-length=10
-qp,--queue-pattern queue name pattern for
creating queues in sequence
-qpf,--queue-pattern-from queue name pattern range
start (inclusive)
-qpt,--queue-pattern-to queue name pattern range end
(inclusive)
-r,--rate producer rate limit
-R,--consumer-rate consumer rate limit
-rkcs,--routing-key-cache-size size of the random routing
keys cache. See
--random-routing-key.
-S,--slow-start start consumers slowly (1 sec
delay between each)
-s,--size message size in bytes
-sb,--skip-binding-queues don't bind queues to the
exchange
-se,--sasl-external use SASL EXTERNAL
authentication, default is
false. Set to true if using
client certificate
authentication with the
rabbitmq_auth_mechanism_ssl
plugin.
-sst,--servers-startup-timeout start timeout in seconds (in
case the servers(s) is (are)
not available when the run
starts). Default is to fail
immediately if the servers(s)
is (are) not available.
-st,--shutdown-timeout shutdown timeout, default is
5 seconds
-sul,--servers-up-limit number of available servers
needed before starting the
run. Used in conjunction with
--servers-start-timeout.
Default is deduced from --uri
or --uris.
-t,--type exchange type
-T,--body-content-type body content-type
-u,--queue queue name
-udsc,--use-default-ssl-context use JVM default SSL context
-v,--version print version information
-vr,--variable-rate variable publishing rate with
[RATE]:[DURATION] syntax,
where [RATE] integer >= 0 and
[DURATION] integer > 0. Use
the option several times to
specify several values.
-vs,--variable-size variable message size with
[SIZE]:[DURATION] syntax,
where [SIZE] integer > 0 and
[DURATION] integer > 0. Use
the option several times to
specify several values.
-x,--producers producer count
-X,--producer-channel-count channels per producer
-y,--consumers consumer count
-Y,--consumer-channel-count channels per consumer
-z,--time run duration in seconds
(unlimited by default)
runjava com.rabbitmq.perf.PerfTest -h amqp://guest:[email protected]:5672 -e xxx_exchange -k xxx_route -s 50 -x 5 -y 0 --body-content-type application/json -t topic -p
使用2个发布者和4个消费者:
runjava com.rabbitmq.perf.PerfTest -x 2 -y 4 -u "test-2" -a --id "test 2"
此修改将消费者切换到手动确认:
runjava com.rabbitmq.perf.PerfTest -x 1 -y 2 -u "test-3" --id "test 3"
修改将消息大小从默认(12字节)更改为4 kB:
runjava com.rabbitmq.perf.PerfTest -x 1 -y 2 -u "test-4" --id "test 4" -s 4000
使用持久队列和持久消息:
runjava com.rabbitmq.perf.PerfTest -x 1 -y 2 -u "test-5" --id "test-5" -f persistent
选项说明:
runjava com.rabbitmq.perf.PerfTest -x 1 -y 2 -u "test-6" --id "test-6" -f persistent --multi-ack-every 100