Skip to content

Commit df710c0

Browse files
author
Alvaro Videla
committed
merges default into bug26129
2 parents 1f6d848 + 3f80149 commit df710c0

22 files changed

+731
-125
lines changed

LICENSE

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
This package, the RabbitMQ Java client library is dual-licensed under
2-
the MPL and the GPL v2. For the MPL, please see
3-
LICENSE-MPL-RabbitMQ. For the GPL v2, please see LICENSE-GPL2.
1+
This package, the RabbitMQ Java client library, is triple-licensed under
2+
the Mozilla Public License 1.1 ("MPL"), the GNU General Public License
3+
version 2 ("GPL") and the Apache License version 2 ("ASL"). For the MPL,
4+
please see LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2.
5+
For the ASL, please see LICENSE-APACHE2.
46

5-
The RabbitMQ Java client library includes software under the Apache
6-
Licence v2. For this license, please see LICENSE-APACHE2. For
7-
attribution of copyright and other details of provenance, please refer
8-
to the source code.
7+
The RabbitMQ Java client library includes third-party software under the
8+
ASL. For this license, please see LICENSE-APACHE2. For attribution of
9+
copyright and other details of provenance, please refer to the source code.
910

1011
If you have any questions regarding licensing, please contact us at
1112
info@rabbitmq.com.

LICENSE-MPL-RabbitMQ

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@
429429
Initial Developer may designate portions of the Covered Code as
430430
"Multiple-Licensed". "Multiple-Licensed" means that the Initial
431431
Developer permits you to utilize portions of the Covered Code under
432-
Your choice of the NPL or the alternative licenses, if any, specified
432+
Your choice of the MPL or the alternative licenses, if any, specified
433433
by the Initial Developer in the file described in Exhibit A.
434434

435435
EXHIBIT A -Mozilla Public License.
@@ -447,8 +447,20 @@ EXHIBIT A -Mozilla Public License.
447447
The Original Code is RabbitMQ.
448448

449449
The Initial Developer of the Original Code is GoPivotal, Inc.
450-
Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.''
451-
450+
Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
451+
452+
Alternatively, the contents of this file may be used under the terms
453+
of the GNU General Public License version 2 (the "GPL2"), or
454+
the Apache License version 2 (the "ASL2") in which case the
455+
provisions of GPL2 or the ASL2 are applicable instead of those
456+
above. If you wish to allow use of your version of this file only
457+
under the terms of the GPL2 or the ASL2 and not to allow others to use
458+
your version of this file under the MPL, indicate your decision by
459+
deleting the provisions above and replace them with the notice and
460+
other provisions required by the GPL2 or the ASL2. If you do not delete
461+
the provisions above, a recipient may use your version of this file
462+
under either the MPL, the GPL2 or the ASL2.''
463+
452464
[NOTE: The text of this Exhibit A may differ slightly from the text of
453465
the notices in the Source Code files of the Original Code. You should
454466
use the text of this Exhibit A rather than the text found in the

README.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ For your convenience, a text copy of these instructions is available
55
below. Please be aware that the instructions here may not be as up to
66
date as those at the above URL.
77

8+
See LICENSE for license information.
9+
810
===========================================================================
911

1012

build.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@
444444
</jar>
445445
</target>
446446

447-
<target name="dist" depends="jar, test-jar">
447+
<target name="dist" depends="jar, test-jar" description="Build all library JARs and documentation">
448448
<mkdir dir="${dist.out}"/>
449449
<copy todir="${dist.out}">
450450
<!-- ant doesn't seem to provide any form of usable abstraction over sets of file names -->
@@ -464,7 +464,7 @@
464464
</copy>
465465
</target>
466466

467-
<target name="clean">
467+
<target name="clean" description="Cleans build artifacts">
468468
<delete dir="build"/>
469469
</target>
470470

src/com/rabbitmq/client/ConnectionFactory.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ public class ConnectionFactory implements Cloneable {
9999
private boolean automaticRecovery = false;
100100
private boolean topologyRecovery = true;
101101

102-
private int networkRecoveryInterval = 5000;
102+
// long is used to make sure the users can use both ints
103+
// and longs safely. It is unlikely that anybody'd need
104+
// to use recovery intervals > Integer.MAX_VALUE in practice.
105+
private long networkRecoveryInterval = 5000;
103106

104107
/** @return number of consumer threads in default {@link ExecutorService} */
105108
@Deprecated
@@ -638,7 +641,7 @@ public Connection newConnection(ExecutorService executor) throws IOException {
638641
* Returns automatic connection recovery interval in milliseconds.
639642
* @return how long will automatic recovery wait before attempting to reconnect, in ms; default is 5000
640643
*/
641-
public int getNetworkRecoveryInterval() {
644+
public long getNetworkRecoveryInterval() {
642645
return networkRecoveryInterval;
643646
}
644647

@@ -649,4 +652,12 @@ public int getNetworkRecoveryInterval() {
649652
public void setNetworkRecoveryInterval(int networkRecoveryInterval) {
650653
this.networkRecoveryInterval = networkRecoveryInterval;
651654
}
655+
656+
/**
657+
* Sets connection recovery interval. Default is 5000.
658+
* @param networkRecoveryInterval how long will automatic recovery wait before attempting to reconnect, in ms
659+
*/
660+
public void setNetworkRecoveryInterval(long networkRecoveryInterval) {
661+
this.networkRecoveryInterval = networkRecoveryInterval;
662+
}
652663
}

src/com/rabbitmq/client/RpcClient.java

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
import com.rabbitmq.utility.BlockingCell;
3737

3838
/**
39-
* Convenience class which manages a temporary reply queue for simple RPC-style communication.
39+
* Convenience class which manages simple RPC-style communication.
4040
* The class is agnostic about the format of RPC arguments / return values.
4141
* It simply provides a mechanism for sending a message to an exchange with a given routing key,
42-
* and waiting for a response on a reply queue.
42+
* and waiting for a response.
4343
*/
4444
public class RpcClient {
4545
/** Channel we are communicating on */
@@ -58,8 +58,6 @@ public class RpcClient {
5858
/** Contains the most recently-used request correlation ID */
5959
private int _correlationId;
6060

61-
/** The name of our private reply queue */
62-
private String _replyQueue;
6361
/** Consumer attached to our reply queue */
6462
private DefaultConsumer _consumer;
6563

@@ -73,7 +71,6 @@ public class RpcClient {
7371
* @param routingKey the routing key
7472
* @param timeout milliseconds before timing out on wait for response
7573
* @throws IOException if an error is encountered
76-
* @see #setupReplyQueue
7774
*/
7875
public RpcClient(Channel channel, String exchange, String routingKey, int timeout) throws IOException {
7976
_channel = channel;
@@ -83,7 +80,6 @@ public RpcClient(Channel channel, String exchange, String routingKey, int timeou
8380
_timeout = timeout;
8481
_correlationId = 0;
8582

86-
_replyQueue = setupReplyQueue();
8783
_consumer = setupConsumer();
8884
}
8985

@@ -98,7 +94,6 @@ public RpcClient(Channel channel, String exchange, String routingKey, int timeou
9894
* @param exchange the exchange to connect to
9995
* @param routingKey the routing key
10096
* @throws IOException if an error is encountered
101-
* @see #setupReplyQueue
10297
*/
10398
public RpcClient(Channel channel, String exchange, String routingKey) throws IOException {
10499
this(channel, exchange, routingKey, NO_TIMEOUT);
@@ -125,16 +120,6 @@ public void close() throws IOException {
125120
}
126121
}
127122

128-
/**
129-
* Creates a server-named exclusive autodelete queue to use for
130-
* receiving replies to RPC requests.
131-
* @throws IOException if an error is encountered
132-
* @return the name of the reply queue
133-
*/
134-
protected String setupReplyQueue() throws IOException {
135-
return _channel.queueDeclare("", false, true, true, null).getQueue();
136-
}
137-
138123
/**
139124
* Registers a consumer on the reply queue.
140125
* @throws IOException if an error is encountered
@@ -167,7 +152,7 @@ public void handleDelivery(String consumerTag,
167152
}
168153
}
169154
};
170-
_channel.basicConsume(_replyQueue, true, consumer);
155+
_channel.basicConsume("amq.rabbitmq.reply-to", true, consumer);
171156
return consumer;
172157
}
173158

@@ -186,7 +171,7 @@ public byte[] primitiveCall(AMQP.BasicProperties props, byte[] message)
186171
_correlationId++;
187172
String replyId = "" + _correlationId;
188173
props = ((props==null) ? new AMQP.BasicProperties.Builder() : props.builder())
189-
.correlationId(replyId).replyTo(_replyQueue).build();
174+
.correlationId(replyId).replyTo("amq.rabbitmq.reply-to").build();
190175
_continuationMap.put(replyId, k);
191176
}
192177
publish(props, message);
@@ -332,14 +317,6 @@ public int getCorrelationId() {
332317
return _correlationId;
333318
}
334319

335-
/**
336-
* Retrieve the reply queue.
337-
* @return the name of the client's reply queue
338-
*/
339-
public String getReplyQueue() {
340-
return _replyQueue;
341-
}
342-
343320
/**
344321
* Retrieve the consumer.
345322
* @return an interface to the client's consumer object

src/com/rabbitmq/client/impl/ConnectionParams.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class ConnectionParams {
1717
private final int requestedChannelMax;
1818
private final int requestedHeartbeat;
1919
private final SaslConfig saslConfig;
20-
private final int networkRecoveryInterval;
20+
private final long networkRecoveryInterval;
2121
private final boolean topologyRecovery;
2222

2323
private ExceptionHandler exceptionHandler;
@@ -41,7 +41,7 @@ public class ConnectionParams {
4141
public ConnectionParams(String username, String password, ExecutorService executor,
4242
String virtualHost, Map<String, Object> clientProperties,
4343
int requestedFrameMax, int requestedChannelMax, int requestedHeartbeat,
44-
SaslConfig saslConfig, int networkRecoveryInterval,
44+
SaslConfig saslConfig, long networkRecoveryInterval,
4545
boolean topologyRecovery, ExceptionHandler exceptionHandler, ThreadFactory threadFactory) {
4646
this.username = username;
4747
this.password = password;
@@ -98,7 +98,7 @@ public ExceptionHandler getExceptionHandler() {
9898
return exceptionHandler;
9999
}
100100

101-
public int getNetworkRecoveryInterval() {
101+
public long getNetworkRecoveryInterval() {
102102
return networkRecoveryInterval;
103103
}
104104

src/com/rabbitmq/client/impl/recovery/AutorecoveringChannel.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.rabbitmq.client.ReturnListener;
1515
import com.rabbitmq.client.ShutdownListener;
1616
import com.rabbitmq.client.ShutdownSignalException;
17+
import com.rabbitmq.client.impl.AMQImpl;
1718

1819
import java.io.IOException;
1920
import java.util.ArrayList;
@@ -221,11 +222,11 @@ public AMQP.Exchange.DeleteOk exchangeDelete(String exchange) throws IOException
221222
}
222223

223224
public AMQP.Exchange.BindOk exchangeBind(String destination, String source, String routingKey) throws IOException {
224-
return delegate.exchangeBind(destination, source, routingKey);
225+
return exchangeBind(destination, source, routingKey, null);
225226
}
226227

227228
public AMQP.Exchange.BindOk exchangeBind(String destination, String source, String routingKey, Map<String, Object> arguments) throws IOException {
228-
AMQP.Exchange.BindOk ok = delegate.exchangeBind(destination, source, routingKey, arguments);
229+
final AMQP.Exchange.BindOk ok = delegate.exchangeBind(destination, source, routingKey, arguments);
229230
recordExchangeBinding(destination, source, routingKey, arguments);
230231
return ok;
231232
}
@@ -241,6 +242,7 @@ public AMQP.Exchange.UnbindOk exchangeUnbind(String destination, String source,
241242

242243
public AMQP.Exchange.UnbindOk exchangeUnbind(String destination, String source, String routingKey, Map<String, Object> arguments) throws IOException {
243244
deleteRecordedExchangeBinding(destination, source, routingKey, arguments);
245+
this.maybeDeleteRecordedAutoDeleteExchange(source);
244246
return delegate.exchangeUnbind(destination, source, routingKey, arguments);
245247
}
246248

@@ -321,6 +323,7 @@ public AMQP.Queue.UnbindOk queueUnbind(String queue, String exchange, String rou
321323

322324
public AMQP.Queue.UnbindOk queueUnbind(String queue, String exchange, String routingKey, Map<String, Object> arguments) throws IOException {
323325
deleteRecordedQueueBinding(queue, exchange, routingKey, arguments);
326+
this.maybeDeleteRecordedAutoDeleteExchange(exchange);
324327
return delegate.queueUnbind(queue, exchange, routingKey, arguments);
325328
}
326329

@@ -367,7 +370,8 @@ public String basicConsume(String queue, boolean autoAck, String consumerTag, bo
367370
}
368371

369372
public void basicCancel(String consumerTag) throws IOException {
370-
this.deleteRecordedConsumer(consumerTag);
373+
RecordedConsumer c = this.deleteRecordedConsumer(consumerTag);
374+
this.maybeDeleteRecordedAutoDeleteQueue(c.getQueue());
371375
delegate.basicCancel(consumerTag);
372376
}
373377

@@ -578,7 +582,15 @@ private void recordConsumer(String result,
578582
this.connection.recordConsumer(result, consumer);
579583
}
580584

581-
private void deleteRecordedConsumer(String consumerTag) {
582-
this.connection.deleteRecordedConsumer(consumerTag);
585+
private RecordedConsumer deleteRecordedConsumer(String consumerTag) {
586+
return this.connection.deleteRecordedConsumer(consumerTag);
587+
}
588+
589+
private void maybeDeleteRecordedAutoDeleteQueue(String queue) {
590+
this.connection.maybeDeleteRecordedAutoDeleteQueue(queue);
591+
}
592+
593+
private void maybeDeleteRecordedAutoDeleteExchange(String exchange) {
594+
this.connection.maybeDeleteRecordedAutoDeleteExchange(exchange);
583595
}
584596
}

0 commit comments

Comments
 (0)