Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>4.2.29</version>
<scope>test</scope>
</dependency>

</dependencies>

<dependencyManagement>
Expand Down Expand Up @@ -490,6 +497,7 @@
<configuration>
<java>
<excludes>
<exclude>src/main/java/com/rabbitmq/client/amqp/impl/FastUtil*.java</exclude>
<exclude>src/test/java/com/rabbitmq/client/amqp/docs/*.java</exclude>
<exclude>src/test/java/SanityCheck.java</exclude>
</excludes>
Expand Down
15 changes: 15 additions & 0 deletions src/docs/asciidoc/usage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ include::{test-examples}/Api.java[tag=connection-settings]
<1> Use the `guest` user by default
<2> Use the `admin` user for this connection

=== Settling Messages in Batch

.Settling messages in batch
[source,java,indent=0]
--------
include::{test-examples}/Api.java[tag=settling-message-in-batch]
--------
<1> Declare batch context property
<2> Create a new batch context instance
<3> Add the current message context to the batch context if processing is successful
<4> Settle the batch context once it contains 10 messages
<5> Reset the batch context
<6> Discard the current message context if processing fails


=== Subscription Listener

The client provides a `SubscriptionListener` interface callback to add behavior before a subscription is created.
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/com/rabbitmq/client/amqp/Consumer.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,45 @@ interface Context {
* in RabbitMQ</a>
*/
void requeue(Map<String, Object> annotations);

/**
* Create a batch context to accumulate message contexts and settle them at once.
*
* <p>The message context the batch context is created from is <b>not</b> added to the batch
* context.
*
* @return the created batch context
*/
BatchContext batch(int batchSizeHint);
}

/**
* Context to accumulate message contexts and settle them at once.
*
* <p>A {@link BatchContext} is also a {@link Context}: the same methods are available to settle
* the messages.
*
* <p>Only "simple" (not batch) message contexts can be added to a batch context. Calling {@link
* Context#batch()} on a batch context returns the instance itself.
*
* @see <a
* href="https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-disposition">AMQP
* 1.0 Disposition performative</a>
*/
interface BatchContext extends Context {

/**
* Add a message context to the batch context.
*
* @param context the message context to add
*/
void add(Context context);

/**
* Get the current number of message contexts in the batch context.
*
* @return current number of message contexts in the batch
*/
int size();
}
}
Loading