Skip to content

Commit 5862193

Browse files
committed
Polish subscription listener documentation
References #38
1 parent ee5465a commit 5862193

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/docs/asciidoc/api.adoc

+8-8
Original file line numberDiff line numberDiff line change
@@ -884,9 +884,9 @@ no guarantee to be contiguous, the operation may not happen exactly every X mess
884884

885885
====== Subscription Listener
886886

887-
The library provides a `SubscriptionListener` interface callback to add behavior before a subscription is created.
888-
This callback can be used to customize the offset the library computed for the subscription.
889-
The callback is called when the consumer is first created and when the library has to re-subscribe (e.g. after a disconnection or a topology change).
887+
The client provides a `SubscriptionListener` interface callback to add behavior before a subscription is created.
888+
This callback can be used to customize the offset the client computed for the subscription.
889+
The callback is called when the consumer is first created and when the client has to re-subscribe (e.g. after a disconnection or a topology change).
890890

891891
It is possible to use the callback to get the last processed offset from an external store, that is not using the server-side offset tracking feature RabbitMQ Stream provides.
892892
The following code snippet shows how this can be done (note the interaction with the external store is not detailed):
@@ -903,8 +903,8 @@ include::{test-examples}/ConsumerUsage.java[tag=subscription-listener]
903903

904904
When using an external store for offset tracking, it is no longer necessary to set a name and an offset strategy, as these only apply when server-side offset tracking is in use.
905905

906-
Using a subscription listener can be useful to have more accurate offset tracking on re-subscription, at the cost of making the application code slightly more complex.
907-
This requires a good understanding on how and when subscription occurs in the library, and so when the subscription listener is called:
906+
Using a subscription listener can also be useful to have more accurate offset tracking on re-subscription, at the cost of making the application code slightly more complex.
907+
This requires a good understanding on how and when subscription occurs in the client, and so when the subscription listener is called:
908908

909909
* for a consumer with no name (server-side offset tracking _disabled_)
910910
** on the first subscription (when the consumer is created): the offset specification is the one specified with `ConsumerBuilder#offset(OffsetSpecification)`, the default being `OffsetSpecification#next()`
@@ -915,9 +915,9 @@ This requires a good understanding on how and when subscription occurs in the li
915915

916916
The subscription listener comes in handy on re-subscription.
917917
The application can track the last processed offset in-memory, with an `AtomicLong` for example.
918-
The application knows exactly when a message is processed and updates its in-memory tracking accordingly, whereas the value computed by the library may not be perfectly appropriate on re-subscription.
918+
The application knows exactly when a message is processed and updates its in-memory tracking accordingly, whereas the value computed by the client may not be perfectly appropriate on re-subscription.
919919

920-
If we take the example of a named consumer with an offset tracking strategy that is lagging because of bad timing and a long flush interval.
921-
When the glitch happens and triggers the re-subscription, the server-side stored offset can be quite behind what the application actually processed.
920+
Let's take the example of a named consumer with an offset tracking strategy that is lagging because of bad timing and a long flush interval.
921+
When a glitch happens and triggers the re-subscription, the server-side stored offset can be quite behind what the application actually processed.
922922
Using this server-side stored offset can lead to duplicates, whereas using the in-memory, application-specific offset tracking variable is more accurate.
923923
A custom `SubscriptionListener` lets the application developer uses what's best for the application if the computed value is not optimal.

0 commit comments

Comments
 (0)