connectionTimeToLive;
-
- /**
- * The amount of time to wait for data to be transferred over an established, open connection before the connection is timed
- * out.
- */
- @ConfigItem(defaultValue = "30S")
- public Duration socketTimeout;
-
- /**
- * The maximum number of connections allowed in the connection pool.
- *
- * Each built HTTP client has its own private connection pool.
- */
- @ConfigItem(defaultValue = "50")
- public int maxConnections;
-
- /**
- * Whether the client should send an HTTP expect-continue handshake before each request.
- */
- @ConfigItem(defaultValue = "true")
- public boolean expectContinueEnabled;
-
- /**
- * Whether the idle connections in the connection pool should be closed asynchronously.
- *
- * When enabled, connections left idling for longer than `quarkus.dynamodb.sync-client.connection-max-idle-time` will be
- * closed.
- * This will not close connections currently in use.
- */
- @ConfigItem(defaultValue = "true")
- public boolean useIdleConnectionReaper;
-
- /**
- * HTTP proxy configuration
- */
- @ConfigItem
- public HttpClientProxyConfiguration proxy;
-
- /**
- * TLS Managers provider configuration
- */
- @ConfigItem
- public TlsManagersProviderConfig tlsManagersProvider;
-
- @ConfigGroup
- public static class HttpClientProxyConfiguration {
-
- /**
- * Enable HTTP proxy
- */
- @ConfigItem
- public boolean enabled;
-
- /**
- * The endpoint of the proxy server that the SDK should connect through.
- *
- * Currently, the endpoint is limited to a host and port. Any other URI components will result in an exception being
- * raised.
- */
- @ConfigItem
- public URI endpoint;
-
- /**
- * The username to use when connecting through a proxy.
- */
- @ConfigItem
- public Optional username;
-
- /**
- * The password to use when connecting through a proxy.
- */
- @ConfigItem
- public Optional password;
-
- /**
- * For NTLM proxies - the Windows domain name to use when authenticating with the proxy.
- */
- @ConfigItem
- public Optional ntlmDomain;
-
- /**
- * For NTLM proxies - the Windows workstation name to use when authenticating with the proxy.
- */
- @ConfigItem
- public Optional ntlmWorkstation;
-
- /**
- * Whether to attempt to authenticate preemptively against the proxy server using basic authentication.
- */
- @ConfigItem
- public Optional preemptiveBasicAuthenticationEnabled;
-
- /**
- * The hosts that the client is allowed to access without going through the proxy.
- */
- @ConfigItem
- public List nonProxyHosts;
- }
-}
diff --git a/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/DynamodbClientProducer.java b/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/DynamodbClientProducer.java
index e51af99d30a4d..940aa53c93cb5 100644
--- a/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/DynamodbClientProducer.java
+++ b/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/DynamodbClientProducer.java
@@ -11,9 +11,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import io.quarkus.dynamodb.runtime.SyncHttpClientConfig.SyncClientType;
import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder;
import software.amazon.awssdk.core.client.builder.SdkClientBuilder;
-import software.amazon.awssdk.core.client.builder.SdkSyncClientBuilder;
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
import software.amazon.awssdk.http.apache.ApacheHttpClient;
@@ -21,6 +21,7 @@
import software.amazon.awssdk.http.apache.ProxyConfiguration;
import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient;
import software.amazon.awssdk.http.nio.netty.SdkEventLoopGroup;
+import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient;
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClientBuilder;
import software.amazon.awssdk.services.dynamodb.DynamoDbBaseClientBuilder;
@@ -101,40 +102,54 @@ private void initSdkClient(SdkClientBuilder builder, SdkConfig config) {
}
}
- private void initHttpClient(SdkSyncClientBuilder builder, ApacheHttpClientConfig config) {
- builder.httpClientBuilder(createApacheClientBuilder(config));
+ private void initHttpClient(DynamoDbClientBuilder builder, SyncHttpClientConfig config) {
+ if (config.type == SyncClientType.APACHE) {
+ builder.httpClientBuilder(createApacheClientBuilder(config));
+ } else {
+ builder.httpClientBuilder(createUrlConnectionClientBuilder(config));
+ }
}
private void initHttpClient(DynamoDbAsyncClientBuilder builder, NettyHttpClientConfig config) {
builder.httpClientBuilder(createNettyClientBuilder(config));
}
- private ApacheHttpClient.Builder createApacheClientBuilder(ApacheHttpClientConfig config) {
+ private UrlConnectionHttpClient.Builder createUrlConnectionClientBuilder(SyncHttpClientConfig config) {
+ UrlConnectionHttpClient.Builder builder = UrlConnectionHttpClient.builder();
+ builder.connectionTimeout(config.connectionTimeout);
+ builder.socketTimeout(config.socketTimeout);
+ return builder;
+ }
+
+ private ApacheHttpClient.Builder createApacheClientBuilder(SyncHttpClientConfig config) {
Builder builder = ApacheHttpClient.builder();
builder.connectionTimeout(config.connectionTimeout);
- builder.connectionAcquisitionTimeout(config.connectionAcquisitionTimeout);
- builder.connectionMaxIdleTime(config.connectionMaxIdleTime);
- config.connectionTimeToLive.ifPresent(builder::connectionTimeToLive);
- builder.expectContinueEnabled(config.expectContinueEnabled);
- builder.maxConnections(config.maxConnections);
builder.socketTimeout(config.socketTimeout);
- builder.useIdleConnectionReaper(config.useIdleConnectionReaper);
- if (config.proxy.enabled) {
- ProxyConfiguration.Builder proxyBuilder = ProxyConfiguration.builder().endpoint(config.proxy.endpoint);
- config.proxy.username.ifPresent(proxyBuilder::username);
- config.proxy.password.ifPresent(proxyBuilder::password);
- config.proxy.nonProxyHosts.forEach(proxyBuilder::addNonProxyHost);
- config.proxy.ntlmDomain.ifPresent(proxyBuilder::ntlmDomain);
- config.proxy.ntlmWorkstation.ifPresent(proxyBuilder::ntlmWorkstation);
- config.proxy.preemptiveBasicAuthenticationEnabled
+ builder.connectionAcquisitionTimeout(config.apache.connectionAcquisitionTimeout);
+ builder.connectionMaxIdleTime(config.apache.connectionMaxIdleTime);
+ config.apache.connectionTimeToLive.ifPresent(builder::connectionTimeToLive);
+ builder.expectContinueEnabled(config.apache.expectContinueEnabled);
+ builder.maxConnections(config.apache.maxConnections);
+ builder.useIdleConnectionReaper(config.apache.useIdleConnectionReaper);
+
+ if (config.apache.proxy.enabled) {
+ ProxyConfiguration.Builder proxyBuilder = ProxyConfiguration.builder()
+ .endpoint(config.apache.proxy.endpoint);
+ config.apache.proxy.username.ifPresent(proxyBuilder::username);
+ config.apache.proxy.password.ifPresent(proxyBuilder::password);
+ config.apache.proxy.nonProxyHosts.forEach(proxyBuilder::addNonProxyHost);
+ config.apache.proxy.ntlmDomain.ifPresent(proxyBuilder::ntlmDomain);
+ config.apache.proxy.ntlmWorkstation.ifPresent(proxyBuilder::ntlmWorkstation);
+ config.apache.proxy.preemptiveBasicAuthenticationEnabled
.ifPresent(proxyBuilder::preemptiveBasicAuthenticationEnabled);
builder.proxyConfiguration(proxyBuilder.build());
}
- builder.tlsKeyManagersProvider(config.tlsManagersProvider.type.create(config.tlsManagersProvider));
+ builder.tlsKeyManagersProvider(
+ config.apache.tlsManagersProvider.type.create(config.apache.tlsManagersProvider));
return builder;
}
diff --git a/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/DynamodbConfig.java b/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/DynamodbConfig.java
index 2cc94c57b21e2..385dc2125247f 100644
--- a/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/DynamodbConfig.java
+++ b/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/DynamodbConfig.java
@@ -26,10 +26,10 @@ public class DynamodbConfig {
public AwsConfig aws;
/**
- * Apache HTTP client transport configuration
+ * Sync client transport configuration
*/
@ConfigItem
- public ApacheHttpClientConfig syncClient;
+ public SyncHttpClientConfig syncClient;
/**
* Netty HTTP client transport configuration
diff --git a/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/SyncHttpClientConfig.java b/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/SyncHttpClientConfig.java
new file mode 100644
index 0000000000000..f1cabe0217d2b
--- /dev/null
+++ b/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/SyncHttpClientConfig.java
@@ -0,0 +1,157 @@
+package io.quarkus.dynamodb.runtime;
+
+import java.net.URI;
+import java.time.Duration;
+import java.util.List;
+import java.util.Optional;
+
+import io.quarkus.runtime.annotations.ConfigGroup;
+import io.quarkus.runtime.annotations.ConfigItem;
+
+@ConfigGroup
+public class SyncHttpClientConfig {
+
+ /**
+ * Type of the sync HTTP client implementation
+ */
+ @ConfigItem(defaultValue = "url")
+ public SyncClientType type;
+
+ /**
+ * The maximum amount of time to establish a connection before timing out.
+ */
+ @ConfigItem(defaultValue = "2S")
+ public Duration connectionTimeout;
+
+ /**
+ * The amount of time to wait for data to be transferred over an established, open connection before the connection is
+ * timed
+ * out.
+ */
+ @ConfigItem(defaultValue = "30S")
+ public Duration socketTimeout;
+
+ /**
+ * Apache HTTP client additional configuration
+ */
+ @ConfigItem
+ public ApacheHttpClientConfig apache;
+
+ @ConfigGroup
+ public static class ApacheHttpClientConfig {
+
+ /**
+ * The amount of time to wait when acquiring a connection from the pool before giving up and timing out.
+ */
+ @ConfigItem(defaultValue = "10S")
+ public Duration connectionAcquisitionTimeout;
+
+ /**
+ * The maximum amount of time that a connection should be allowed to remain open while idle.
+ */
+ @ConfigItem(defaultValue = "60S")
+ public Duration connectionMaxIdleTime;
+
+ /**
+ * The maximum amount of time that a connection should be allowed to remain open, regardless of usage frequency.
+ */
+ @ConfigItem
+ public Optional connectionTimeToLive;
+
+ /**
+ * The maximum number of connections allowed in the connection pool.
+ *
+ * Each built HTTP client has its own private connection pool.
+ */
+ @ConfigItem(defaultValue = "50")
+ public int maxConnections;
+
+ /**
+ * Whether the client should send an HTTP expect-continue handshake before each request.
+ */
+ @ConfigItem(defaultValue = "true")
+ public boolean expectContinueEnabled;
+
+ /**
+ * Whether the idle connections in the connection pool should be closed asynchronously.
+ *
+ * When enabled, connections left idling for longer than `quarkus.dynamodb.sync-client.connection-max-idle-time` will be
+ * closed.
+ * This will not close connections currently in use.
+ */
+ @ConfigItem(defaultValue = "true")
+ public boolean useIdleConnectionReaper;
+
+ /**
+ * HTTP proxy configuration
+ */
+ @ConfigItem
+ public HttpClientProxyConfiguration proxy;
+
+ /**
+ * TLS Managers provider configuration
+ */
+ @ConfigItem
+ public TlsManagersProviderConfig tlsManagersProvider;
+
+ @ConfigGroup
+ public static class HttpClientProxyConfiguration {
+
+ /**
+ * Enable HTTP proxy
+ */
+ @ConfigItem
+ public boolean enabled;
+
+ /**
+ * The endpoint of the proxy server that the SDK should connect through.
+ *
+ * Currently, the endpoint is limited to a host and port. Any other URI components will result in an exception being
+ * raised.
+ */
+ @ConfigItem
+ public URI endpoint;
+
+ /**
+ * The username to use when connecting through a proxy.
+ */
+ @ConfigItem
+ public Optional username;
+
+ /**
+ * The password to use when connecting through a proxy.
+ */
+ @ConfigItem
+ public Optional password;
+
+ /**
+ * For NTLM proxies - the Windows domain name to use when authenticating with the proxy.
+ */
+ @ConfigItem
+ public Optional ntlmDomain;
+
+ /**
+ * For NTLM proxies - the Windows workstation name to use when authenticating with the proxy.
+ */
+ @ConfigItem
+ public Optional ntlmWorkstation;
+
+ /**
+ * Whether to attempt to authenticate preemptively against the proxy server using basic authentication.
+ */
+ @ConfigItem
+ public Optional preemptiveBasicAuthenticationEnabled;
+
+ /**
+ * The hosts that the client is allowed to access without going through the proxy.
+ */
+ @ConfigItem
+ public List nonProxyHosts;
+ }
+ }
+
+ public enum SyncClientType {
+ URL,
+ APACHE
+ }
+}
diff --git a/integration-tests/amazon-dynamodb/pom.xml b/integration-tests/amazon-dynamodb/pom.xml
index 0cdcc82c56583..51f0a5da3f347 100644
--- a/integration-tests/amazon-dynamodb/pom.xml
+++ b/integration-tests/amazon-dynamodb/pom.xml
@@ -37,6 +37,15 @@
quarkus-amazon-dynamodb