[ 
https://issues.apache.org/jira/browse/CAMEL-27965?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen updated CAMEL-27965:
--------------------------------
    Description: 
Found while improving the option descriptions of camel-opensearch for 
CAMEL-23832 (commit 
https://github.com/apache/camel/commit/a43fa856bf61a24517ac0d3fbc25e0e83b77792d,
 pull request https://github.com/apache/camel/pull/31200).
These are separate problems of the component; the descriptions change only 
documents the current behavior.

h4. 1. Scroll search with disconnect=true closes the client too early
{{OpensearchProducer.process}}: for a Search with useScroll and 
disconnect=true, cleanup(ctx) runs right after the scroll iterator is built and 
closes the client the producer created, so the next scroll request and the 
clear-scroll in close() fail.
Proposed change: hand the client to the iterator and close it when the iterator 
is closed, as camel-elasticsearch does since CAMEL-27617.

h4. 2. Cleanup is skipped when a request fails
{{OpensearchProducer.onComplete}} chains the cleanup with thenAccept, so it 
does not run when the request fails; an exception in process() before the 
request (for example a wrong body) skips it too. The headers set from the 
options (CamelOpensearchIndexName, Size, From, WaitForActiveShards) then stay 
on the message, and with disconnect=true the client is not closed.
Proposed change: run the cleanup in whenComplete and in the catch block.

h4. 3. sniffAfterFailureDelay has no effect
{{OpensearchProducer.createClient}} sets no SniffOnFailureListener on the 
RestClientBuilder; only that listener calls Sniffer.sniffOnFailure() 
(opensearch-rest-client-sniffer 3.9.0), so the nodes are only read at 
snifferInterval. The description now says the option has no effect.
Proposed change: builder.setFailureListener(new SniffOnFailureListener()) and 
listener.setSniffer(sniffer), then update the description.

h4. 4. Smaller issues
Without hostAddresses, client or openSearchClient, startClient only logs a WARN 
and every exchange fails later (fail in doStart instead). With disconnect=true 
and concurrent exchanges the client is a shared field: the first exchange to 
complete closes it and sets it to null while others still use it. enableSSL 
replaces the connection manager of the RestClientBuilder, so its pool sizes (10 
per route, 30 total) fall back to the HttpClient defaults (5 and 25). 
hostAddresses is split on ":", so IPv6 literals cannot be used. The doc page 
operation table names the headers indexName, indexId, documentClass, size and 
from instead of CamelOpensearchIndexName and so on (camel-elasticsearch has the 
same).


_Claude Code on behalf of davsclaus_

  was:
Found while improving the option descriptions of camel-opensearch for 
CAMEL-23832 (pull request https://github.com/apache/camel/pull/31200).
These are separate problems of the component; the descriptions change only 
documents the current behavior.

h4. 1. Scroll search with disconnect=true closes the client too early
{{OpensearchProducer.process}}: for a Search with useScroll and 
disconnect=true, cleanup(ctx) runs right after the scroll iterator is built and 
closes the client the producer created, so the next scroll request and the 
clear-scroll in close() fail.
Proposed change: hand the client to the iterator and close it when the iterator 
is closed, as camel-elasticsearch does since CAMEL-27617.

h4. 2. Cleanup is skipped when a request fails
{{OpensearchProducer.onComplete}} chains the cleanup with thenAccept, so it 
does not run when the request fails; an exception in process() before the 
request (for example a wrong body) skips it too. The headers set from the 
options (CamelOpensearchIndexName, Size, From, WaitForActiveShards) then stay 
on the message, and with disconnect=true the client is not closed.
Proposed change: run the cleanup in whenComplete and in the catch block.

h4. 3. sniffAfterFailureDelay has no effect
{{OpensearchProducer.createClient}} sets no SniffOnFailureListener on the 
RestClientBuilder; only that listener calls Sniffer.sniffOnFailure() 
(opensearch-rest-client-sniffer 3.9.0), so the nodes are only read at 
snifferInterval. The description now says the option has no effect.
Proposed change: builder.setFailureListener(new SniffOnFailureListener()) and 
listener.setSniffer(sniffer), then update the description.

h4. 4. Smaller issues
Without hostAddresses, client or openSearchClient, startClient only logs a WARN 
and every exchange fails later (fail in doStart instead). With disconnect=true 
and concurrent exchanges the client is a shared field: the first exchange to 
complete closes it and sets it to null while others still use it. enableSSL 
replaces the connection manager of the RestClientBuilder, so its pool sizes (10 
per route, 30 total) fall back to the HttpClient defaults (5 and 25). 
hostAddresses is split on ":", so IPv6 literals cannot be used. The doc page 
operation table names the headers indexName, indexId, documentClass, size and 
from instead of CamelOpensearchIndexName and so on (camel-elasticsearch has the 
same).


_Claude Code on behalf of davsclaus_


> camel-opensearch: scroll search with disconnect closes the client too early, 
> cleanup skipped on failure, sniffAfterFailureDelay has no effect
> ---------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27965
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27965
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-opensearch
>            Reporter: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.25.0
>
>
> Found while improving the option descriptions of camel-opensearch for 
> CAMEL-23832 (commit 
> https://github.com/apache/camel/commit/a43fa856bf61a24517ac0d3fbc25e0e83b77792d,
>  pull request https://github.com/apache/camel/pull/31200).
> These are separate problems of the component; the descriptions change only 
> documents the current behavior.
> h4. 1. Scroll search with disconnect=true closes the client too early
> {{OpensearchProducer.process}}: for a Search with useScroll and 
> disconnect=true, cleanup(ctx) runs right after the scroll iterator is built 
> and closes the client the producer created, so the next scroll request and 
> the clear-scroll in close() fail.
> Proposed change: hand the client to the iterator and close it when the 
> iterator is closed, as camel-elasticsearch does since CAMEL-27617.
> h4. 2. Cleanup is skipped when a request fails
> {{OpensearchProducer.onComplete}} chains the cleanup with thenAccept, so it 
> does not run when the request fails; an exception in process() before the 
> request (for example a wrong body) skips it too. The headers set from the 
> options (CamelOpensearchIndexName, Size, From, WaitForActiveShards) then stay 
> on the message, and with disconnect=true the client is not closed.
> Proposed change: run the cleanup in whenComplete and in the catch block.
> h4. 3. sniffAfterFailureDelay has no effect
> {{OpensearchProducer.createClient}} sets no SniffOnFailureListener on the 
> RestClientBuilder; only that listener calls Sniffer.sniffOnFailure() 
> (opensearch-rest-client-sniffer 3.9.0), so the nodes are only read at 
> snifferInterval. The description now says the option has no effect.
> Proposed change: builder.setFailureListener(new SniffOnFailureListener()) and 
> listener.setSniffer(sniffer), then update the description.
> h4. 4. Smaller issues
> Without hostAddresses, client or openSearchClient, startClient only logs a 
> WARN and every exchange fails later (fail in doStart instead). With 
> disconnect=true and concurrent exchanges the client is a shared field: the 
> first exchange to complete closes it and sets it to null while others still 
> use it. enableSSL replaces the connection manager of the RestClientBuilder, 
> so its pool sizes (10 per route, 30 total) fall back to the HttpClient 
> defaults (5 and 25). hostAddresses is split on ":", so IPv6 literals cannot 
> be used. The doc page operation table names the headers indexName, indexId, 
> documentClass, size and from instead of CamelOpensearchIndexName and so on 
> (camel-elasticsearch has the same).
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to