ElasticsearchClient Java Circuit Breaker errors and retries


Using ElasticsearchClient (co.elastic, not RHLC), I have a bulkrequest inserting data. When it fails due to circuit breaker exceptions, I would like to implement some kind of retry.

Currently I simply iterate over the errors, log them and lose the data.

final boolean hasFailures = bulkResponse.errors();
if (hasFailures) {
	for (final var bulkItemResponse : bulkResponse.items()) {
		final var error = bulkItemResponse.error();
		if (error != null) {
			final var failure = error.reason();
			LOGGER.error("Failed: {}", failure);

Some questions:

  1. Is there some kind of auto retries implementation in ElasticsearchClient? (Getting started | Elasticsearch Java API Client [8.11] | Elastic). If so, can you please provide link to some example code.
  2. If not, how do I distinguish between errors and process only circuit breaker errors? I think BulkResponseItem and ErrorCause seem to only have String data of the error.
  3. I would like to test this but having problems emulating such a circuit breaker issue as I saw in production. How can I deliberately cause Elasticsearch to fail with circuit breaker. When I change indices.breaker.request.limit or indices.breaker.total.limit I get a general runtime exception, and not an error in the items that I iterate over as seen above.


This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.