Skip to content

Commit 00d46bf

Browse files
author
Matthew Sackman
committed
Merging default into bug21673
2 parents 332bed3 + 5b0c630 commit 00d46bf

30 files changed

+799
-112
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ SRC_ARCHIVE=$(PACKAGE_NAME)-$(VERSION)
77
SIGNING_KEY=056E8E56
88
GNUPG_PATH=~
99

10-
WEB_URL=http://stage.rabbitmq.com/
10+
WEB_URL=http://www.rabbitmq.com/
1111
NEXUS_STAGE_URL=http://oss.sonatype.org/service/local/staging/deploy/maven2
1212

1313
AMQP_CODEGEN_DIR=$(shell fgrep sibling.codegen.dir build.properties | sed -e 's:sibling\.codegen\.dir=::')

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.xml

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

29-
<property name="AMQP_SPEC_JSON_PATH" value="${codegen.dir}/amqp-${spec.version}.json"/>
29+
<property name="AMQP_SPEC_JSON_PATH" value="${codegen.dir}/amqp-${spec.version}.json ${codegen.dir}/rabbitmq-0.8-extensions.json"/>
3030

3131
<target name="amqp-generate-check" description="check if codegen needs to be run">
3232
<uptodate property="amqp.generate.notRequired">
@@ -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">
@@ -317,7 +321,7 @@
317321
<property name="haltOnFailureJava" value="false" />
318322
</target>
319323

320-
<target name="test-suite" depends="test-suite-prepare, test-suite-run">
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>
@@ -329,7 +333,7 @@
329333

330334
<target name="test-suite-run" depends="test-client, test-ssl, test-server, test-functional, test-main-silent"/>
331335

332-
<target name="test-client" depends="test-build">
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"
@@ -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"

src/com/rabbitmq/client/Channel.java

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,40 @@ public interface Channel extends ShutdownNotifier {
147147
*/
148148
void setFlowListener(FlowListener listener);
149149

150+
/**
151+
* Get the current default consumer. @see setDefaultConsumer for rationale.
152+
* @return an interface to the current default consumer.
153+
*/
154+
Consumer getDefaultConsumer();
155+
156+
/**
157+
* Set the current default consumer.
158+
*
159+
* Under certain circumstances it is possible for a channel to receive a
160+
* message delivery which does not match any consumer which is currently
161+
* set up via basicConsume(). This will occur after the following sequence
162+
* of events:
163+
*
164+
* ctag = basicConsume(queue, consumer); // i.e. with explicit acks
165+
* // some deliveries take place but are not acked
166+
* basicCancel(ctag);
167+
* basicRecover(false);
168+
*
169+
* Since requeue is specified to be false in the basicRecover, the spec
170+
* states that the message must be redelivered to "the original recipient"
171+
* - i.e. the same channel / consumer-tag. But the consumer is no longer
172+
* active.
173+
*
174+
* In these circumstances, you can register a default consumer to handle
175+
* such deliveries. If no default consumer is registered an
176+
* IllegalStateException will be thrown when such a delivery arrives.
177+
*
178+
* Most people will not need to use this.
179+
*
180+
* @param consumer the consumer to use, or null indicating "don't use one".
181+
*/
182+
void setDefaultConsumer(Consumer consumer);
183+
150184
/**
151185
* Request specific "quality of service" settings.
152186
*
@@ -495,12 +529,22 @@ Queue.DeclareOk queueDeclare(String queue, boolean durable, boolean exclusive, b
495529
* Ask the broker to resend unacknowledged messages. In 0-8
496530
* basic.recover is asynchronous; in 0-9-1 it is synchronous, and
497531
* the new, deprecated method basic.recover_async is asynchronous.
498-
* To avoid this API changing, this is named for the latter, and
499-
* will be deprecated.
500532
* @param requeue If true, messages will be requeued and possibly
501533
* delivered to a different consumer. If false, messages will be
502534
* redelivered to the same consumer.
503535
*/
536+
Basic.RecoverOk basicRecover(boolean requeue) throws IOException;
537+
538+
/**
539+
* Ask the broker to resend unacknowledged messages. In 0-8
540+
* basic.recover is asynchronous; in 0-9-1 it is synchronous, and
541+
* the new, deprecated method basic.recover_async is asynchronous
542+
* and deprecated.
543+
* @param requeue If true, messages will be requeued and possibly
544+
* delivered to a different consumer. If false, messages will be
545+
* redelivered to the same consumer.
546+
*/
547+
@Deprecated
504548
void basicRecoverAsync(boolean requeue) throws IOException;
505549

506550
/**

src/com/rabbitmq/client/Connection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
*
4141
* <pre>
4242
* ConnectionFactory factory = new ConnectionFactory();
43-
* factory.setHostName(hostName);
43+
* factory.setHost(hostName);
44+
* factory.setPort(portNumber);
4445
* factory.setVirtualHost(virtualHost);
4546
* factory.setUsername(username);
4647
* factory.setPassword(password);

src/com/rabbitmq/client/ConnectionFactory.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ public int getPort() {
135135
}
136136

137137
/**
138-
* @return the default port to use for connections
138+
* Set the target port.
139+
* @param port the default port to use for connections
139140
*/
140141
public void setPort(int port) {
141142
this.port = port;
@@ -244,7 +245,7 @@ public void setRequestedHeartbeat(int requestedHeartbeat) {
244245
* table. Such changes will take effect when the next new
245246
* connection is started using this factory.
246247
* @return the map of client properties
247-
* @see setClientProperties()
248+
* @see #setClientProperties
248249
*/
249250
public Map<String, Object> getClientProperties() {
250251
return _clientProperties;
@@ -254,7 +255,7 @@ public Map<String, Object> getClientProperties() {
254255
* Replace the table of client properties that will be sent to the
255256
* server during subsequent connection startups.
256257
* @param clientProperties the map of extra client properties
257-
* @see getClientProperties()
258+
* @see #getClientProperties
258259
*/
259260
public void setClientProperties(Map<String, Object> clientProperties) {
260261
_clientProperties = clientProperties;
@@ -335,7 +336,13 @@ protected FrameHandler createFrameHandler(Address addr)
335336
Socket socket = factory.createSocket();
336337
configureSocket(socket);
337338
socket.connect(new InetSocketAddress(hostName, portNumber));
338-
return new SocketFrameHandler(socket);
339+
return createFrameHandler(socket);
340+
}
341+
342+
protected FrameHandler createFrameHandler(Socket sock)
343+
throws IOException
344+
{
345+
return new SocketFrameHandler(sock);
339346
}
340347

341348
/**

src/com/rabbitmq/client/Consumer.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,19 @@ public interface Consumer {
7070
*/
7171
void handleShutdownSignal(String consumerTag, ShutdownSignalException sig);
7272

73+
/**
74+
* Called to notify the consumer that we've received a basic.recover-ok
75+
* in reply to a basic.recover some other thread sent. All messages
76+
* received before this is invoked that haven't been ack'ed will be
77+
* redelivered. All messages received afterwards won't be.
78+
*
79+
* This method exists since all the Consumer callbacks are invoked by the
80+
* connection main loop thread - so it's sometimes useful to allow that
81+
* thread to know that the recover-ok has been received, rather than the
82+
* thread which invoked basicRecover().
83+
*/
84+
void handleRecoverOk();
85+
7386
/**
7487
* Called when a delivery appears for this consumer.
7588
* @param consumerTag the defined consumerTag (either client- or server-generated)

src/com/rabbitmq/client/DefaultConsumer.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ public void handleShutdownSignal(String consumerTag, ShutdownSignalException sig
7474
// no work to do
7575
}
7676

77+
/**
78+
* No-op implementation of {@link Consumer#handleRecoverOk}.
79+
*/
80+
public void handleRecoverOk() {
81+
// no work to do
82+
}
83+
7784
/**
7885
* No-op implementation of {@link Consumer#handleDelivery}.
7986
*/

0 commit comments

Comments
 (0)