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.
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:
- 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.
- If not, how do I distinguish between errors and process only circuit breaker errors? I think
BulkResponseItem
andErrorCause
seem to only have String data of the error. - 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
orindices.breaker.total.limit
I get a general runtime exception, and not an error in the items that I iterate over as seen above.
Thanks.