Skip to content

Commit f616788

Browse files
author
Simon MacMullen
committed
Merging default into bug22956
2 parents aa34beb + 8e34cea commit f616788

40 files changed

+1296
-355
lines changed

README-EXAMPLES

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
Overview
2+
========
3+
4+
A number of examples are packaged with the source distribution and
5+
with the tests jar in the binary distribution. These examples vary in
6+
complexity from simple clients and servers through to complex test
7+
harnesses that are used for testing the RabbitMQ server.
8+
9+
The source code for the examples can be found in the
10+
test/src/com/rabbitmq/examples directory of the source distribution.
11+
12+
13+
Running the Examples
14+
====================
15+
16+
The script runjava.sh or runjava.bat can be found in the top level
17+
directory of the binary distribution or in the scripts directory of
18+
the source distribution.
19+
20+
This script can be used to run the examples. For instance, if you are
21+
using the binary distribution and if you have a RabbitMQ broker
22+
running and you open two shell or console windows you can test basic
23+
connectivity like this:
24+
25+
shell-1$ ./runjava.sh com.rabbitmq.examples.SimpleConsumer
26+
27+
shell-2$ ./runjava.sh com.rabbitmq.examples.SimpleProducer
28+
29+
shell-1$ ./runjava.sh com.rabbitmq.examples.SimpleConsumer
30+
Message: the time is Fri Feb 26 08:28:58 GMT 2010
31+
32+
Running the examples from the source distribution requries two more
33+
preliminary steps:
34+
35+
shell-1$ ant dist
36+
37+
shell-1$ cd build/dist/
38+
39+
Now, the examples can be run exactly as detailed above.
40+
41+
The more complex examples will require additional command line
42+
arguments and it is best to examine the source of the examples to
43+
determine what arguments are available.
44+
45+
All examples live in the com.rabbitmq.examples package, so just add
46+
that package name to the examples described below to produce the full
47+
classname that is required as the first argument to the runjava
48+
script.
49+
50+
51+
Simple Examples
52+
===============
53+
54+
SimpleProducer - Sends a message to an exchange.
55+
SimpleConsumer - Reads a message from a queue.
56+
SimpleTopicProducer - Sends a message to a topic exchange.
57+
SimpleTopicConsumer - Reads a message from a topic queue.
58+
SendString - Send a string to an exchange.
59+
FileProducer - Sends a file to an exchange.
60+
FileConsumer - Reads a file from a queue.
61+
HelloClient - Performs a simple RPC call over AMQP.
62+
HelloServer - Acts as an RPC server over AMQP.
63+
HelloJsonClient - Performs a simple JSON-RPC call over AMQP.
64+
HelloJsonServer - Acts as a JSON-RPC server over AMQP.
65+
LogTail - Tails the server logs.
66+
SendString - Sends a user supplied message over AMQP.
67+
68+
69+
More Complex Examples
70+
=====================
71+
72+
Most of these examples are used in testing and tuning the RabbitMQ
73+
server.
74+
75+
BufferPerformanceMetrics - Tests buffer sizing.
76+
ChannelCreationPerformance - Test different Channel creation strategies.
77+
ConsumerMain - Measures performance of Consumers.
78+
ManyConnections - Tests many connections.
79+
MulticastMain - Measures performance of multiple consumers and producers.
80+
ProducerMain - Measures performance of Producers.
81+
SpammyTopicProducer - Sends lots of different topic messages over AMQP.
82+
StressPersister - Stress test for persister.
83+
TestMain - RabbitMQ server regression tests.
84+
TracerConcurrencyTest - Tests correct concurrency behaviour of RabbitMQ tracer.

README-TESTS

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
Overview
2+
========
3+
4+
There are multiple test suites in the RabbitMQ Java client library;
5+
the source for all of the suites can be found in the test/src
6+
directory.
7+
8+
The suites are:
9+
10+
Client tests
11+
Functional tests
12+
Server tests
13+
SSL tests
14+
15+
All the tests require a conforming server listening on localhost:5672
16+
(the default settings). For details on running specific tests, see
17+
below.
18+
19+
All the test suites can be run with the command ant test-suite. To run
20+
specific test suites see the instructions below.
21+
22+
23+
Running a Specific Test Suite
24+
=============================
25+
26+
To run a specific test suite, but not the others, you should execute
27+
one of the following in the top-level directory of the source tree:
28+
29+
ant test-client
30+
ant test-functional
31+
ant test-server
32+
ant test-ssl
33+
34+
Note that to run the SSL tests, the RabbitMQ server should be
35+
configured to use SSL as per the SSL with RabbitMQ guide.
36+
37+
The server tests are meant to test a RabbitMQ broker. Broadly, they
38+
require a running RabbitMQ broker on the default host/port, the source
39+
code for rabbitmq-server in ../rabbitmq-server, and a test directory
40+
../rabbitmq-test. Running them manually is a tricky business.
41+
42+
For example, to run the client tests:
43+
44+
----------------- Example shell session -------------------------------------
45+
rabbitmq-java-client$ ant test-client
46+
Buildfile: build.xml
47+
48+
test-prepare:
49+
50+
test-build:
51+
52+
amqp-generate-check:
53+
54+
amqp-generate:
55+
56+
build:
57+
58+
test-build-param:
59+
60+
test-client:
61+
[junit] Running com.rabbitmq.client.test.ClientTests
62+
[junit] Tests run: 31, Failures: 0, Errors: 0, Time elapsed: 2.388 sec
63+
64+
BUILD SUCCESSFUL
65+
-----------------------------------------------------------------------------
66+
67+
If any tests are broken details can be found by viewing this file:
68+
build/TEST-com.rabbitmq.client.test.ClientTests.txt

build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test.javac.out=${build.out}/test/classes
1313
test.src.home=test/src
1414
java-jvm-1.4=c:/Program Files/java/j2re1.4.2_14/bin/java
1515
sibling.codegen.dir=../rabbitmq-codegen/
16-
spec.version=0.8
16+
spec.version=0.9.1
1717
bundle.out=${build.out}/bundle
1818
javadoc.out=build/doc/api
1919
python.bin=python

build.xml

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
<pathelement path="${test.javac.out}"/>
2727
</path>
2828

29-
<property name="AMQP_SPEC_JSON_PATH" value="${codegen.dir}/amqp-${spec.version}.json ${codegen.dir}/rabbitmq-0.8-extensions.json"/>
30-
29+
<property name="AMQP_SPEC_JSON_PATH" value="${codegen.dir}/amqp-rabbitmq-${spec.version}.json"/>
30+
3131
<target name="amqp-generate-check" description="check if codegen needs to be run">
3232
<uptodate property="amqp.generate.notRequired">
3333
<srcfiles file="codegen.py"/>
@@ -40,7 +40,7 @@
4040
</compositemapper>
4141
</uptodate>
4242
</target>
43-
43+
4444
<target name="amqp-generate" depends="amqp-generate-check"
4545
unless="amqp.generate.notRequired" description="generate AMQP.java and AMQImpl.java from AMQP spec">
4646
<mkdir dir="${src.generated}/com/rabbitmq/client/"/>
@@ -77,7 +77,7 @@
7777
</fail>
7878
</target>
7979

80-
<target name="build" depends="amqp-generate">
80+
<target name="build" depends="amqp-generate" description="Build the client library.">
8181
<mkdir dir="${javac.out}"/>
8282
<copy file="src/com/rabbitmq/client/impl/ClientVersion.java.in"
8383
tofile="${src.generated}/com/rabbitmq/client/impl/ClientVersion.java">
@@ -116,6 +116,10 @@
116116
<property name="SSL_P12_PASSWORD" value="${env.PASSWORD}"/>
117117
</target>
118118

119+
<target name="detect-umbrella">
120+
<available property="UMBRELLA_AVAILABLE" file="../rabbitmq-test"/>
121+
</target>
122+
119123
<target name="detect-tmpdir">
120124
<property environment="env"/>
121125
<condition property="TMPDIR" value="${env.TMPDIR}" else="/tmp">
@@ -167,12 +171,12 @@
167171
<arg value="${CLIENT_KEYSTORE_PHRASE}"/>
168172
</exec>
169173
</target>
170-
174+
171175
<target name="remove-client-keystore" if="SSL_AVAILABLE">
172176
<delete file="${CLIENT_KEYSTORE}" failonerror="false"/>
173177
<delete file="${CLIENT_KEYSTORE_EMPTY}" failonerror="false"/>
174178
</target>
175-
179+
176180
<target name="test-prepare">
177181
<property name="haltOnFailureJunit" value="yes" />
178182
<property name="haltOnFailureJava" value="true" />
@@ -314,10 +318,10 @@
314318

315319
<target name="test-suite-prepare">
316320
<property name="haltOnFailureJunit" value="no" />
317-
<property name="haltOnFailureJava" value="false" />
321+
<property name="haltOnFailureJava" value="false" />
318322
</target>
319-
320-
<target name="test-suite" depends="test-suite-prepare, test-suite-run">
323+
324+
<target name="test-suite" depends="test-suite-prepare, test-suite-run" description="Run all test suites.">
321325
<fail message="Errors occured in tests">
322326
<condition>
323327
<not>
@@ -328,8 +332,8 @@
328332
</target>
329333

330334
<target name="test-suite-run" depends="test-client, test-ssl, test-server, test-functional, test-main-silent"/>
331-
332-
<target name="test-client" depends="test-build">
335+
336+
<target name="test-client" depends="test-build" description="Run the client test suites.">
333337
<junit printSummary="withOutAndErr"
334338
haltOnFailure="${haltOnFailureJunit}"
335339
failureproperty="test.failure"
@@ -351,7 +355,7 @@
351355
<jvmarg value="-Dkeystore.path=${CLIENT_KEYSTORE}"/>
352356
<jvmarg value="-Dkeystore.empty.path=${CLIENT_KEYSTORE_EMPTY}"/>
353357
<jvmarg value="-Dkeystore.passwd=${CLIENT_KEYSTORE_PHRASE}"/>
354-
358+
355359
<jvmarg value="-Dp12.path=${SSL_CERTS_DIR}/client/keycert.p12"/>
356360
<jvmarg value="-Dp12.passwd=${SSL_P12_PASSWORD}"/>
357361

@@ -362,7 +366,7 @@
362366
<antcall target="remove-client-keystore"/>
363367
</target>
364368

365-
<target name="test-functional" depends="test-build">
369+
<target name="test-functional" depends="test-build" description="Run the functional test suite.">
366370
<junit printSummary="withOutAndErr"
367371
haltOnFailure="${haltOnFailureJunit}"
368372
failureproperty="test.failure"
@@ -375,7 +379,7 @@
375379
</junit>
376380
</target>
377381

378-
<target name="test-server" depends="test-build">
382+
<target name="test-server" depends="detect-umbrella, test-build" if="UMBRELLA_AVAILABLE">
379383
<junit printSummary="withOutAndErr"
380384
haltOnFailure="${haltOnFailureJunit}"
381385
failureproperty="test.failure"
@@ -475,16 +479,16 @@
475479
<fileset dir="lib">
476480
<include name="**/*.jar"/>
477481
</fileset>
478-
482+
479483
<fileset dir="${lib.out}">
480484
<include name="**/*.jar"/>
481485
</fileset>
482-
486+
483487
<fileset dir="scripts">
484488
<include name="**/*.sh"/>
485489
<include name="**/*.bat"/>
486490
</fileset>
487-
491+
488492
<fileset file="${retrotranslator}/retrotranslator-runtime-1.2.1.jar"/>
489493
<fileset file="${retrotranslator}/backport-util-concurrent-3.0.jar"/>
490494
</copy>

codegen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ def printHeader():
150150
public static class PROTOCOL {"""
151151
print " public static final int MAJOR = %i;" % spec.major
152152
print " public static final int MINOR = %i;" % spec.minor
153+
print " public static final int REVISION = %i;" % spec.revision
153154
print " public static final int PORT = %i;" % spec.port
154155
print " }"
155156

src/com/rabbitmq/client/BasicProperties.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,6 @@ public interface BasicProperties {
114114
*/
115115
public abstract String getAppId();
116116

117-
/**
118-
* Retrieve the value in the clusterId field.
119-
* @return clusterId field, or null if the field has not been set.
120-
*/
121-
public abstract String getClusterId();
122-
123117
/**
124118
* Set the contentType field, or null indicating the field is not set
125119
* @param contentType the value to set the field to
@@ -198,9 +192,4 @@ public interface BasicProperties {
198192
*/
199193
public abstract void setAppId(String appId);
200194

201-
/**
202-
* Set the clusterId field, or null indicating the field is not set
203-
* @param clusterId the value to set the field to
204-
*/
205-
public abstract void setClusterId(String clusterId);
206195
}

src/com/rabbitmq/client/Channel.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,17 @@ Queue.DeclareOk queueDeclare(String queue, boolean durable, boolean exclusive, b
457457
*/
458458
void basicAck(long deliveryTag, boolean multiple) throws IOException;
459459

460+
/**
461+
* Reject a message. Supply the deliveryTag from the {@link com.rabbitmq.client.AMQP.Basic.GetOk}
462+
* or {@link com.rabbitmq.client.AMQP.Basic.Deliver} method
463+
* containing the received message being rejected.
464+
* @see com.rabbitmq.client.AMQP.Basic.Reject
465+
* @param deliveryTag the tag from the received {@link com.rabbitmq.client.AMQP.Basic.GetOk} or {@link com.rabbitmq.client.AMQP.Basic.Deliver}
466+
* @param requeue true if the rejected message should be requeued rather than discarded/dead-lettered
467+
* @throws java.io.IOException if an error is encountered
468+
*/
469+
void basicReject(long deliveryTag, boolean requeue) throws IOException;
470+
460471
/**
461472
* Start a non-nolocal, non-exclusive consumer, with
462473
* explicit acknowledgements required and a server-generated consumerTag.
@@ -467,7 +478,7 @@ Queue.DeclareOk queueDeclare(String queue, boolean durable, boolean exclusive, b
467478
* @see com.rabbitmq.client.AMQP.Basic.Consume
468479
* @see com.rabbitmq.client.AMQP.Basic.ConsumeOk
469480
* @see #basicAck
470-
* @see #basicConsume(String,boolean, String,boolean,boolean, Consumer)
481+
* @see #basicConsume(String,boolean, String,boolean,boolean, Map, Consumer)
471482
*/
472483
String basicConsume(String queue, Consumer callback) throws IOException;
473484

@@ -481,7 +492,7 @@ Queue.DeclareOk queueDeclare(String queue, boolean durable, boolean exclusive, b
481492
* @throws java.io.IOException if an error is encountered
482493
* @see com.rabbitmq.client.AMQP.Basic.Consume
483494
* @see com.rabbitmq.client.AMQP.Basic.ConsumeOk
484-
* @see #basicConsume(String,boolean, String,boolean,boolean, Consumer)
495+
* @see #basicConsume(String,boolean, String,boolean,boolean, Map, Consumer)
485496
*/
486497
String basicConsume(String queue, boolean noAck, Consumer callback) throws IOException;
487498

@@ -495,7 +506,7 @@ Queue.DeclareOk queueDeclare(String queue, boolean durable, boolean exclusive, b
495506
* @throws java.io.IOException if an error is encountered
496507
* @see com.rabbitmq.client.AMQP.Basic.Consume
497508
* @see com.rabbitmq.client.AMQP.Basic.ConsumeOk
498-
* @see #basicConsume(String,boolean, String,boolean,boolean, Consumer)
509+
* @see #basicConsume(String,boolean, String,boolean,boolean, Map, Consumer)
499510
*/
500511
String basicConsume(String queue, boolean noAck, String consumerTag, Consumer callback) throws IOException;
501512

@@ -513,7 +524,7 @@ Queue.DeclareOk queueDeclare(String queue, boolean durable, boolean exclusive, b
513524
* @see com.rabbitmq.client.AMQP.Basic.Consume
514525
* @see com.rabbitmq.client.AMQP.Basic.ConsumeOk
515526
*/
516-
String basicConsume(String queue, boolean noAck, String consumerTag, boolean noLocal, boolean exclusive, Consumer callback) throws IOException;
527+
String basicConsume(String queue, boolean noAck, String consumerTag, boolean noLocal, boolean exclusive, Map<String, Object> filter, Consumer callback) throws IOException;
517528

518529
/**
519530
* Cancel a consumer. Calls the consumer's {@link Consumer#handleCancelOk}

src/com/rabbitmq/client/Connection.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,6 @@ public interface Connection extends ShutdownNotifier { // rename to AMQPConnecti
9898
*/
9999
Map<String, Object> getClientProperties();
100100

101-
/**
102-
* Retrieve the known hosts.
103-
* @return an array of addresses for all hosts that came back in the initial {@link com.rabbitmq.client.AMQP.Connection.OpenOk} open-ok method
104-
*/
105-
Address[] getKnownHosts();
106-
107101
/**
108102
* Retrieve the server properties.
109103
* @return a map of the server properties. This typically includes the product name and version of the server.

0 commit comments

Comments
 (0)