You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/docs/asciidoc/api.adoc
+8-8
Original file line number
Diff line number
Diff line change
@@ -884,9 +884,9 @@ no guarantee to be contiguous, the operation may not happen exactly every X mess
884
884
885
885
====== Subscription Listener
886
886
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).
890
890
891
891
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.
892
892
The following code snippet shows how this can be done (note the interaction with the external store is not detailed):
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.
905
905
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:
908
908
909
909
* for a consumer with no name (server-side offset tracking _disabled_)
910
910
** 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
915
915
916
916
The subscription listener comes in handy on re-subscription.
917
917
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.
919
919
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.
922
922
Using this server-side stored offset can lead to duplicates, whereas using the in-memory, application-specific offset tracking variable is more accurate.
923
923
A custom `SubscriptionListener` lets the application developer uses what's best for the application if the computed value is not optimal.
0 commit comments