Hi Adam, On Mon, Mar 13, 2023 at 2:24 PM Adam Brenner via users < users@pulsar.apache.org> wrote:
> Hello, > > I have a few questions regarding Pulsar Async mode and what, if any, > guarantees are made with respect to packet ordering: > > 1) Does Pulsar offer any guarantee packet ordering in Async send mode? > Let us assume best case with single producer and exclusive access mode. > Yes, messages are guaranteed to be sent in order in both sync & async mode. > > 2) Does the client library do any coordination with Pulsar Broker to > guarantee packet ordering in async send mode? > In case of failures, the client library ensures that all messages pending in the producer queue are resent in the same order. This could lead to a sequence of dups, (unless the exactly once mode is enabled), though you wouldn't see a message out of order. NOTE: to have a 100% guarantee you need to disable publish timeout (sendTimeout=0). This is mostly to ease you application code. In the presence of a timeout, Pulsar client guarantees anyway that any message present in the queue will also fail, even if not all of them have already timed out. The application though could be already trying to publish the next message. Unless there's proper synchronization. For that, the easier way is to disable timeouts and let the Pulsar client retrying until a successful publish. > > 3) Would using batch mode with async send mode help in any way to > guaranteed packet ordering? > Batching will improve the throughput and the overall efficiency, less CPU usage, and better compression ratio, though it doesn't affect ordering. -- Matteo Merli <mme...@apache.org>