Skip to content

GH-2447: Publisher Confirms/Returns Doc Polishing #2448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2023
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -96,7 +96,7 @@ public CompletableFuture<Confirm> getFuture() {

/**
* Get the returned message and metadata, if any. Guaranteed to be populated before
* the future is set.
* the future is completed.
* @return the {@link ReturnedMessage}.
* @since 2.3.3
*/
Expand Down
15 changes: 12 additions & 3 deletions src/reference/asciidoc/amqp.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ When such a channel is obtained, the client can register a `PublisherCallbackCha
The `PublisherCallbackChannel` implementation contains logic to route a confirm or return to the appropriate listener.
These features are explained further in the following sections.

See also `simplePublisherConfirms` in <<scoped-operations>>.
See also <<template-confirms>> and `simplePublisherConfirms` in <<scoped-operations>>.

TIP: For some more background information, see the blog post by the RabbitMQ team titled https://www.rabbitmq.com/blog/2011/02/10/introducing-publisher-confirms/[Introducing Publisher Confirms].

Expand Down Expand Up @@ -1278,6 +1278,8 @@ The following example shows how to configure a `CorrelationData` instance:
CorrelationData cd1 = new CorrelationData();
this.templateWithConfirmsEnabled.convertAndSend("exchange", queue.getName(), "foo", cd1);
assertTrue(cd1.getFuture().get(10, TimeUnit.SECONDS).isAck());
ReturnedMessage = cd1.getReturn();
...
----
====

Expand All @@ -1286,8 +1288,15 @@ The `Confirm` object is a simple bean with 2 properties: `ack` and `reason` (for
The reason is not populated for broker-generated `nack` instances.
It is populated for `nack` instances generated by the framework (for example, closing the connection while `ack` instances are outstanding).

In addition, when both confirms and returns are enabled, the `CorrelationData` is populated with the returned message, as long as the `CorrelationData` has a unique `id`; this is always the case, by default, starting with version 2.3.
It is guaranteed that the returned message is set before the future is set with the `ack`.
In addition, when both confirms and returns are enabled, the `CorrelationData` `return` property is populated with the returned message, if it couldn't be routed to any queue.
It is guaranteed that the returned message property is set before the future is set with the `ack`.
`CorrelationData.getReturn()` returns a `ReturnMessage` with properties:

* message (the returned message)
* replyCode
* replyText
* exchange
* routingKey

See also <<scoped-operations>> for a simpler mechanism for waiting for publisher confirms.

Expand Down