Skip to content

Commit d77e2d4

Browse files
authored
GH-2447: Publisher Confirms/Returns Doc Polishing
Resolves #2447
1 parent b117372 commit d77e2d4

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/CorrelationData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -96,7 +96,7 @@ public CompletableFuture<Confirm> getFuture() {
9696

9797
/**
9898
* Get the returned message and metadata, if any. Guaranteed to be populated before
99-
* the future is set.
99+
* the future is completed.
100100
* @return the {@link ReturnedMessage}.
101101
* @since 2.3.3
102102
*/

src/reference/asciidoc/amqp.adoc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ When such a channel is obtained, the client can register a `PublisherCallbackCha
851851
The `PublisherCallbackChannel` implementation contains logic to route a confirm or return to the appropriate listener.
852852
These features are explained further in the following sections.
853853

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

856856
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].
857857

@@ -1278,6 +1278,8 @@ The following example shows how to configure a `CorrelationData` instance:
12781278
CorrelationData cd1 = new CorrelationData();
12791279
this.templateWithConfirmsEnabled.convertAndSend("exchange", queue.getName(), "foo", cd1);
12801280
assertTrue(cd1.getFuture().get(10, TimeUnit.SECONDS).isAck());
1281+
ReturnedMessage = cd1.getReturn();
1282+
...
12811283
----
12821284
====
12831285

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

1289-
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.
1290-
It is guaranteed that the returned message is set before the future is set with the `ack`.
1291+
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.
1292+
It is guaranteed that the returned message property is set before the future is set with the `ack`.
1293+
`CorrelationData.getReturn()` returns a `ReturnMessage` with properties:
1294+
1295+
* message (the returned message)
1296+
* replyCode
1297+
* replyText
1298+
* exchange
1299+
* routingKey
12911300

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

0 commit comments

Comments
 (0)