Skip to content

Commit 5f279fc

Browse files
committed
More Javadoc
1 parent fc54b74 commit 5f279fc

File tree

8 files changed

+126
-6
lines changed

8 files changed

+126
-6
lines changed

src/main/java/com/rabbitmq/client/amqp/Address.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import java.util.Objects;
2121

22+
/** Utility class to represent a hostname and a port. */
2223
public class Address {
2324

2425
private final String host;

src/main/java/com/rabbitmq/client/amqp/AddressBuilder.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,35 @@
1717
// info@rabbitmq.com.
1818
package com.rabbitmq.client.amqp;
1919

20+
/**
21+
* Builder for a <a href="https://www.rabbitmq.com/docs/next/amqp#address-v2">AMQP target address
22+
* format v2.</a>
23+
*
24+
* @param <T> the type of object returned by methods, usually the object itself
25+
*/
2026
public interface AddressBuilder<T> {
2127

28+
/**
29+
* Set the exchange.
30+
*
31+
* @param exchange exchange
32+
* @return type-parameter object
33+
*/
2234
T exchange(String exchange);
2335

36+
/**
37+
* Set the routing key.
38+
*
39+
* @param key routing key
40+
* @return type-parameter object
41+
*/
2442
T key(String key);
2543

44+
/**
45+
* Set the queue.
46+
*
47+
* @param queue queue
48+
* @return type-parameter object
49+
*/
2650
T queue(String queue);
2751
}

src/main/java/com/rabbitmq/client/amqp/AmqpException.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// info@rabbitmq.com.
1818
package com.rabbitmq.client.amqp;
1919

20+
/** Exception classes. */
2021
public class AmqpException extends RuntimeException {
2122

2223
public AmqpException(Throwable cause) {
@@ -38,6 +39,7 @@ public AmqpConnectionException(String message, Throwable cause) {
3839
}
3940
}
4041

42+
/** Exception related to security (authentication, permission, etc). */
4143
public static class AmqpSecurityException extends AmqpException {
4244

4345
public AmqpSecurityException(String message, Throwable cause) {
@@ -60,6 +62,11 @@ public AmqpEntityDoesNotExistException(String message) {
6062
}
6163
}
6264

65+
/**
66+
* Exception when a resource is not in an appropriate state.
67+
*
68+
* <p>An example is a connection that is initializing.
69+
*/
6370
public static class AmqpResourceInvalidStateException extends AmqpException {
6471

6572
public AmqpResourceInvalidStateException(String format, Object... args) {
@@ -71,6 +78,7 @@ public AmqpResourceInvalidStateException(String message, Throwable cause) {
7178
}
7279
}
7380

81+
/** Exception when a resource is not usable because it is closed. */
7482
public static class AmqpResourceClosedException extends AmqpResourceInvalidStateException {
7583

7684
public AmqpResourceClosedException(String message) {

src/main/java/com/rabbitmq/client/amqp/BackOffDelayPolicy.java

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,59 @@
1919

2020
import java.time.Duration;
2121

22+
/**
23+
* Contract to determine a delay between attempts of some task.
24+
*
25+
* <p>The task is typically the creation of a connection.
26+
*/
2227
public interface BackOffDelayPolicy {
2328

2429
Duration TIMEOUT = Duration.ofMillis(Long.MAX_VALUE);
2530

31+
/**
32+
* Returns the delay to use for a given attempt.
33+
*
34+
* <p>The policy can return the TIMEOUT constant to indicate that the task has reached a timeout.
35+
*
36+
* @param recoveryAttempt number of the recovery attempt
37+
* @return the delay, TIMEOUT if the task should stop being retried
38+
*/
2639
Duration delay(int recoveryAttempt);
2740

41+
/**
42+
* Policy with a fixed delay.
43+
*
44+
* @param delay the fixed delay
45+
* @return fixed-delay policy
46+
*/
47+
static BackOffDelayPolicy fixed(Duration delay) {
48+
return new FixedWithInitialDelayBackOffPolicy(delay, delay);
49+
}
50+
51+
/**
52+
* Policy with an initial delay for the first attempt, then a fixed delay.
53+
*
54+
* @param initialDelay delay for the first attempt
55+
* @param delay delay for other attempts than the first one
56+
* @return fixed-delay policy with initial delay
57+
*/
2858
static BackOffDelayPolicy fixedWithInitialDelay(Duration initialDelay, Duration delay) {
2959
return new FixedWithInitialDelayBackOffPolicy(initialDelay, delay);
3060
}
3161

62+
/**
63+
* Policy with an initial delay for the first attempt, then a fixed delay, and a timeout.
64+
*
65+
* @param initialDelay delay for the first attempt
66+
* @param delay delay for other attempts than the first one
67+
* @param timeout timeout
68+
* @return fixed-delay policy with initial delay and timeout
69+
*/
3270
static BackOffDelayPolicy fixedWithInitialDelay(
3371
Duration initialDelay, Duration delay, Duration timeout) {
3472
return new FixedWithInitialDelayAndTimeoutBackOffPolicy(initialDelay, delay, timeout);
3573
}
3674

37-
static BackOffDelayPolicy fixed(Duration delay) {
38-
return new FixedWithInitialDelayBackOffPolicy(delay, delay);
39-
}
40-
4175
final class FixedWithInitialDelayBackOffPolicy implements BackOffDelayPolicy {
4276

4377
private final Duration initialDelay;

src/main/java/com/rabbitmq/client/amqp/ConnectionSettings.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ public interface ConnectionSettings<T> {
128128
/**
129129
* SASL mechanism to use.
130130
*
131+
* <p>Supported mechanisms are {@link #SASL_MECHANISM_ANONYMOUS}, {@link #SASL_MECHANISM_PLAIN},
132+
* and {@link #SASL_MECHANISM_EXTERNAL}.
133+
*
131134
* @param mechanism SASL mechanism
132135
* @return type-parameter object
133136
* @see <a href="https://www.rabbitmq.com/docs/access-control#mechanisms">RabbitMQ Authentication
@@ -225,9 +228,9 @@ interface Affinity<T> {
225228
/**
226229
* The type of operation to look affinity with.
227230
*
228-
* <p>PUBLISH will favor the node with the queue leader on it.
231+
* <p>{@link Operation#PUBLISH} will favor the node with the queue leader on it.
229232
*
230-
* <p>CONSUME will favor a node with a queue member (replica) on it.
233+
* <p>{@link Operation#CONSUME} will favor a node with a queue member (replica) on it.
231234
*
232235
* @param operation type of operation
233236
* @return affinity settings

src/main/java/com/rabbitmq/client/amqp/Consumer.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,70 @@
1717
// info@rabbitmq.com.
1818
package com.rabbitmq.client.amqp;
1919

20+
/**
21+
* API to consume messages from a RabbitMQ queue.
22+
*
23+
* <p>Instances are configured and created with a {@link ConsumerBuilder}.
24+
*
25+
* @see Connection#consumerBuilder()
26+
* @see ConsumerBuilder
27+
*/
2028
public interface Consumer extends AutoCloseable {
2129

30+
/** Pause the consumer to stop receiving messages. */
2231
void pause();
2332

33+
/**
34+
* Return the number of unsettled messages.
35+
*
36+
* @return unsettled message count
37+
*/
2438
long unsettledMessageCount();
2539

40+
/** Request to receive messages again. */
2641
void unpause();
2742

43+
/** Close the consumer with its resources. */
2844
@Override
2945
void close();
3046

47+
/** Contract to process a message. */
3148
@FunctionalInterface
3249
interface MessageHandler {
3350

51+
/**
52+
* Process a message
53+
*
54+
* @param context message context
55+
* @param message message
56+
*/
3457
void handle(Context context, Message message);
3558
}
3659

60+
/** Context for message processing. */
3761
interface Context {
3862

63+
/**
64+
* Accept the message (AMQP 1.0 <code>accepted</code> outcome).
65+
*
66+
* <p>This means the message has been processed and the broker can delete it.
67+
*/
3968
void accept();
4069

70+
/**
71+
* Discard the message (AMQP 1.0 <code>rejected</code> outcome).
72+
*
73+
* <p>This means the message cannot be processed because it is invalid, the broker can drop it
74+
* or dead-letter it if it is configured.
75+
*/
4176
void discard();
4277

78+
/**
79+
* Requeue the message (AMQP 1.0 <code>released</code> outcome).
80+
*
81+
* <p>This means the message has not been processed and the broker can requeue it and deliver it
82+
* to the same or a different consumer.
83+
*/
4384
void requeue();
4485
}
4586
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* Implementation package.
3+
*
4+
* <p>Only the {@link com.rabbitmq.client.amqp.impl.AmqpEnvironmentBuilder} is public and should be
5+
* used by applications.
6+
*/
7+
package com.rabbitmq.client.amqp.impl;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/** Main API for the RabbitMQ AMQP 1.0 Java Client. */
2+
package com.rabbitmq.client.amqp;

0 commit comments

Comments
 (0)