Skip to content

Commit 4f96e24

Browse files
committed
Merge default into bug17538
2 parents 93d4992 + cceb341 commit 4f96e24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+632
-243
lines changed

.hgignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
syntax: glob
2+
*~
3+
4+
syntax: regexp
5+
^build/

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ post-dist:
4949
srcdist: distclean
5050
mkdir -p build/$(SRC_ARCHIVE)
5151
cp -Rp `ls | grep -v '^\(build\|BUILD.in\)$$'` build/$(SRC_ARCHIVE)
52-
cp -r $(AMQP_CODEGEN_DIR) build/$(SRC_ARCHIVE)/codegen
52+
53+
mkdir -p build/$(SRC_ARCHIVE)/codegen
54+
cp -r $(AMQP_CODEGEN_DIR)/* build/$(SRC_ARCHIVE)/codegen/.
55+
5356
if [ -f BUILD.in ]; then \
5457
cp BUILD.in build/$(SRC_ARCHIVE)/BUILD; \
5558
elinks -dump -no-references -no-numbering $(WEB_URL)build.html \

scripts/runjava.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
setlocal EnableDelayedExpansion
44

55
set CP=
6-
for %%F in (*.jar) do set CP=!CP!;%%F
6+
for %%F in ("%~dp0"/*.jar) do set CP=!CP!;%%F
77

88
java -cp %CP% %1 %2 %3 %4 %5 %6 %7 %8 %9
99

scripts/runjava.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
RABBIT_JARS=
3-
for d in *.jar
3+
for d in `dirname $0`/*.jar
44
do
55
RABBIT_JARS="$d:$RABBIT_JARS"
66
done
7-
exec java -cp "$RABBIT_JARS" "$@"
7+
exec java -cp "$RABBIT_JARS" "$@"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.rabbitmq.client;
2+
3+
/*
4+
* Thrown when application tries to perform an action on connection/channel
5+
* which was already closed
6+
*/
7+
public class AlreadyClosedException extends ShutdownSignalException {
8+
public AlreadyClosedException(String s, Object ref)
9+
{
10+
super(true, true, s, ref);
11+
}
12+
}

src/com/rabbitmq/client/Channel.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
/**
3636
* Public API: Interface to an AMQ channel. See the <a href="http://www.amqp.org/">spec</a> for details.
37-
*
37+
*
3838
* <p>
3939
* To open a channel,
4040
* <pre>
@@ -49,14 +49,14 @@
4949
* <li> close
5050
* </ul>
5151
* <p>
52-
*
53-
* While a Channel can be used by multiple threads, it's important to ensure
52+
*
53+
* While a Channel can be used by multiple threads, it's important to ensure
5454
* that only one thread executes a command at once. Concurrent execution of
5555
* commands will likely cause an UnexpectedFrameError to be thrown.
56-
*
56+
*
5757
*/
5858

59-
public interface Channel {
59+
public interface Channel extends ShutdownNotifier{
6060
/**
6161
* Retrieve this channel's channel number.
6262
* @return the channel number
@@ -77,22 +77,22 @@ public interface Channel {
7777
*/
7878
void close(int closeCode, String closeMessage) throws IOException;
7979

80-
/**
80+
/**
8181
* Return the current {@link ReturnListener}.
82-
* @return an interface to the current return listener
82+
* @return an interface to the current return listener
8383
*/
8484
ReturnListener getReturnListener();
8585

8686
/**
87-
* Set the current {@link ReturnListener}.
87+
* Set the current {@link ReturnListener}.
8888
* @param listener the listener to use, or null indicating "don't use one".
8989
*/
9090
void setReturnListener(ReturnListener listener);
9191

9292
/**
9393
* Request a non-exclusive access ticket for the specified realm.
9494
* The access ticket is valid within the current channel and for the lifespan of the channel.
95-
*
95+
*
9696
* @see com.rabbitmq.client.AMQP.Access.Request
9797
* @param realm the name of the realm
9898
* @return a valid access ticket
@@ -330,7 +330,7 @@ Queue.DeclareOk queueDeclare(int ticket, String queue, boolean passive, boolean
330330
* containing the received message being acknowledged.
331331
* @see com.rabbitmq.client.AMQP.Basic.Ack
332332
* @param deliveryTag the tag from the received {@link com.rabbitmq.client.AMQP.Basic.GetOk} or {@link com.rabbitmq.client.AMQP.Basic.Deliver}
333-
* @param multiple true if we are acknowledging multiple messages with the same delivery tag
333+
* @param multiple true if we are acknowledging multiple messages with the same delivery tag
334334
* @throws java.io.IOException if an error is encountered
335335
*/
336336
void basicAck(long deliveryTag, boolean multiple) throws IOException;

src/com/rabbitmq/client/Connection.java

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* Public API: Interface to an AMQ connection. See the see the <a href="http://www.amqp.org/">spec</a> for details.
3131
* <p>
3232
* To connect to a broker, fill in a {@link ConnectionParameters} and use a {@link ConnectionFactory} as follows:
33-
*
33+
*
3434
* <pre>
3535
* ConnectionParameters params = new ConnectionParameters();
3636
* params.setUsername(userName);
@@ -41,15 +41,15 @@
4141
* Connection conn = factory.newConnection(hostName, AMQP.PROTOCOL.PORT);
4242
*
4343
* // Then open a channel and retrieve an access ticket:
44-
*
44+
*
4545
* Channel channel = conn.createChannel();
4646
* int ticket = channel.accessRequest(realmName);
4747
* </pre>
4848
*
4949
* Current implementations are thread-safe for code at the client API level,
5050
* and in fact thread-safe internally except for code within RPC calls.
5151
*/
52-
public interface Connection { // rename to AMQPConnection later, this is a temporary name
52+
public interface Connection extends ShutdownNotifier { // rename to AMQPConnection later, this is a temporary name
5353
/**
5454
* Retrieve the host.
5555
* @return the hostname of the peer we're connected to.
@@ -104,7 +104,7 @@ public interface Connection { // rename to AMQPConnection later, this is a tempo
104104
* @return an array of addresses for all hosts that came back in the initial {@link com.rabbitmq.client.AMQP.Connection.OpenOk} open-ok method
105105
*/
106106
Address[] getKnownHosts();
107-
107+
108108
/**
109109
* Create a new channel, using an internally allocated channel number.
110110
* @return a new channel descriptor, or null if none is available
@@ -119,12 +119,46 @@ public interface Connection { // rename to AMQPConnection later, this is a tempo
119119
* @throws IOException if an I/O problem is encountered
120120
*/
121121
Channel createChannel(int channelNumber) throws IOException;
122-
122+
123+
/**
124+
* Close this connection and all its channels.
125+
*
126+
* This method will wait infinitely for all the close operations to
127+
* complete.
128+
*
129+
* @throws IOException if an I/O problem is encountered
130+
*/
131+
void close() throws IOException;
132+
123133
/**
124-
* Close this connection with the given code and message.
125-
* @param closeCode code indicating the reason for closing the connection - see AMQP spec for a list of codes
126-
* @param closeMessage optional message describing the reason for closing the connection
134+
* Close this connection and all its channels
135+
*
136+
* This method will wait with the given timeout for all the close
137+
* operations to complete. If timeout is reached then socket is forced
138+
* to close
139+
* @param timeout timeout (in milioseconds) for completing all the close-related
140+
* operations, use -1 for infinity
127141
* @throws IOException if an I/O problem is encountered
128142
*/
129-
void close(int closeCode, String closeMessage) throws IOException;
143+
void close(int timeout) throws IOException;
144+
145+
/**
146+
* Abort this connection and all its channels.
147+
*
148+
* This method will force the connection to close. It will silently discard
149+
* any exceptions enountered in close operations
150+
*/
151+
void abort();
152+
153+
/**
154+
* Abort this connection and all its channels.
155+
*
156+
* This method behaves in a similar way as abort(), with the only difference
157+
* that it will wait with a provided timeout for all the close operations to
158+
* complete. If timeout is reached socket is forced to close.
159+
*
160+
* @param timeout timeout (in miliseconds) for completing all the close-related
161+
* operations, use -1 for infinity
162+
*/
163+
void abort(int timeout);
130164
}

src/com/rabbitmq/client/ConnectionParameters.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private static String safeGetProperty(String key, String def) {
5959
/** Default value for desired heartbeat interval; zero for none */
6060
public static final int DEFAULT_HEARTBEAT = 3;
6161

62-
/**
62+
/**
6363
* Default value for suppressAccessRequest flag. Retrieved from
6464
* system property
6565
* "com.rabbitmq.client.ConnectionParameters.suppressAccessRequest"
@@ -112,7 +112,7 @@ public String getPassword() {
112112
public void setPassword(String password) {
113113
_password = password;
114114
}
115-
115+
116116
/**
117117
* Retrieve the virtual host.
118118
* @return the virtual host to use when connecting to the broker
@@ -188,7 +188,7 @@ public boolean getSuppressAccessRequest() {
188188

189189
/**
190190
* Enable or disable the suppression of sending "access.request"
191-
* methods.
191+
* methods.
192192
* @param suppressAccessRequest true of "access.request" methods are suppressed, false otherwise.
193193
*/
194194
public void setSuppressAccessRequest(boolean suppressAccessRequest) {

src/com/rabbitmq/client/ContentHeader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*/
3131

3232
public interface ContentHeader {
33-
/**
33+
/**
3434
* Retrieve the class ID (see the spec for a list of allowable IDs).
3535
* @return class ID of this ContentHeader. Properly an unsigned short, i.e. only the lowest 16 bits are significant
3636
*/

src/com/rabbitmq/client/GetResponse.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
/**
3030
* Encapsulates the response from a {@link Channel#basicGet} message-retrieval method call
31-
* - essentially a static bean "holder" with message response data.
31+
* - essentially a static bean "holder" with message response data.
3232
*/
3333
public class GetResponse {
3434
private final Envelope envelope;
@@ -44,11 +44,11 @@ public class GetResponse {
4444
* @param messageCount the number of messages in the response
4545
*/
4646
public GetResponse(Envelope envelope, BasicProperties props, byte[] body, int messageCount)
47-
{
48-
this.envelope = envelope;
49-
this.props = props;
50-
this.body = body;
51-
this.messageCount = messageCount;
47+
{
48+
this.envelope = envelope;
49+
this.props = props;
50+
this.body = body;
51+
this.messageCount = messageCount;
5252
}
5353

5454
/**

0 commit comments

Comments
 (0)