For AWS SDK for Java 2, configure the HTTP implementation used by the synchronous SQS client. A UrlConnection transport can be built with an explicit intermediary:

import java.net.URI;
import software.amazon.awssdk.http.urlconnection.ProxyConfiguration;
import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sqs.SqsClient;

var httpBuilder = UrlConnectionHttpClient.builder()
    .proxyConfiguration(ProxyConfiguration.builder()
        .endpoint(URI.create("http://proxy.example.net:8080"))
        .build());

var sqs = SqsClient.builder()
    .region(Region.US_EAST_1)
    .httpClientBuilder(httpBuilder)
    .build();

Use the application’s region and credential setup. The url-connection-client transport must be available to the project alongside the SQS module.

The proxy URI identifies the intermediary; the HTTP proxy list provides public candidates, while SqsClient still selects its SQS endpoint normally. Add username and password on the ProxyConfiguration builder when the intermediary requires them.

Giving the service builder an HTTP client builder lets the SDK manage the resulting HTTP client’s lifecycle. Close sqs when its workload ends. An application that instead supplies an already built HTTP client owns that shared client’s lifecycle.

AmazonSQSClientBuilder and ClientConfiguration examples belong to SDK Java 1. Match the imports and transport builder to the major SDK version used by the application.

Tënë sô zo