# ElasticsearchClient Java Circuit Breaker errors and retries

**URL:** <https://discuss.elastic.co/t/elasticsearchclient-java-circuit-breaker-errors-and-retries/347736>\
**Category:** Elasticsearch\
**Tags:** language-clients, runtime-fields\
**Created:** [November 22, 2023, 1:19pm UTC](https://discuss.elastic.co/t/elasticsearchclient-java-circuit-breaker-errors-and-retries/347736 "2023-11-22T13:19:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ewolfman](https://avatars.discourse-cdn.com/v4/letter/e/5f8ce5/32.png) [@ewolfman](https://discuss.elastic.co/u/ewolfman)\
**Post date:** [November 22, 2023, 1:19pm UTC](https://discuss.elastic.co/t/elasticsearchclient-java-circuit-breaker-errors-and-retries/347736/1 "2023-11-22T13:19:14Z")

</div>

Hi,

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.

```auto
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](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/getting-started-java.html)). 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.

Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 20, 2023, 1:20pm UTC](https://discuss.elastic.co/t/elasticsearchclient-java-circuit-breaker-errors-and-retries/347736/2 "2023-12-20T13:20:08Z")

</div>

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