@@ -468,4 +468,36 @@ include::{test-examples}/ApiGuideSender.java[tag=resource-management-options]
468468
469469In the example above, each operation will use the same `Channel` as it is cached.
470470This way these operations won't interfer with any other thread using the default
471- resource management `Mono<Channel>` in the `Sender` instance.
471+ resource management `Mono<Channel>` in the `Sender` instance.
472+
473+ ==== Channel pooling in `Sender`
474+
475+ By default, `Sender#send*` methods open a new `Channel` for every call. This is
476+ OK for long-running calls, e.g. when the flux of outbound messages is
477+ infinite. For workloads whereby `Sender#send*` is called often for finite,
478+ short flux of messages, opening a new `Channel` every time may not be optimal.
479+
480+ It is possible to use a pool of channels as part of the `SendOptions` when
481+ sending outbound messages with `Sender`, as illustrated in the following snippet:
482+
483+ [source,java,indent=0]
484+ -------
485+ include::{test-examples}/ApiGuideSender.java[tag=channel-pool]
486+ -------
487+ <1> Create `ChannelPool` with factory
488+ <2> Set the maximum size to 5 channels
489+ <3> Use a channel from the pool to send messages
490+ <4> Close the pool when no longer needed
491+
492+ Note it is developer's responsibility to close the pool when it is no longer
493+ necessary, typically at application shutdown.
494+
495+ https://github.com/reactor/reactor-rabbitmq/tree/master/src/jmh/java/reactor/rabbitmq[Micro-benchmarks]
496+ revealed channel pooling performs much better for sending short sequence
497+ of messages (1 to 10) repeatedly, without publisher confirms. With longer sequence
498+ of messages (100 or more), channel pooling can perform worse than
499+ without pooling at all. According to the same micro-benchmarks, channel pooling
500+ does not make sending with publisher confirms perform better, it appears to perform
501+ even worse. Don't take these conclusions for granted, you should always make your
502+ own benchmarks depending on your workloads.
503+
0 commit comments