Skip to content

Commit 48d38ae

Browse files
committed
Documentation editing
1 parent 80fa1fa commit 48d38ae

File tree

3 files changed

+74
-98
lines changed

3 files changed

+74
-98
lines changed

src/docs/asciidoc/api.adoc

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
=== Overview
77

8-
This section describes the API to connect to the RabbitMQ Stream Plugin, publish messages, and
9-
consume messages. There are 3 main interfaces:
8+
This section covers the API for connecting to the RabbitMQ Stream Plugin and working with messages.
9+
The API provides three main interfaces:
1010

1111
* `com.rabbitmq.stream.Environment` for connecting to a node and optionally
1212
managing streams.
@@ -17,9 +17,9 @@ managing streams.
1717

1818
==== Creating the Environment
1919

20-
The environment is the main entry point to a node or a cluster of nodes. `Producer` and
21-
`Consumer` instances are created from an `Environment` instance. Here is the simplest
22-
way to create an `Environment` instance:
20+
The environment serves as the main entry point to a node or a cluster of nodes.
21+
`Producer` and `Consumer` instances are created from an `Environment` instance.
22+
Here is the simplest way to create an `Environment` instance:
2323

2424
.Creating an environment with all the defaults
2525
[source,java,indent=0]
@@ -29,11 +29,10 @@ include::{test-examples}/EnvironmentUsage.java[tag=environment-creation]
2929
<1> Create an environment that will connect to localhost:5552
3030
<2> Close the environment after usage
3131

32-
Note the environment must be closed to release resources when it is no
33-
longer needed.
32+
Always close the environment to release resources when finished.
3433

35-
Consider the environment like a long-lived object. An application will usually
36-
create one `Environment` instance when it starts up and close it when it exits.
34+
Treat the environment as a long-lived object.
35+
An application will usually create one `Environment` instance when it starts up and close it when it exits.
3736

3837
It is possible to use a URI to specify all the necessary information to
3938
connect to a node:
@@ -52,10 +51,11 @@ https://www.rabbitmq.com/uri-spec.html[AMQP 0.9.1 URI],
5251
except the protocol must be `rabbitmq-stream`.
5352
<<enabling-tls,TLS is enabled>> by using the `rabbitmq-stream+tls` scheme in the URI.
5453

55-
When using one URI, the corresponding node will be the main entry point to connect to. The
56-
`Environment` will then use the stream protocol to find out more about streams topology
57-
(leaders and replicas) when asked to create `Producer` and `Consumer` instances.
58-
The `Environment` may become blind if this node goes down though, so it may be more appropriate to specify several other URIs to try in case of failure of a node:
54+
When using one URI, the corresponding node will be the main entry point to connect to.
55+
The `Environment` will then use the stream protocol to find out more about streams topology (leaders and replicas) when asked to create `Producer` and `Consumer` instances.
56+
57+
If this node fails, the `Environment` will lose connectivity.
58+
To improve resilience, specify multiple URIs as fallback options:
5959

6060
.Creating an environment with several URIs
6161
[source,java,indent=0]
@@ -70,11 +70,11 @@ will pick a new URI randomly in case of disconnection.
7070
[[understanding-connection-logic]]
7171
==== Understanding Connection Logic
7272

73-
Creating the environment to connect to a cluster node works usually seamlessly.
74-
Creating publishers and consumers can cause problems as the client uses hints from the cluster to find the nodes where stream leaders and replicas are located to connect to the appropriate nodes.
73+
Creating the environment to connect to a cluster node usually works seamlessly.
74+
Creating publishers and consumers may encounter connection issues because the client relies on cluster hints to locate stream leaders and replicas.
7575

7676
These connection hints can be accurate or less appropriate depending on the infrastructure.
77-
If you hit connection problems at some point – like hostnames impossible to resolve for client applications - this https://www.rabbitmq.com/blog/2021/07/23/connecting-to-streams[blog post] should help you understand what is going on and fix the issues.
77+
If you encounter connection problems (such as unresolvable hostnames), this https://www.rabbitmq.com/blog/2021/07/23/connecting-to-streams[blog post] explains the root causes and solutions.
7878
Setting the `advertised_host` and `advertised_port` https://www.rabbitmq.com/blog/2021/07/23/connecting-to-streams#advertised-host-and-port[configuration entries] should solve the most common connection problems.
7979

8080
To make the local development experience simple, the client library can choose to always use `localhost` for producers and consumers.
@@ -403,9 +403,8 @@ include::{test-examples}/ProducerUsage.java[tag=producer-creation]
403403
<3> Create the producer instance with `build()`
404404
<4> Close the producer after usage
405405

406-
Consider a `Producer` instance like a long-lived object, do not create one
407-
to send just one message.
408-
406+
Treat `Producer` instances as long-lived objects.
407+
Avoid creating a producer for single-message operations.
409408

410409
[NOTE]
411410
.Producer thread safety
@@ -499,9 +498,7 @@ include::{test-examples}/ProducerUsage.java[tag=producer-publish]
499498
<2> Create the message with `Producer#messageBuilder()`
500499
<3> Define the behavior on publish confirmation
501500

502-
Messages are not only made of a `byte[]` payload, we will see in
503-
<<working-with-complex-messages,the next section>>
504-
they can also carry pre-defined and application properties.
501+
Messages are not only made of a `byte[]` payload, as shown in <<working-with-complex-messages,the next section>> they can also carry pre-defined and application properties.
505502

506503
[NOTE]
507504
.Use a `MessageBuilder` instance only once
@@ -511,11 +508,8 @@ need to create a new instance of `MessageBuilder` for every message
511508
you want to create.
512509
====
513510

514-
The `ConfirmationHandler` defines an asynchronous callback invoked
515-
when the client received from the broker the confirmation the message
516-
has been taken into account. The `ConfirmationHandler` is the place
517-
for any logic on publishing confirmation, including
518-
re-publishing the message if it is negatively acknowledged.
511+
The `ConfirmationHandler` defines an asynchronous callback invoked when the broker confirms message receipt.
512+
The `ConfirmationHandler` is the place for any logic on publishing confirmation, including re-publishing the message if it is negatively acknowledged.
519513

520514
[WARNING]
521515
.Keep the confirmation callback as short as possible
@@ -532,7 +526,7 @@ a separate thread (e.g. with an asynchronous `ExecutorService`).
532526

533527
The publishing example above showed that messages are made of
534528
a byte array payload, but it did not go much further. Messages in RabbitMQ Stream
535-
can actually be more sophisticated, as they comply to the
529+
can actually be more sophisticated, as they comply with the
536530
https://www.amqp.org/resources/specifications[AMQP 1.0 message format].
537531

538532
In a nutshell, a message in RabbitMQ Stream has the following structure:
@@ -594,12 +588,12 @@ on 2 client-side elements: the _producer name_ and the _message publishing ID_.
594588

595589
[[deduplication-multithreading]]
596590
[WARNING]
597-
.Only one publisher instance with a given name and no multithreading to guarantee deduplication
591+
.Deduplication Requirements: Single Publisher Instance and Single Thread
598592
====
599593
We'll see below that deduplication works using a strictly increasing sequence for messages.
600594
This means messages must be published in order, so there must be only _one publisher instance with a given name_ and this instance must publish messages _within a single thread_.
601595
602-
With several publisher instances with the same name, one instance can be "ahead" of the others for the sequence ID: if it publishes a message with sequence ID 100, any message from any instance with a smaller lower sequence ID will be filtered out.
596+
With several publisher instances with the same name, one instance can be "ahead" of the others for the sequence ID: if it publishes a message with sequence ID 100, any message from any instance with a lower sequence ID will be filtered out.
603597
604598
If there is only one publisher instance with a given name, it should publish messages in a single thread.
605599
Even if messages are _created_ in order, with the proper sequence ID, they can get out of order if they are published in several threads, e.g. message 5 can be _published_ before message 2.
@@ -612,11 +606,8 @@ If you worry about performance, note it is possible to publish hundreds of thous
612606
[WARNING]
613607
.Deduplication is not guaranteed when using sub-entries batching
614608
====
615-
It is not possible to guarantee deduplication when
616-
<<sub-entry-batching-and-compression, sub-entry batching>> is in use.
617-
Sub-entry batching is disabled by default and it does not prevent from
618-
batching messages in a single publish frame, which can already provide
619-
very high throughput.
609+
It is not possible to guarantee deduplication when <<sub-entry-batching-and-compression, sub-entry batching>> is in use.
610+
Sub-entry batching is disabled by default and it does not prevent batching messages in a single publish frame, which can already provide very high throughput.
620611
====
621612

622613
===== Setting the Name of a Producer
@@ -820,7 +811,7 @@ include::{test-examples}/ConsumerUsage.java[tag=producer-creation]
820811
<5> Build the consumer
821812
<6> Close consumer after usage
822813

823-
The broker start sending messages as soon as the `Consumer` instance is created.
814+
The broker starts sending messages as soon as the `Consumer` instance is created.
824815

825816
[WARNING]
826817
.The message processing callback can take its time, but not too much
@@ -962,7 +953,7 @@ made of 2 chunks:
962953
....
963954

964955
Each chunk contains a timestamp of its creation time.
965-
This is this timestamp the broker uses to find the appropriate chunk to start from when using a timestamp specification.
956+
The broker uses this timestamp to find the appropriate chunk to start from when using a timestamp specification.
966957
The broker chooses the closest chunk _before_ the specified timestamp, that is why consumers may see messages published a bit before what they specified.
967958

968959
[[consumer-offset-tracking]]
@@ -1037,7 +1028,7 @@ manual tracking.
10371028
[[consumer-manual-offset-tracking]]
10381029
===== Manual Offset Tracking
10391030

1040-
The manual tracking strategy lets the developer in charge of storing offsets
1031+
The manual tracking strategy gives the developer control of storing offsets
10411032
whenever they want, not only after a given number of messages has been received
10421033
and supposedly processed, like automatic tracking does.
10431034

@@ -1082,7 +1073,7 @@ make the stream grow unnecessarily, as the broker persists offset
10821073
tracking entries in the stream itself.
10831074

10841075
A good rule of thumb is to store the offset every few thousands
1085-
of messages. Of course, when the consumer will restart consuming in a new incarnation, the
1076+
of messages. Of course, when the consumer restarts consuming in a new incarnation, the
10861077
last tracked offset may be a little behind the very last message the previous incarnation
10871078
actually processed, so the consumer may see some messages that have been already processed.
10881079

@@ -1091,8 +1082,9 @@ last duplicated messages.
10911082

10921083
'''
10931084

1094-
_Is the offset a reliable absolute value?_ Message offsets may not be contiguous.
1095-
This implies that the message at offset 500 in a stream may
1085+
_Is the offset a reliable absolute value?_
1086+
Message offsets may not be contiguous.
1087+
This means the message at offset 500 in a stream may
10961088
not be the 501 message in the stream (offsets start at 0).
10971089
There can be different types of entries in a stream storage, a message is
10981090
just one of them. For example, storing an offset creates an offset tracking

src/docs/asciidoc/index.adoc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@ ifndef::imagesdir[:imagesdir: images]
66
ifndef::sourcedir[:sourcedir: ../../main/java]
77
:source-highlighter: prettify
88

9-
The RabbitMQ Stream Java Client is a Java library to communicate with
10-
the https://rabbitmq.com/stream.html[RabbitMQ Stream Plugin].
11-
It allows creating and deleting streams, as well as publishing to and consuming from
12-
these streams. Learn more in the <<overview.adoc#stream-client-overview,client overview>>.
9+
The RabbitMQ Stream Java Client is a Java library for communicating with the https://rabbitmq.com/stream.html[RabbitMQ Stream Plugin].
10+
Use it to create and delete streams, publish messages, and consume from streams.
11+
Learn more in the <<overview.adoc#stream-client-overview,client overview>>.
1312

1413
This library requires at least Java 11, but Java 21 or more is recommended.
1514

1615
https://github.com/rabbitmq/rabbitmq-stream-perf-test[Stream PerfTest] is a performance testing tool based on this client library.
1716

18-
1917
include::overview.adoc[]
2018

2119
include::setup.adoc[]
@@ -30,4 +28,4 @@ include::advanced-topics.adoc[]
3028

3129
include::building.adoc[]
3230

33-
include::appendixes.adoc[]
31+
include::appendixes.adoc[]

0 commit comments

Comments
 (0)