This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 1a95828a2257 CAMEL-27617: camel-elasticsearch - scroll with
disconnect, cleanup on failure, sniff on failure, no-host start (#30980)
1a95828a2257 is described below
commit 1a95828a2257e0b7cea11df606d1db6d39bb6374
Author: allthingssecurity <[email protected]>
AuthorDate: Sat Nov 28 00:25:38 2026 +0530
CAMEL-27617: camel-elasticsearch - scroll with disconnect, cleanup on
failure, sniff on failure, no-host start (#30980)
1. useScroll with disconnect=true: the producer closed the client right
after
the first search, so the next scroll request and the clear-scroll request
failed while the route read the body. The producer now hands the client
it
created (with its sniffer and transport) to the scroll iterator, which
closes them when it is closed. The next exchange creates a new client.
2. The cleanup now runs when the request fails too (whenComplete) and when
process() throws before the request is sent, such as a body the operation
cannot take. The headers set from the endpoint options are removed and,
with disconnect=true, the client is closed. The context records each
header as it is set, so only the headers set so far are removed.
3. The CamelElasticsearchEnableDocumentOnlyMode header that the producer
sets
from the enableDocumentOnlyMode option is removed by the cleanup, like
the
other headers set from the options. A header set on the message is kept.
4. With enableSniffer, the client now gets a SniffOnFailureListener that
tells the sniffer about failed nodes, so a failure starts a sniff and the
next one runs sniffAfterFailureDelay later, as the option says. Before,
the option had no effect.
5. A producer without hostAddresses and without the client option of the
component now fails to start with a message that names both options,
instead of logging a warning and failing every exchange with a
NullPointerException.
6. The component option certificatePath has supportFileReference, like the
endpoint option; both are loaded with ResourceHelper. The component JSON
and its catalog copy are regenerated.
Tests use a local fake node (JDK HttpServer), like the other unit tests of
the module: ElasticsearchProducerCleanupTest (1, 2, 3),
ElasticsearchProducerSnifferTest (4) and a new test in
ElasticsearchProducerClientLifecycleTest (5).
CAMEL-27617: camel-elasticsearch - review: close the scroll at its end,
upgrade guide entry
1. With useScroll=true&disconnect=true the scroll iterator holds the client
of
the exchange until it is closed. A route that reads the iterator in its
own
processor until hasNext() is false, without closing it, kept a RestClient
and its I/O reactor threads open per exchange. The iterator now closes
itself when the next scroll page comes back empty: it sends the
clear-scroll request and releases the client. A failed clear-scroll at
the
end is logged at WARN, as all hits were read. close() now marks the
iterator closed also when the clear-scroll request fails, so hasNext()
sends no further scroll request. The component page says that an iterator
left before its end must be closed.
2. Upgrade guide: an endpoint without hostAddresses and without a component
client now fails when the producer starts, and the scroll iterator closes
itself at the end of the scroll.
Tests: ElasticsearchProducerCleanupTest reads a scroll to the end without
close() and checks the clear-scroll request and the closed client (fails
without the change), and closes a scroll before its end.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../camel/catalog/components/elasticsearch.json | 8 +-
.../catalog/docs/elasticsearch-component.adoc | 4 +
.../apache/camel/component/es/elasticsearch.json | 8 +-
.../src/main/docs/elasticsearch-component.adoc | 4 +
.../camel/component/es/ElasticsearchComponent.java | 5 +-
.../component/es/ElasticsearchConfiguration.java | 7 +-
.../camel/component/es/ElasticsearchProducer.java | 124 +++++++---
.../es/ElasticsearchScrollRequestIterator.java | 36 ++-
.../es/ElasticsearchProducerCleanupTest.java | 256 +++++++++++++++++++++
.../ElasticsearchProducerClientLifecycleTest.java | 13 ++
.../es/ElasticsearchProducerSnifferTest.java | 102 ++++++++
.../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc | 12 +
.../dsl/ElasticsearchComponentBuilderFactory.java | 7 +-
.../dsl/ElasticsearchEndpointBuilderFactory.java | 20 +-
14 files changed, 544 insertions(+), 62 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/elasticsearch.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/elasticsearch.json
index 2e9740e2aaee..7b38fd56ae82 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/elasticsearch.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/elasticsearch.json
@@ -33,10 +33,10 @@
"autowiredEnabled": { "index": 6, "kind": "property", "displayName":
"Autowired Enabled", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": true, "description":
"Whether autowiring is enabled. This is used for automatic autowiring options
(the option must be marked as autowired) by looking up in the registry to find
if there is a single instance of matching t [...]
"client": { "index": 7, "kind": "property", "displayName": "Client",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType": "org.elasticsearch.client.RestClient", "deprecated": false,
"autowired": true, "secret": false, "description": "To use an existing
org.elasticsearch.client.RestClient, shared by all the endpoints of the
component, instead of a client that each producer creates. The hostAddresses,
timeout, authentication, SSL, sniffer and disco [...]
"enableSniffer": { "index": 8, "kind": "property", "displayName": "Enable
Sniffer", "group": "advanced", "label": "advanced", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "description": "Whether to start the
Sniffer of the Elasticsearch REST client, which reads the nodes of the cluster
from its Nodes Info API at an interval and updates the nodes that the client
uses. Not used when the cli [...]
- "sniffAfterFailureDelay": { "index": 9, "kind": "property", "displayName":
"Sniff After Failure Delay", "group": "advanced", "label": "advanced",
"required": false, "type": "integer", "javaType": "int", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": 60000, "description": "The
delay in milliseconds of the read of the nodes that the Sniffer schedules after
a failed request. The component does not register the client listener that
reports failures to the Sniff [...]
+ "sniffAfterFailureDelay": { "index": 9, "kind": "property", "displayName":
"Sniff After Failure Delay", "group": "advanced", "label": "advanced",
"required": false, "type": "integer", "javaType": "int", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": 60000, "description": "The
delay in milliseconds of the read of the nodes that the Sniffer schedules after
a failed request, when enableSniffer is set." },
"snifferInterval": { "index": 10, "kind": "property", "displayName":
"Sniffer Interval", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 300000, "description": "The interval in
milliseconds between two reads of the nodes of the cluster, when enableSniffer
is set." },
"apiKey": { "index": 11, "kind": "property", "displayName": "Api Key",
"group": "security", "label": "security", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": true, "security": "secret", "description": "API key to authenticate
with, sent in the Authorization header instead of a user and password. Either
the encoded key as Elasticsearch shows it when the key is created, or the id
and the key separated by a colon [...]
- "certificatePath": { "index": 12, "kind": "property", "displayName":
"Certificate Path", "group": "security", "label": "security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "The CA certificate, in
X.509 format, that the client trusts for HTTPS instead of the default trust
store of the JVM. It is loaded from the classpath by default, or with the
prefix classpath:, file: or http:. It nee [...]
+ "certificatePath": { "index": 12, "kind": "property", "displayName":
"Certificate Path", "group": "security", "label": "security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "supportFileReference": true,
"description": "The CA certificate, in X.509 format, that the client trusts for
HTTPS instead of the default trust store of the JVM. It is loaded from the
classpath by default, or with the prefix clas [...]
"enableSSL": { "index": 13, "kind": "property", "displayName": "Enable
SSL", "group": "security", "label": "security", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "description": "Whether to connect to
the nodes of hostAddresses with HTTPS instead of HTTP. The default SSLContext
of the JVM is used unless sslContextParameters or certificatePath is set." },
"password": { "index": 14, "kind": "property", "displayName": "Password",
"group": "security", "label": "security", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": true, "security": "secret", "description": "The password for HTTP
basic authentication to the nodes, used only together with user. Not used when
the client option is set." },
"sslContextParameters": { "index": 15, "kind": "property", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "description": "To configure security
using SSLContextParameters, which sets the protocols, cipher suites, named
groups and signature schemes of the HTTPS connection. It takes precedenc [...]
@@ -62,7 +62,7 @@
"properties": {
"clusterName": { "index": 0, "kind": "path", "displayName": "Cluster
Name", "group": "producer", "label": "", "required": true, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "The name of the
Elasticsearch cluster. The producer uses it only in its log messages: the
hostAddresses option or t [...]
"connectionTimeout": { "index": 1, "kind": "parameter", "displayName":
"Connection Timeout", "group": "producer", "label": "", "required": false,
"type": "integer", "javaType": "int", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": 30000, "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "The connect timeout in
milliseconds: the longest time that the client waits to establi [...]
- "disconnect": { "index": 2, "kind": "parameter", "displayName":
"Disconnect", "group": "producer", "label": "", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "Whether the producer
creates the client for each exchange and closes it when the exchange is done
[...]
+ "disconnect": { "index": 2, "kind": "parameter", "displayName":
"Disconnect", "group": "producer", "label": "", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "Whether the producer
creates the client for each exchange and closes it when the exchange is done
[...]
"enableDocumentOnlyMode": { "index": 3, "kind": "parameter",
"displayName": "Enable Document Only Mode", "group": "producer", "label": "",
"required": false, "type": "boolean", "javaType": "boolean", "deprecated":
false, "autowired": false, "secret": false, "defaultValue": false,
"configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "Whether the body of
Update is only the partial document to merge into [...]
"from": { "index": 4, "kind": "parameter", "displayName": "From", "group":
"producer", "label": "", "required": false, "type": "integer", "javaType":
"java.lang.Integer", "deprecated": false, "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "The offset of the first
hit that Search returns when the body is JSON text or a Map. It replaces the
from of the body, and [...]
"hostAddresses": { "index": 5, "kind": "parameter", "displayName": "Host
Addresses", "group": "producer", "label": "", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "The comma-separated list
of the nodes to connect to, each as host:port, for example es1:9200,es2:9200.
Th [...]
@@ -77,7 +77,7 @@
"lazyStartProducer": { "index": 14, "kind": "parameter", "displayName":
"Lazy Start Producer", "group": "producer (advanced)", "label":
"producer,advanced", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Whether the producer should be started
lazy (on the first message). By starting lazy you can use this to allow
CamelContext and routes to startup in situations where a produ [...]
"documentClass": { "index": 15, "kind": "parameter", "displayName":
"Document Class", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.Class<java.lang.Object>",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
"ObjectNode", "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "The class to which the
documents in the responses [...]
"enableSniffer": { "index": 16, "kind": "parameter", "displayName":
"Enable Sniffer", "group": "advanced", "label": "advanced", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "Whether to start the
Sniffer of the Elasticsearch REST client, which reads the no [...]
- "sniffAfterFailureDelay": { "index": 17, "kind": "parameter",
"displayName": "Sniff After Failure Delay", "group": "advanced", "label":
"advanced", "required": false, "type": "integer", "javaType": "int",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
60000, "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "The delay in
milliseconds of the read of the nodes that the Sniff [...]
+ "sniffAfterFailureDelay": { "index": 17, "kind": "parameter",
"displayName": "Sniff After Failure Delay", "group": "advanced", "label":
"advanced", "required": false, "type": "integer", "javaType": "int",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
60000, "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "The delay in
milliseconds of the read of the nodes that the Sniff [...]
"snifferInterval": { "index": 18, "kind": "parameter", "displayName":
"Sniffer Interval", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 300000, "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "The interval in
milliseconds between two reads of the nodes of the cluster, when [...]
"certificatePath": { "index": 19, "kind": "parameter", "displayName":
"Certificate Path", "group": "security", "label": "security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "supportFileReference": true,
"configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "The CA certificate, in
X.509 format, that the client trusts fo [...]
"enableSSL": { "index": 20, "kind": "parameter", "displayName": "Enable
SSL", "group": "security", "label": "security", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "Whether to connect to
the nodes of hostAddresses with HTTPS instead of HTTP. The default [...]
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/elasticsearch-component.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/elasticsearch-component.adoc
index 26b1bd9ccf51..a614d1433b11 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/elasticsearch-component.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/elasticsearch-component.adoc
@@ -370,6 +370,10 @@ try (ElasticsearchScrollRequestIterator response =
template.requestBody("direct:
}
----
+The iterator sends a scroll request for each page while it is read, and clears
the scroll when it is closed. It
+closes itself once `hasNext()` returns `false` at the end of the scroll. When
you stop reading before the end, close
+the iterator, as above: with `disconnect=true` it holds the client of the
exchange until it is closed.
+
xref:eips:split-eip.adoc[Split EIP] can also be used.
[tabs]
diff --git
a/components/camel-elasticsearch/src/generated/resources/META-INF/org/apache/camel/component/es/elasticsearch.json
b/components/camel-elasticsearch/src/generated/resources/META-INF/org/apache/camel/component/es/elasticsearch.json
index 2e9740e2aaee..7b38fd56ae82 100644
---
a/components/camel-elasticsearch/src/generated/resources/META-INF/org/apache/camel/component/es/elasticsearch.json
+++
b/components/camel-elasticsearch/src/generated/resources/META-INF/org/apache/camel/component/es/elasticsearch.json
@@ -33,10 +33,10 @@
"autowiredEnabled": { "index": 6, "kind": "property", "displayName":
"Autowired Enabled", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": true, "description":
"Whether autowiring is enabled. This is used for automatic autowiring options
(the option must be marked as autowired) by looking up in the registry to find
if there is a single instance of matching t [...]
"client": { "index": 7, "kind": "property", "displayName": "Client",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType": "org.elasticsearch.client.RestClient", "deprecated": false,
"autowired": true, "secret": false, "description": "To use an existing
org.elasticsearch.client.RestClient, shared by all the endpoints of the
component, instead of a client that each producer creates. The hostAddresses,
timeout, authentication, SSL, sniffer and disco [...]
"enableSniffer": { "index": 8, "kind": "property", "displayName": "Enable
Sniffer", "group": "advanced", "label": "advanced", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "description": "Whether to start the
Sniffer of the Elasticsearch REST client, which reads the nodes of the cluster
from its Nodes Info API at an interval and updates the nodes that the client
uses. Not used when the cli [...]
- "sniffAfterFailureDelay": { "index": 9, "kind": "property", "displayName":
"Sniff After Failure Delay", "group": "advanced", "label": "advanced",
"required": false, "type": "integer", "javaType": "int", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": 60000, "description": "The
delay in milliseconds of the read of the nodes that the Sniffer schedules after
a failed request. The component does not register the client listener that
reports failures to the Sniff [...]
+ "sniffAfterFailureDelay": { "index": 9, "kind": "property", "displayName":
"Sniff After Failure Delay", "group": "advanced", "label": "advanced",
"required": false, "type": "integer", "javaType": "int", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": 60000, "description": "The
delay in milliseconds of the read of the nodes that the Sniffer schedules after
a failed request, when enableSniffer is set." },
"snifferInterval": { "index": 10, "kind": "property", "displayName":
"Sniffer Interval", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 300000, "description": "The interval in
milliseconds between two reads of the nodes of the cluster, when enableSniffer
is set." },
"apiKey": { "index": 11, "kind": "property", "displayName": "Api Key",
"group": "security", "label": "security", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": true, "security": "secret", "description": "API key to authenticate
with, sent in the Authorization header instead of a user and password. Either
the encoded key as Elasticsearch shows it when the key is created, or the id
and the key separated by a colon [...]
- "certificatePath": { "index": 12, "kind": "property", "displayName":
"Certificate Path", "group": "security", "label": "security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "The CA certificate, in
X.509 format, that the client trusts for HTTPS instead of the default trust
store of the JVM. It is loaded from the classpath by default, or with the
prefix classpath:, file: or http:. It nee [...]
+ "certificatePath": { "index": 12, "kind": "property", "displayName":
"Certificate Path", "group": "security", "label": "security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "supportFileReference": true,
"description": "The CA certificate, in X.509 format, that the client trusts for
HTTPS instead of the default trust store of the JVM. It is loaded from the
classpath by default, or with the prefix clas [...]
"enableSSL": { "index": 13, "kind": "property", "displayName": "Enable
SSL", "group": "security", "label": "security", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "description": "Whether to connect to
the nodes of hostAddresses with HTTPS instead of HTTP. The default SSLContext
of the JVM is used unless sslContextParameters or certificatePath is set." },
"password": { "index": 14, "kind": "property", "displayName": "Password",
"group": "security", "label": "security", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": true, "security": "secret", "description": "The password for HTTP
basic authentication to the nodes, used only together with user. Not used when
the client option is set." },
"sslContextParameters": { "index": 15, "kind": "property", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "description": "To configure security
using SSLContextParameters, which sets the protocols, cipher suites, named
groups and signature schemes of the HTTPS connection. It takes precedenc [...]
@@ -62,7 +62,7 @@
"properties": {
"clusterName": { "index": 0, "kind": "path", "displayName": "Cluster
Name", "group": "producer", "label": "", "required": true, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "The name of the
Elasticsearch cluster. The producer uses it only in its log messages: the
hostAddresses option or t [...]
"connectionTimeout": { "index": 1, "kind": "parameter", "displayName":
"Connection Timeout", "group": "producer", "label": "", "required": false,
"type": "integer", "javaType": "int", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": 30000, "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "The connect timeout in
milliseconds: the longest time that the client waits to establi [...]
- "disconnect": { "index": 2, "kind": "parameter", "displayName":
"Disconnect", "group": "producer", "label": "", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "Whether the producer
creates the client for each exchange and closes it when the exchange is done
[...]
+ "disconnect": { "index": 2, "kind": "parameter", "displayName":
"Disconnect", "group": "producer", "label": "", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "Whether the producer
creates the client for each exchange and closes it when the exchange is done
[...]
"enableDocumentOnlyMode": { "index": 3, "kind": "parameter",
"displayName": "Enable Document Only Mode", "group": "producer", "label": "",
"required": false, "type": "boolean", "javaType": "boolean", "deprecated":
false, "autowired": false, "secret": false, "defaultValue": false,
"configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "Whether the body of
Update is only the partial document to merge into [...]
"from": { "index": 4, "kind": "parameter", "displayName": "From", "group":
"producer", "label": "", "required": false, "type": "integer", "javaType":
"java.lang.Integer", "deprecated": false, "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "The offset of the first
hit that Search returns when the body is JSON text or a Map. It replaces the
from of the body, and [...]
"hostAddresses": { "index": 5, "kind": "parameter", "displayName": "Host
Addresses", "group": "producer", "label": "", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "The comma-separated list
of the nodes to connect to, each as host:port, for example es1:9200,es2:9200.
Th [...]
@@ -77,7 +77,7 @@
"lazyStartProducer": { "index": 14, "kind": "parameter", "displayName":
"Lazy Start Producer", "group": "producer (advanced)", "label":
"producer,advanced", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Whether the producer should be started
lazy (on the first message). By starting lazy you can use this to allow
CamelContext and routes to startup in situations where a produ [...]
"documentClass": { "index": 15, "kind": "parameter", "displayName":
"Document Class", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.Class<java.lang.Object>",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
"ObjectNode", "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "The class to which the
documents in the responses [...]
"enableSniffer": { "index": 16, "kind": "parameter", "displayName":
"Enable Sniffer", "group": "advanced", "label": "advanced", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "Whether to start the
Sniffer of the Elasticsearch REST client, which reads the no [...]
- "sniffAfterFailureDelay": { "index": 17, "kind": "parameter",
"displayName": "Sniff After Failure Delay", "group": "advanced", "label":
"advanced", "required": false, "type": "integer", "javaType": "int",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
60000, "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "The delay in
milliseconds of the read of the nodes that the Sniff [...]
+ "sniffAfterFailureDelay": { "index": 17, "kind": "parameter",
"displayName": "Sniff After Failure Delay", "group": "advanced", "label":
"advanced", "required": false, "type": "integer", "javaType": "int",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
60000, "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "The delay in
milliseconds of the read of the nodes that the Sniff [...]
"snifferInterval": { "index": 18, "kind": "parameter", "displayName":
"Sniffer Interval", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 300000, "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "The interval in
milliseconds between two reads of the nodes of the cluster, when [...]
"certificatePath": { "index": 19, "kind": "parameter", "displayName":
"Certificate Path", "group": "security", "label": "security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "supportFileReference": true,
"configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "The CA certificate, in
X.509 format, that the client trusts fo [...]
"enableSSL": { "index": 20, "kind": "parameter", "displayName": "Enable
SSL", "group": "security", "label": "security", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.es.ElasticsearchConfiguration",
"configurationField": "configuration", "description": "Whether to connect to
the nodes of hostAddresses with HTTPS instead of HTTP. The default [...]
diff --git
a/components/camel-elasticsearch/src/main/docs/elasticsearch-component.adoc
b/components/camel-elasticsearch/src/main/docs/elasticsearch-component.adoc
index 26b1bd9ccf51..a614d1433b11 100644
--- a/components/camel-elasticsearch/src/main/docs/elasticsearch-component.adoc
+++ b/components/camel-elasticsearch/src/main/docs/elasticsearch-component.adoc
@@ -370,6 +370,10 @@ try (ElasticsearchScrollRequestIterator response =
template.requestBody("direct:
}
----
+The iterator sends a scroll request for each page while it is read, and clears
the scroll when it is closed. It
+closes itself once `hasNext()` returns `false` at the end of the scroll. When
you stop reading before the end, close
+the iterator, as above: with `disconnect=true` it holds the client of the
exchange until it is closed.
+
xref:eips:split-eip.adoc[Split EIP] can also be used.
[tabs]
diff --git
a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchComponent.java
b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchComponent.java
index af10b10e09ef..a51b15c6e4b3 100644
---
a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchComponent.java
+++
b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchComponent.java
@@ -84,7 +84,7 @@ public class ElasticsearchComponent extends DefaultComponent
implements SSLConte
description = "Whether to connect to the nodes of hostAddresses
with HTTPS instead of HTTP. The default"
+ " SSLContext of the JVM is used unless
sslContextParameters or certificatePath is set.")
private boolean enableSSL;
- @Metadata(label = "security",
+ @Metadata(label = "security", supportFileReference = true,
description = "The CA certificate, in X.509 format, that the
client trusts for HTTPS instead of the default"
+ " trust store of the JVM. It is loaded from the
classpath by default, or with the prefix"
+ " classpath:, file: or http:. It needs
enableSSL, and sslContextParameters takes precedence.")
@@ -109,8 +109,7 @@ public class ElasticsearchComponent extends
DefaultComponent implements SSLConte
private int snifferInterval =
ElasticsearchConstants.DEFAULT_SNIFFER_INTERVAL;
@Metadata(label = "advanced", defaultValue = "" +
ElasticsearchConstants.DEFAULT_AFTER_FAILURE_DELAY,
description = "The delay in milliseconds of the read of the
nodes that the Sniffer schedules after a failed"
- + " request. The component does not register the
client listener that reports failures to the"
- + " Sniffer, so this option has no effect.")
+ + " request, when enableSniffer is set.")
private int sniffAfterFailureDelay =
ElasticsearchConstants.DEFAULT_AFTER_FAILURE_DELAY;
public ElasticsearchComponent() {
diff --git
a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchConfiguration.java
b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchConfiguration.java
index 82fff03efe5e..7e4d0b8cfa03 100644
---
a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchConfiguration.java
+++
b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchConfiguration.java
@@ -82,8 +82,8 @@ public class ElasticsearchConfiguration {
+ " header replaces this option.")
private boolean enableDocumentOnlyMode;
@UriParam(description = "Whether the producer creates the client for each
exchange and closes it when the exchange is"
- + " done, instead of keeping one client from its
start to its stop. Not used when the client"
- + " option of the component is set.")
+ + " done, or with useScroll when the scroll
iterator is closed, instead of keeping one client"
+ + " from its start to its stop. Not used when the
client option of the component is set.")
private boolean disconnect;
@UriParam(label = "security",
description = "Whether to connect to the nodes of hostAddresses
with HTTPS instead of HTTP. The default"
@@ -120,8 +120,7 @@ public class ElasticsearchConfiguration {
private int snifferInterval =
ElasticsearchConstants.DEFAULT_SNIFFER_INTERVAL;
@UriParam(label = "advanced", defaultValue = "" +
ElasticsearchConstants.DEFAULT_AFTER_FAILURE_DELAY,
description = "The delay in milliseconds of the read of the
nodes that the Sniffer schedules after a failed"
- + " request. The component does not register the
client listener that reports failures to the"
- + " Sniffer, so this option has no effect.")
+ + " request, when enableSniffer is set.")
private int sniffAfterFailureDelay =
ElasticsearchConstants.DEFAULT_AFTER_FAILURE_DELAY;
@UriParam(label = "advanced", defaultValue = "ObjectNode",
description = "The class to which the documents in the responses
of GetById, MultiGet, Search and MultiSearch"
diff --git
a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchProducer.java
b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchProducer.java
index 85c1ce19f55d..992238f46730 100644
---
a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchProducer.java
+++
b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchProducer.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.es;
+import java.io.Closeable;
import java.io.InputStream;
import java.security.KeyStore;
import java.security.cert.Certificate;
@@ -70,6 +71,7 @@ import org.elasticsearch.client.Node;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
+import org.elasticsearch.client.sniff.SniffOnFailureListener;
import org.elasticsearch.client.sniff.Sniffer;
import org.elasticsearch.client.sniff.SnifferBuilder;
import org.slf4j.Logger;
@@ -143,6 +145,7 @@ class ElasticsearchProducer extends DefaultAsyncProducer {
@Override
public boolean process(Exchange exchange, AsyncCallback callback) {
+ ActionContext ctx = null;
try {
if (configuration.isDisconnect() && client == null) {
startClient();
@@ -151,6 +154,9 @@ class ElasticsearchProducer extends DefaultAsyncProducer {
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
RestClientOptions options = new
RestClientOptions(RequestOptions.DEFAULT, true);
ElasticsearchTransport transport = new RestClientTransport(client,
new JacksonJsonpMapper(mapper), options);
+ // the context records the headers set from the options as they
are set, so that the cleanup removes them
+ // also when the exchange fails before the request is sent
+ ctx = new ActionContext(exchange, callback, transport);
// 2. Index and type will be set by:
// a. If the incoming body is already an action request
// b. If the body is not an action request we will use headers if
they
@@ -166,37 +172,34 @@ class ElasticsearchProducer extends DefaultAsyncProducer {
// Set the index/type headers on the exchange if necessary. This
is used
// for type conversion.
- boolean configIndexName = false;
String indexName =
message.getHeader(ElasticsearchConstants.PARAM_INDEX_NAME, String.class);
if (indexName == null) {
message.setHeader(ElasticsearchConstants.PARAM_INDEX_NAME,
configuration.getIndexName());
- configIndexName = true;
+ ctx.setConfigIndexName();
}
- boolean configSize = false;
Integer size =
message.getHeader(ElasticsearchConstants.PARAM_SIZE, Integer.class);
if (size == null) {
message.setHeader(ElasticsearchConstants.PARAM_SIZE,
configuration.getSize());
- configSize = true;
+ ctx.setConfigSize();
}
- boolean configFrom = false;
Integer from =
message.getHeader(ElasticsearchConstants.PARAM_FROM, Integer.class);
if (from == null) {
message.setHeader(ElasticsearchConstants.PARAM_FROM,
configuration.getFrom());
- configFrom = true;
+ ctx.setConfigFrom();
}
Boolean enableDocumentOnlyMode =
message.getHeader(ElasticsearchConstants.PARAM_DOCUMENT_MODE, Boolean.class);
if (enableDocumentOnlyMode == null) {
message.setHeader(ElasticsearchConstants.PARAM_DOCUMENT_MODE,
configuration.isEnableDocumentOnlyMode());
+ ctx.setConfigDocumentOnlyMode();
}
- boolean configWaitForActiveShards = false;
Integer waitForActiveShards =
message.getHeader(ElasticsearchConstants.PARAM_WAIT_FOR_ACTIVE_SHARDS,
Integer.class);
if (waitForActiveShards == null) {
message.setHeader(ElasticsearchConstants.PARAM_WAIT_FOR_ACTIVE_SHARDS,
configuration.getWaitForActiveShards());
- configWaitForActiveShards = true;
+ ctx.setConfigWaitForActiveShards();
}
Class<?> documentClass =
message.getHeader(ElasticsearchConstants.PARAM_DOCUMENT_CLASS, Class.class);
@@ -204,9 +207,6 @@ class ElasticsearchProducer extends DefaultAsyncProducer {
documentClass = configuration.getDocumentClass();
}
- ActionContext ctx = new ActionContext(
- exchange, callback, transport, configIndexName,
configWaitForActiveShards, configSize, configFrom);
-
switch (operation) {
case Index: {
processIndexAsync(ctx);
@@ -252,6 +252,11 @@ class ElasticsearchProducer extends DefaultAsyncProducer {
ElasticsearchScrollRequestIterator<?>
scrollRequestIterator = new ElasticsearchScrollRequestIterator<>(
searchRequestBuilder, new
ElasticsearchClient(transport), scrollKeepAliveMs, exchange,
documentClass);
+ if (configuration.isDisconnect() && clientCreated) {
+ // the iterator sends the next scroll requests
while the body is read, so it closes the
+ // client when it is closed, and the next exchange
creates a new client
+
scrollRequestIterator.closeOnClose(detachClient(ctx.getTransport()));
+ }
exchange.getIn().setBody(scrollRequestIterator);
cleanup(ctx);
callback.done(true);
@@ -283,6 +288,9 @@ class ElasticsearchProducer extends DefaultAsyncProducer {
}
} catch (Exception e) {
exchange.setException(e);
+ if (ctx != null) {
+ cleanup(ctx);
+ }
callback.done(true);
return true;
}
@@ -440,7 +448,6 @@ class ElasticsearchProducer extends DefaultAsyncProducer {
private <T> void onComplete(CompletableFuture<T> future, ActionContext
ctx) {
final Exchange exchange = ctx.getExchange();
future.thenAccept(r -> exchange.getIn().setBody(r))
- .thenAccept(r -> cleanup(ctx))
.whenComplete(
(r, e) -> {
try {
@@ -449,6 +456,8 @@ class ElasticsearchProducer extends DefaultAsyncProducer {
"An error occurred while executing
the action", exchange, e));
}
} finally {
+ // also when the request failed, so the
headers set from the options are removed
+ cleanup(ctx);
ctx.getCallback().done(false);
}
});
@@ -483,6 +492,9 @@ class ElasticsearchProducer extends DefaultAsyncProducer {
if (ctx.isConfigFrom()) {
message.removeHeader(ElasticsearchConstants.PARAM_FROM);
}
+ if (ctx.isConfigDocumentOnlyMode()) {
+
message.removeHeader(ElasticsearchConstants.PARAM_DOCUMENT_MODE);
+ }
if (configuration.isDisconnect() && clientCreated) {
closeClient();
IOHelper.close(ctx.getTransport());
@@ -495,6 +507,11 @@ class ElasticsearchProducer extends DefaultAsyncProducer {
@Override
protected void doStart() throws Exception {
super.doStart();
+ if (client == null
+ && (configuration.getHostAddressesList() == null ||
configuration.getHostAddressesList().isEmpty())) {
+ throw new IllegalArgumentException(
+ "The hostAddresses option, or the client option of the
elasticsearch component, is required");
+ }
if (!configuration.isDisconnect()) {
startClient();
}
@@ -506,13 +523,9 @@ class ElasticsearchProducer extends DefaultAsyncProducer {
try {
if (client == null) {
LOG.info("Connecting to the Elasticsearch cluster: {}",
configuration.getClusterName());
- if (configuration.getHostAddressesList() != null
- &&
!configuration.getHostAddressesList().isEmpty()) {
- client = createClient();
- clientCreated = true;
- } else {
- LOG.warn("Incorrect ip address and port parameters
settings for Elasticsearch cluster");
- }
+ // doStart checked that the host addresses are set when no
client is given
+ client = createClient();
+ clientCreated = true;
}
} finally {
lock.unlock();
@@ -550,13 +563,21 @@ class ElasticsearchProducer extends DefaultAsyncProducer {
}
return httpClientBuilder;
});
+ // the sniffer sniffs again after a failure (and then waits
sniffAfterFailureDelay) only when the client
+ // tells it about the failure, through this listener
+ final SniffOnFailureListener sniffOnFailureListener
+ = configuration.isEnableSniffer() ? new
SniffOnFailureListener() : null;
+ if (sniffOnFailureListener != null) {
+ builder.setFailureListener(sniffOnFailureListener);
+ }
final RestClient restClient = builder.build();
restClientRef.set(restClient);
- if (configuration.isEnableSniffer()) {
+ if (sniffOnFailureListener != null) {
SnifferBuilder snifferBuilder = Sniffer.builder(restClient);
snifferBuilder.setSniffIntervalMillis(configuration.getSnifferInterval());
snifferBuilder.setSniffAfterFailureDelayMillis(configuration.getSniffAfterFailureDelay());
sniffer = snifferBuilder.build();
+ sniffOnFailureListener.setSniffer(sniffer);
}
return restClient;
}
@@ -589,6 +610,29 @@ class ElasticsearchProducer extends DefaultAsyncProducer {
super.doStop();
}
+ /**
+ * Hands the client this producer created, its sniffer and the given
transport over to the caller, which closes
+ * them, so that the next exchange creates a new client.
+ */
+ private Closeable detachClient(ElasticsearchTransport transport) {
+ lock.lock();
+ try {
+ final Sniffer detachedSniffer = sniffer;
+ final RestClient detachedClient = client;
+ sniffer = null;
+ client = null;
+ clientCreated = false;
+ return () -> {
+ // the sniffer is closed first, it uses the client
+ IOHelper.close(detachedSniffer);
+ IOHelper.close(detachedClient);
+ IOHelper.close(transport);
+ };
+ } finally {
+ lock.unlock();
+ }
+ }
+
/**
* Closes the client this producer created, so that a start creates a new
one.
*/
@@ -646,20 +690,36 @@ class ElasticsearchProducer extends DefaultAsyncProducer {
private final Exchange exchange;
private final AsyncCallback callback;
private final ElasticsearchTransport transport;
- private final boolean configIndexName;
- private final boolean configWaitForActiveShards;
- private final boolean configSize;
- private final boolean configFrom;
+ private boolean configIndexName;
+ private boolean configWaitForActiveShards;
+ private boolean configSize;
+ private boolean configFrom;
+ private boolean configDocumentOnlyMode;
- ActionContext(Exchange exchange, AsyncCallback callback,
ElasticsearchTransport transport, boolean configIndexName,
- boolean configWaitForActiveShards, boolean configSize,
boolean configFrom) {
+ ActionContext(Exchange exchange, AsyncCallback callback,
ElasticsearchTransport transport) {
this.exchange = exchange;
this.callback = callback;
this.transport = transport;
- this.configIndexName = configIndexName;
- this.configWaitForActiveShards = configWaitForActiveShards;
- this.configSize = configSize;
- this.configFrom = configFrom;
+ }
+
+ void setConfigIndexName() {
+ this.configIndexName = true;
+ }
+
+ void setConfigWaitForActiveShards() {
+ this.configWaitForActiveShards = true;
+ }
+
+ void setConfigSize() {
+ this.configSize = true;
+ }
+
+ void setConfigFrom() {
+ this.configFrom = true;
+ }
+
+ void setConfigDocumentOnlyMode() {
+ this.configDocumentOnlyMode = true;
}
ElasticsearchTransport getTransport() {
@@ -686,6 +746,10 @@ class ElasticsearchProducer extends DefaultAsyncProducer {
return configFrom;
}
+ boolean isConfigDocumentOnlyMode() {
+ return configDocumentOnlyMode;
+ }
+
Exchange getExchange() {
return exchange;
}
diff --git
a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchScrollRequestIterator.java
b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchScrollRequestIterator.java
index b336998609e8..24a45ab95bf3 100644
---
a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchScrollRequestIterator.java
+++
b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchScrollRequestIterator.java
@@ -30,9 +30,14 @@ import co.elastic.clients.elasticsearch.core.SearchRequest;
import co.elastic.clients.elasticsearch.core.SearchResponse;
import co.elastic.clients.elasticsearch.core.search.Hit;
import org.apache.camel.Exchange;
+import org.apache.camel.util.IOHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ElasticsearchScrollRequestIterator<TDocument> implements
Iterator<Hit<TDocument>>, Closeable {
+ private static final Logger LOG =
LoggerFactory.getLogger(ElasticsearchScrollRequestIterator.class);
+
private final SearchRequest searchRequest;
private final ElasticsearchClient esClient;
private final Class<TDocument> documentClass;
@@ -42,6 +47,7 @@ public class ElasticsearchScrollRequestIterator<TDocument>
implements Iterator<H
private String scrollId;
private boolean closed;
private int requestCount;
+ private Closeable resource;
public ElasticsearchScrollRequestIterator(SearchRequest.Builder
searchRequestBuilder, ElasticsearchClient esClient,
int scrollKeepAliveMs, Exchange
exchange, Class<TDocument> documentClass) {
@@ -70,6 +76,11 @@ public class ElasticsearchScrollRequestIterator<TDocument>
implements Iterator<H
updateCurrentSearchHits();
hasNext = currentSearchHits.hasNext();
+ if (!hasNext) {
+ // the scroll is read to the end: clear it, and release the
client it holds with disconnect=true, as a
+ // reader that stops when hasNext() returns false may never
close the iterator
+ closeAtEnd();
+ }
}
return hasNext;
@@ -121,9 +132,28 @@ public class ElasticsearchScrollRequestIterator<TDocument>
implements Iterator<H
return scrollResponse;
}
+ /**
+ * Closes the given resource, the client that this iterator uses, once the
iterator is closed.
+ */
+ void closeOnClose(Closeable resource) {
+ this.resource = resource;
+ }
+
+ private void closeAtEnd() {
+ try {
+ close();
+ } catch (RuntimeException e) {
+ // all the hits were read, the scroll context expires on the node
after scrollKeepAliveMs
+ LOG.warn("Could not clear the scroll after its last page", e);
+ }
+ }
+
@Override
public void close() {
if (!closed) {
+ // closed also when the clear-scroll request fails, so that
hasNext() sends no further scroll request
+ closed = true;
+
exchange.setProperty(ElasticsearchConstants.PROPERTY_SCROLL_ES_QUERY_COUNT,
requestCount);
try {
// scrollId can be null if the initial search returned no
scroll id; List.of(null) would NPE
if (scrollId != null) {
@@ -133,10 +163,12 @@ public class
ElasticsearchScrollRequestIterator<TDocument> implements Iterator<H
esClient.clearScroll(clearScrollRequest);
}
- closed = true;
-
exchange.setProperty(ElasticsearchConstants.PROPERTY_SCROLL_ES_QUERY_COUNT,
requestCount);
} catch (IOException e) {
throw new IllegalStateException(e);
+ } finally {
+ // the client is closed also when the clear-scroll request
failed
+ IOHelper.close(resource);
+ resource = null;
}
}
}
diff --git
a/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/ElasticsearchProducerCleanupTest.java
b/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/ElasticsearchProducerCleanupTest.java
new file mode 100644
index 000000000000..3c505b00afe2
--- /dev/null
+++
b/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/ElasticsearchProducerCleanupTest.java
@@ -0,0 +1,256 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.es;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import co.elastic.clients.elasticsearch.core.search.Hit;
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpServer;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.elasticsearch.client.RestClient;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * The producer removes the headers it set from the endpoint options, and
closes the client it created with
+ * disconnect=true, when the request succeeds, when it fails, and when a
scroll is read to its end or closed.
+ */
+class ElasticsearchProducerCleanupTest {
+
+ private static final String SHARDS =
"\"_shards\":{\"total\":1,\"successful\":1,\"failed\":0}";
+ private static final String QUERY = "{\"query\":{\"match_all\":{}}}";
+ private static final List<String> OPTION_HEADERS = List.of(
+ ElasticsearchConstants.PARAM_INDEX_NAME,
ElasticsearchConstants.PARAM_SIZE, ElasticsearchConstants.PARAM_FROM,
+ ElasticsearchConstants.PARAM_WAIT_FOR_ACTIVE_SHARDS,
ElasticsearchConstants.PARAM_DOCUMENT_MODE);
+
+ private final List<String> requests = new CopyOnWriteArrayList<>();
+ private final AtomicInteger scrolls = new AtomicInteger();
+ private final List<RestClient> createdClients = new
CopyOnWriteArrayList<>();
+ private HttpServer server;
+ private CamelContext context;
+ private String uri;
+
+ @BeforeEach
+ void start() throws Exception {
+ server = HttpServer.create(new InetSocketAddress("127.0.0.1", 0), 0);
+ server.createContext("/", this::answer);
+ server.start();
+ uri = "elasticsearch:test-cluster?hostAddresses=127.0.0.1:" +
server.getAddress().getPort();
+ context = new DefaultCamelContext();
+ context.start();
+ }
+
+ @AfterEach
+ void stop() {
+ context.stop();
+ server.stop(0);
+ }
+
+ @Test
+ void optionHeadersAreRemovedAfterASuccessfulRequest() throws Exception {
+ Exchange exchange = send(uri +
"&operation=Ping&enableDocumentOnlyMode=true", null);
+
+ assertNull(exchange.getException());
+ assertEquals(Boolean.TRUE, exchange.getMessage().getBody());
+ assertNoOptionHeaders(exchange);
+ }
+
+ @Test
+ void aDocumentOnlyModeHeaderOfTheMessageIsKept() throws Exception {
+ ElasticsearchProducer producer = startProducer(uri +
"&operation=Ping&enableDocumentOnlyMode=true");
+ Exchange exchange = producer.getEndpoint().createExchange();
+
exchange.getMessage().setHeader(ElasticsearchConstants.PARAM_DOCUMENT_MODE,
false);
+
+ producer.process(exchange);
+
+ assertNull(exchange.getException());
+ assertEquals(Boolean.FALSE,
exchange.getMessage().getHeader(ElasticsearchConstants.PARAM_DOCUMENT_MODE));
+ producer.stop();
+ }
+
+ @Test
+ void optionHeadersAreRemovedAndTheClientClosedWhenTheRequestFails() throws
Exception {
+ Exchange exchange = send(uri +
"&operation=Index&indexName=failing&size=5&from=1&disconnect=true",
+ Map.of("name", "camel"));
+
+ assertNotNull(exchange.getException(), "the node rejected the
request");
+ assertTrue(requests.stream().anyMatch(r -> r.endsWith("
/failing/_doc")), "requests sent: " + requests);
+ assertNoOptionHeaders(exchange);
+ assertEquals(1, createdClients.size());
+ assertFalse(createdClients.get(0).isRunning(), "the client the failed
exchange used was not closed");
+ }
+
+ @Test
+ void optionHeadersAreRemovedAndTheClientClosedWhenTheBodyIsRejected()
throws Exception {
+ // the producer throws before it sends the request: the Index
operation needs a body
+ Exchange exchange = send(uri +
"&operation=Index&indexName=idx&size=5&from=1&disconnect=true", null);
+
+ assertInstanceOf(IllegalArgumentException.class,
exchange.getException());
+ assertTrue(requests.isEmpty(), "requests sent: " + requests);
+ assertNoOptionHeaders(exchange);
+ assertEquals(1, createdClients.size());
+ assertFalse(createdClients.get(0).isRunning(), "the client the failed
exchange used was not closed");
+ }
+
+ @Test
+ void aScrollWithDisconnectReadToTheEndClosesTheClientWithoutClose() throws
Exception {
+ ElasticsearchProducer producer
+ = startProducer(uri +
"&operation=Search&indexName=idx&useScroll=true&disconnect=true");
+ Exchange exchange = producer.getEndpoint().createExchange();
+ exchange.getMessage().setBody(QUERY);
+
+ producer.process(exchange);
+
+ assertNull(exchange.getException());
+ ElasticsearchScrollRequestIterator<?> iterator
+ = assertInstanceOf(ElasticsearchScrollRequestIterator.class,
exchange.getMessage().getBody());
+ // a reader in its own processor reads until hasNext() is false and
never calls close()
+ List<String> ids = new ArrayList<>();
+ while (iterator.hasNext()) {
+ Hit<?> hit = iterator.next();
+ ids.add(hit.id());
+ assertTrue(createdClients.get(0).isRunning(), "the client was
closed before the scroll was read");
+ }
+
+ assertEquals(List.of("1", "2"), ids);
+ assertTrue(iterator.isClosed(), "the scroll read to the end was not
closed");
+ assertTrue(requests.contains("DELETE /_search/scroll"), "requests
sent: " + requests);
+ assertEquals(1, createdClients.size());
+ assertFalse(createdClients.get(0).isRunning(), "the client of the
scroll was not closed at the end of the scroll");
+ assertFalse(iterator.hasNext());
+ assertEquals(3,
exchange.getProperty(ElasticsearchConstants.PROPERTY_SCROLL_ES_QUERY_COUNT,
Integer.class));
+ // the next exchange creates a new client, the scroll kept the one it
read with
+ assertNull(producer.getClient());
+ assertNoOptionHeaders(exchange);
+ producer.stop();
+ }
+
+ @Test
+ void aScrollWithDisconnectClosedBeforeTheEndClosesTheClient() throws
Exception {
+ ElasticsearchProducer producer
+ = startProducer(uri +
"&operation=Search&indexName=idx&useScroll=true&disconnect=true");
+ Exchange exchange = producer.getEndpoint().createExchange();
+ exchange.getMessage().setBody(QUERY);
+
+ producer.process(exchange);
+
+ assertNull(exchange.getException());
+ ElasticsearchScrollRequestIterator<?> iterator
+ = assertInstanceOf(ElasticsearchScrollRequestIterator.class,
exchange.getMessage().getBody());
+ try (iterator) {
+ assertTrue(iterator.hasNext());
+ assertEquals("1", iterator.next().id());
+ assertTrue(createdClients.get(0).isRunning(), "the client was
closed before the scroll was closed");
+ }
+
+ assertTrue(requests.contains("DELETE /_search/scroll"), "requests
sent: " + requests);
+ assertEquals(1, createdClients.size());
+ assertFalse(createdClients.get(0).isRunning(), "the client of the
scroll was not closed with the scroll");
+ assertNull(producer.getClient());
+ producer.stop();
+ }
+
+ private Exchange send(String endpointUri, Object body) throws Exception {
+ ElasticsearchProducer producer = startProducer(endpointUri);
+ Exchange exchange = producer.getEndpoint().createExchange();
+ exchange.getMessage().setBody(body);
+ producer.process(exchange);
+ producer.stop();
+ return exchange;
+ }
+
+ private ElasticsearchProducer startProducer(String endpointUri) {
+ ElasticsearchEndpoint endpoint = context.getEndpoint(endpointUri,
ElasticsearchEndpoint.class);
+ ElasticsearchProducer producer = new ElasticsearchProducer(endpoint,
endpoint.getConfiguration()) {
+ @Override
+ RestClient createClient() {
+ RestClient client = super.createClient();
+ createdClients.add(client);
+ return client;
+ }
+ };
+ producer.start();
+ return producer;
+ }
+
+ private static void assertNoOptionHeaders(Exchange exchange) {
+ for (String header : OPTION_HEADERS) {
+ assertFalse(exchange.getMessage().getHeaders().containsKey(header),
+ header + " set from the options is still on the message");
+ }
+ }
+
+ private void answer(HttpExchange exchange) throws IOException {
+ exchange.getRequestBody().readAllBytes();
+ String method = exchange.getRequestMethod();
+ String path = exchange.getRequestURI().getPath();
+ requests.add(method + " " + path);
+ int status = 200;
+ String response;
+ if ("HEAD".equals(method)) {
+ response = null;
+ } else if (path.startsWith("/failing/")) {
+ status = 400;
+ response =
"{\"error\":{\"type\":\"mapper_parsing_exception\",\"reason\":\"rejected\"},\"status\":400}";
+ } else if (path.endsWith("/_search")) {
+ response = hits("\"_scroll_id\":\"s1\",", "1");
+ } else if ("/_search/scroll".equals(path) && "DELETE".equals(method)) {
+ response = "{\"succeeded\":true,\"num_freed\":1}";
+ } else if ("/_search/scroll".equals(path)) {
+ response = scrolls.incrementAndGet() == 1 ?
hits("\"_scroll_id\":\"s1\",", "2") : hits("", null);
+ } else {
+ response = "{}";
+ }
+ exchange.getResponseHeaders().add("X-Elastic-Product",
"Elasticsearch");
+ exchange.getResponseHeaders().add("Content-Type", "application/json");
+ if (response == null) {
+ exchange.sendResponseHeaders(status, -1);
+ exchange.close();
+ return;
+ }
+ byte[] bytes = response.getBytes(StandardCharsets.UTF_8);
+ exchange.sendResponseHeaders(status, bytes.length);
+ try (OutputStream out = exchange.getResponseBody()) {
+ out.write(bytes);
+ }
+ }
+
+ private static String hits(String scrollId, String id) {
+ String hit = id == null ? "" : "{\"_index\":\"idx\",\"_id\":\"" + id +
"\",\"_source\":{\"n\":" + id + "}}";
+ return "{" + scrollId + "\"took\":1,\"timed_out\":false," + SHARDS
+ +
",\"hits\":{\"total\":{\"value\":2,\"relation\":\"eq\"},\"hits\":[" + hit +
"]}}";
+ }
+}
diff --git
a/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/ElasticsearchProducerClientLifecycleTest.java
b/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/ElasticsearchProducerClientLifecycleTest.java
index f62a8ae06092..391b22f37a2f 100644
---
a/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/ElasticsearchProducerClientLifecycleTest.java
+++
b/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/ElasticsearchProducerClientLifecycleTest.java
@@ -34,6 +34,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
@@ -138,6 +139,18 @@ class ElasticsearchProducerClientLifecycleTest {
}
}
+ @Test
+ void producerWithoutHostAddressesAndClientFailsToStart() throws Exception {
+ try (CamelContext context = new DefaultCamelContext()) {
+ context.start();
+ Endpoint endpoint =
context.getEndpoint("elasticsearch:test-cluster?operation=Ping");
+ ElasticsearchProducer producer = (ElasticsearchProducer)
endpoint.createProducer();
+
+ IllegalArgumentException e =
assertThrows(IllegalArgumentException.class, producer::start);
+ assertTrue(e.getMessage().contains("hostAddresses"),
e.getMessage());
+ }
+ }
+
private static Object ping(Endpoint endpoint, ElasticsearchProducer
producer) throws Exception {
Exchange exchange = endpoint.createExchange();
producer.process(exchange);
diff --git
a/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/ElasticsearchProducerSnifferTest.java
b/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/ElasticsearchProducerSnifferTest.java
new file mode 100644
index 000000000000..724f1c8f66ee
--- /dev/null
+++
b/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/ElasticsearchProducerSnifferTest.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.es;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpServer;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.awaitility.Awaitility.await;
+
+/**
+ * With enableSniffer, a failed request makes the sniffer sniff the nodes
again, and once more sniffAfterFailureDelay
+ * later, instead of only every snifferInterval.
+ */
+class ElasticsearchProducerSnifferTest {
+
+ private final AtomicInteger sniffs = new AtomicInteger();
+ private HttpServer server;
+
+ @BeforeEach
+ void startServer() throws Exception {
+ // the node fails every request with 503, which the client counts as a
failure of the node, and answers the
+ // sniffing of the nodes with no node
+ server = HttpServer.create(new InetSocketAddress("127.0.0.1", 0), 0);
+ server.createContext("/", this::answer);
+ server.start();
+ }
+
+ @AfterEach
+ void stopServer() {
+ server.stop(0);
+ }
+
+ @Test
+ void aFailedRequestMakesTheSnifferSniffAgain() throws Exception {
+ try (CamelContext context = new DefaultCamelContext()) {
+ context.start();
+ Endpoint endpoint =
context.getEndpoint("elasticsearch:test-cluster?operation=Ping&hostAddresses=127.0.0.1:"
+ +
server.getAddress().getPort()
+ +
"&enableSniffer=true&snifferInterval=3600000&sniffAfterFailureDelay=100");
+ ElasticsearchProducer producer = (ElasticsearchProducer)
endpoint.createProducer();
+ producer.start();
+ try {
+ // the sniffer ignores failures until its first round is done,
so the request is repeated until a
+ // failure is seen; the first round is the only one in the
next hour without that
+ await().atMost(20, TimeUnit.SECONDS).pollInterval(200,
TimeUnit.MILLISECONDS).until(() -> {
+ Exchange exchange = endpoint.createExchange();
+ producer.process(exchange);
+ return sniffs.get() >= 2;
+ });
+ // and the round sniffAfterFailureDelay after the one of the
failure
+ await().atMost(20, TimeUnit.SECONDS).until(() -> sniffs.get()
>= 3);
+ } finally {
+ producer.stop();
+ }
+ }
+ }
+
+ private void answer(HttpExchange exchange) throws IOException {
+ exchange.getRequestBody().readAllBytes();
+ exchange.getResponseHeaders().add("X-Elastic-Product",
"Elasticsearch");
+ if (!exchange.getRequestURI().getPath().startsWith("/_nodes")) {
+ exchange.sendResponseHeaders(503, -1);
+ exchange.close();
+ return;
+ }
+ sniffs.incrementAndGet();
+ byte[] bytes = "{\"nodes\":{}}".getBytes(StandardCharsets.UTF_8);
+ exchange.getResponseHeaders().add("Content-Type", "application/json");
+ exchange.sendResponseHeaders(200, bytes.length);
+ try (OutputStream out = exchange.getResponseBody()) {
+ out.write(bytes);
+ }
+ }
+}
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index 842cdec20280..12d1bbcbd0bd 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -12387,6 +12387,18 @@ response now leaves out that header and logs it at
DEBUG level, instead of faili
the route has already run. Headers with a valid name are written as before. A
route that needs such a value in the
response must set it in a header with a valid name.
+=== camel-elasticsearch - without hostAddresses the producer fails when it
starts, and a scroll is closed at its end
+
+A producer of an elasticsearch endpoint that has neither `hostAddresses` nor a
`client` set on the component now fails
+when it starts (with `lazyStartProducer=true`, on its first exchange), instead
of starting with a WARN and failing
+every exchange. Without `lazyStartProducer=true`, a route with such an
endpoint that is never used, for example one
+switched off by configuration, now stops the application from starting: give
it `hostAddresses`, set a `client` on
+the component, or leave the route out.
+
+With `useScroll=true`, the `ElasticsearchScrollRequestIterator` now closes
itself once its last page is read, which
+clears the scroll on the node and, with `disconnect=true`, closes the client
the scroll was read with. Close the
+iterator yourself when you stop reading before the end.
+
=== camel-ldif - a body that is not a URL fails with InvalidPayloadException
With `allowUrlBody=true`, a body that does not start with `version: 1` and is
not a valid absolute URL, such as a text
diff --git
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ElasticsearchComponentBuilderFactory.java
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ElasticsearchComponentBuilderFactory.java
index 202c48e8f0f5..db6fbb64651b 100644
---
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ElasticsearchComponentBuilderFactory.java
+++
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ElasticsearchComponentBuilderFactory.java
@@ -238,9 +238,7 @@ public interface ElasticsearchComponentBuilderFactory {
/**
* The delay in milliseconds of the read of the nodes that the Sniffer
- * schedules after a failed request. The component does not register
the
- * client listener that reports failures to the Sniffer, so this option
- * has no effect.
+ * schedules after a failed request, when enableSniffer is set.
*
* The option is a: <code>int</code> type.
*
@@ -298,6 +296,9 @@ public interface ElasticsearchComponentBuilderFactory {
* classpath by default, or with the prefix classpath:, file: or http:.
* It needs enableSSL, and sslContextParameters takes precedence.
*
+ * This option can also be loaded from an existing file, by prefixing
+ * with file: or classpath: followed by the location of the file.
+ *
* The option is a: <code>java.lang.String</code> type.
*
* Group: security
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ElasticsearchEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ElasticsearchEndpointBuilderFactory.java
index 324eb5773821..cbf218009c78 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ElasticsearchEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ElasticsearchEndpointBuilderFactory.java
@@ -81,9 +81,9 @@ public interface ElasticsearchEndpointBuilderFactory {
}
/**
* Whether the producer creates the client for each exchange and closes
- * it when the exchange is done, instead of keeping one client from its
- * start to its stop. Not used when the client option of the component
- * is set.
+ * it when the exchange is done, or with useScroll when the scroll
+ * iterator is closed, instead of keeping one client from its start to
+ * its stop. Not used when the client option of the component is set.
*
* The option is a: <code>boolean</code> type.
*
@@ -99,9 +99,9 @@ public interface ElasticsearchEndpointBuilderFactory {
}
/**
* Whether the producer creates the client for each exchange and closes
- * it when the exchange is done, instead of keeping one client from its
- * start to its stop. Not used when the client option of the component
- * is set.
+ * it when the exchange is done, or with useScroll when the scroll
+ * iterator is closed, instead of keeping one client from its start to
+ * its stop. Not used when the client option of the component is set.
*
* The option will be converted to a <code>boolean</code> type.
*
@@ -692,9 +692,7 @@ public interface ElasticsearchEndpointBuilderFactory {
}
/**
* The delay in milliseconds of the read of the nodes that the Sniffer
- * schedules after a failed request. The component does not register
the
- * client listener that reports failures to the Sniffer, so this option
- * has no effect.
+ * schedules after a failed request, when enableSniffer is set.
*
* The option is a: <code>int</code> type.
*
@@ -710,9 +708,7 @@ public interface ElasticsearchEndpointBuilderFactory {
}
/**
* The delay in milliseconds of the read of the nodes that the Sniffer
- * schedules after a failed request. The component does not register
the
- * client listener that reports failures to the Sniffer, so this option
- * has no effect.
+ * schedules after a failed request, when enableSniffer is set.
*
* The option will be converted to a <code>int</code> type.
*