I have been trying to add correlation ID in hibernate search . Tried creating custom HTTP client configure as given in the documentation. But It’s not working .
@Configuration
public class HttpClientConfigurer implements ElasticsearchHttpClientConfigurer {
@Override
public void configure(ElasticsearchHttpClientConfigurationContext context) {
System.out.println("Setting the correlationId");
MDC.put("correlationId", UUID.randomUUID().toString());
System.out.println("The correlationId is set");
HttpAsyncClientBuilder clientBuilder = context.clientBuilder();
clientBuilder.setMaxConnPerRoute( 7 );
clientBuilder.addInterceptorFirst( (HttpResponseInterceptor) (request, httpContext) -> {
System.out.println("Checkpoint 2");
} );
clientBuilder.build();
}
}
Added this in the properties :
elasticsearch.search.backend.client.configurer = com.broadridge.basmsp.configuration.HttpClientConfigurer
Need to add correlation Id here in the request :
2022-09-26 12:51:33.132 TRACE [ ] 11712 --- [port thread - 1] o.h.search.elasticsearch.request : HSEARCH400093: Executed Elasticsearch HTTP POST request to 'http://localhost:9200' with path 'read', query parameters {from=0, size=25, track_total_hits=true} and 1 objects in payload in 15ms. Response had status 200 'OK'. Request body: <{"query":{"bool":{"must":{"bool":POST}...},"hits":{"total":{"value":0,"relation":"eq"},"hits":[]}}>