Elasticsearch નું Rest5Client કન્ફિગરેશન કૉલબૅક દ્વારા તેનું Apache HttpClient 5 બિલ્ડર ખુલ્લું કરે છે:

import co.elastic.clients.transport.rest5_client.low_level.Rest5Client;
import org.apache.hc.core5.http.HttpHost;

var proxy = new HttpHost("http", "proxy.example.net", 8080);

var rest = Rest5Client.builder(
    new HttpHost("https", "search.example.net", 9200))
    .setHttpClientConfigCallback(httpBuilder -> {
        httpBuilder.setProxy(proxy);
    })
    .build();

rest ને એપ્લિકેશનના Elasticsearch ટ્રાન્સપોર્ટ સેટઅપને આપો અને તે ઘટક બંધ થાય ત્યારે તેને બંધ કરો. શોધ હોસ્ટ HTTPS જ રહે છે; પ્રોક્સીની http સ્કીમ મધ્યસ્થ જોડાણનું વર્ણન કરે છે. મંજૂર જાહેર-પ્રોક્સી માર્ગ માટે HTTP પ્રોક્સી સૂચિ એન્ડપોઇન્ટ ઉમેદવારો પૂરા પાડે છે; ખાતરી કરો કે પસંદ કરેલી પ્રોક્સી શોધ હોસ્ટ અને પોર્ટને મંજૂરી આપે છે.

પ્રોક્સી પ્રમાણીકરણ માટે, તે જ કૉલબૅકમાં યોગ્ય વ્યાપવાળો Apache 5 ક્રેડેન્શિયલ પ્રદાતા જોડો. Elasticsearch ખાતું અલગ રાખો.

કૉલબૅક Consumer સ્વીકારે છે: બ્લોકની અંદર આપેલ બિલ્ડર ગોઠવો, બદલી પાછી ન આપો. org.apache.http વાપરતા RestHighLevelClient ઉદાહરણો જૂની પેઢીના છે; Apache 5 org.apache.hc પેકેજ વાપરે છે.

સંબંધિત લેખો