Pulsar支持参数配置重试次数吗?

不支持。Pulsar 按照时间来进行退避重试策略,和重试次数机制类似。客户端内部的重试策略是用的退避(backoff)机制,可以配置 ClientBuilder 的 backoff 参数来控制。

/**
 * Set the duration of time for a backoff interval.
 *
 * @param duration the duration of the interval
 * @param unit the time unit in which the duration is defined
 * @return the client builder instance
 */
ClientBuilder startingBackoffInterval(long duration, TimeUnit unit);

/**
 * Set the maximum duration of time for a backoff interval.
 *
 * @param duration the duration of the interval
 * @param unit the time unit in which the duration is defined
 * @return the client builder instance
 */
ClientBuilder maxBackoffInterval(long duration, TimeUnit unit);

从生产者的角度,可以在 ProducerBuilder 中配置总的 send timeout。

/**
 * Set the send timeout <i>(default: 30 seconds)</i>.
 *
 * <p>If a message is not acknowledged by the server before the sendTimeout expires, an error will be reported.
 *
 * <p>Setting the timeout to zero, for example {@code setTimeout(0, TimeUnit.SECONDS)} will set the timeout
 * to infinity, which can be useful when using Pulsar's message deduplication feature, since the client
 * library will retry forever to publish a message. No errors will be propagated back to the application.
 *
 * @param sendTimeout
 *            the send timeout
 * @param unit
 *            the time unit of the {@code sendTimeout}
 * @return the producer builder instance
 */
ProducerBuilder<T> sendTimeout(int sendTimeout, TimeUnit unit)