From 1e156757fd3974e4ed1d815b3858695246db4be1 Mon Sep 17 00:00:00 2001 From: AmilaSamith Date: Tue, 22 Oct 2024 15:34:21 +0530 Subject: [PATCH 1/3] add changes to support providing time configs in milliseconds This change allows time configuration values to be provided in milliseconds, with support for specifying the time in decimal seconds Fixes:https://github.com/wso2/micro-integrator/issues/3690 --- .../carbon/connector/amazonsqs/config/Init.java | 14 +++++++------- .../amazonsqs/connection/SqsConnection.java | 14 +++++++------- .../carbon/connector/amazonsqs/utils/Utils.java | 16 ++++++++++++++-- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/wso2/carbon/connector/amazonsqs/config/Init.java b/src/main/java/org/wso2/carbon/connector/amazonsqs/config/Init.java index aeda8c3..7fbeb7c 100644 --- a/src/main/java/org/wso2/carbon/connector/amazonsqs/config/Init.java +++ b/src/main/java/org/wso2/carbon/connector/amazonsqs/config/Init.java @@ -101,25 +101,25 @@ private ConnectionConfiguration getConnectionConfigFromContext(MessageContext ms connectionConfig.setAwsAccessKeyId(awsAccessKeyId); connectionConfig.setAwsSecretAccessKey(awsSecretAccessKey); if (StringUtils.isNotBlank(socketTimeout)) { - connectionConfig.setSocketTimeout(Integer.valueOf(socketTimeout)); + connectionConfig.setSocketTimeout(Utils.convertToMillis(socketTimeout)); } if (StringUtils.isNotBlank(connectionTimeout)) { - connectionConfig.setConnectionTimeout(Integer.valueOf(connectionTimeout)); + connectionConfig.setConnectionTimeout(Utils.convertToMillis(connectionTimeout)); } if (StringUtils.isNotBlank(connectionMaxIdleTime)) { - connectionConfig.setConnectionMaxIdleTime(Integer.valueOf(connectionMaxIdleTime)); + connectionConfig.setConnectionMaxIdleTime(Utils.convertToMillis(connectionMaxIdleTime)); } if (StringUtils.isNotBlank(connectionTimeToLive)) { - connectionConfig.setConnectionTimeToLive(Integer.valueOf(connectionTimeToLive)); + connectionConfig.setConnectionTimeToLive(Utils.convertToMillis(connectionTimeToLive)); } if (StringUtils.isNotBlank(connectionAcquisitionTimeout)) { - connectionConfig.setConnectionAcquisitionTimeout(Integer.valueOf(connectionAcquisitionTimeout)); + connectionConfig.setConnectionAcquisitionTimeout(Utils.convertToMillis(connectionAcquisitionTimeout)); } if (StringUtils.isNotBlank(apiCallTimeout)) { - connectionConfig.setApiCallTimeout(Integer.valueOf(apiCallTimeout)); + connectionConfig.setApiCallTimeout(Utils.convertToMillis(apiCallTimeout)); } if (StringUtils.isNotBlank(apiCallAttemptTimeout)) { - connectionConfig.setApiCallAttemptTimeout(Integer.valueOf(apiCallAttemptTimeout)); + connectionConfig.setApiCallAttemptTimeout(Utils.convertToMillis(apiCallAttemptTimeout)); } return connectionConfig; } diff --git a/src/main/java/org/wso2/carbon/connector/amazonsqs/connection/SqsConnection.java b/src/main/java/org/wso2/carbon/connector/amazonsqs/connection/SqsConnection.java index ed0d5d7..39a2227 100644 --- a/src/main/java/org/wso2/carbon/connector/amazonsqs/connection/SqsConnection.java +++ b/src/main/java/org/wso2/carbon/connector/amazonsqs/connection/SqsConnection.java @@ -74,19 +74,19 @@ private SqsClient createNewClientInstance(ConnectionConfiguration connectionConf Integer apiCallAttemptTimeout = connectionConfig.getApiCallAttemptTimeout(); ApacheHttpClient.Builder apacheHttpClientBuilder = ApacheHttpClient.builder(); if (connectionTimeout != -1) { - apacheHttpClientBuilder.connectionTimeout(Duration.ofSeconds(connectionTimeout)); + apacheHttpClientBuilder.connectionTimeout(Duration.ofMillis(connectionTimeout)); } if (connectionAcquisitionTimeout != -1) { - apacheHttpClientBuilder.connectionAcquisitionTimeout(Duration.ofSeconds(connectionAcquisitionTimeout)); + apacheHttpClientBuilder.connectionAcquisitionTimeout(Duration.ofMillis(connectionAcquisitionTimeout)); } if (socketTimeout != -1) { - apacheHttpClientBuilder.socketTimeout(Duration.ofSeconds(socketTimeout)); + apacheHttpClientBuilder.socketTimeout(Duration.ofMillis(socketTimeout)); } if (connectionTimeToLive != -1) { - apacheHttpClientBuilder.connectionTimeToLive(Duration.ofSeconds(connectionTimeToLive)); + apacheHttpClientBuilder.connectionTimeToLive(Duration.ofMillis(connectionTimeToLive)); } if (connectionMaxIdleTime != -1) { - apacheHttpClientBuilder.connectionMaxIdleTime(Duration.ofSeconds(connectionMaxIdleTime)); + apacheHttpClientBuilder.connectionMaxIdleTime(Duration.ofMillis(connectionMaxIdleTime)); } SqsClientBuilder sqsClientBuilder = SqsClient.builder().region(Region.of(connectionConfig.getRegion())). httpClient(apacheHttpClientBuilder.build()); @@ -96,11 +96,11 @@ private SqsClient createNewClientInstance(ConnectionConfiguration connectionConf create(awsAccessKeyId, awsSecretAccessKey)); } if (apiCallTimeout != -1) { - sqsClientBuilder.overrideConfiguration(b -> b.apiCallTimeout(Duration.ofSeconds(apiCallTimeout))); + sqsClientBuilder.overrideConfiguration(b -> b.apiCallTimeout(Duration.ofMillis(apiCallTimeout))); } if (apiCallAttemptTimeout != -1) { sqsClientBuilder.overrideConfiguration(b -> b.apiCallAttemptTimeout( - Duration.ofSeconds(apiCallAttemptTimeout))); + Duration.ofMillis(apiCallAttemptTimeout))); } return sqsClientBuilder.credentialsProvider(credentialsProvider).build(); } diff --git a/src/main/java/org/wso2/carbon/connector/amazonsqs/utils/Utils.java b/src/main/java/org/wso2/carbon/connector/amazonsqs/utils/Utils.java index 3c97747..57eebf7 100644 --- a/src/main/java/org/wso2/carbon/connector/amazonsqs/utils/Utils.java +++ b/src/main/java/org/wso2/carbon/connector/amazonsqs/utils/Utils.java @@ -50,6 +50,7 @@ import software.amazon.awssdk.services.sqs.model.SqsResponseMetadata; import javax.xml.stream.XMLStreamException; +import java.math.BigDecimal; import java.net.MalformedURLException; import java.net.URL; import java.time.Duration; @@ -335,11 +336,22 @@ public static AwsRequestOverrideConfiguration.Builder getOverrideConfiguration(S throws NumberFormatException { AwsRequestOverrideConfiguration.Builder overrideConfiguration = AwsRequestOverrideConfiguration.builder(); if (StringUtils.isNotBlank(apiCallTimeout)) { - overrideConfiguration.apiCallTimeout(Duration.ofSeconds(Integer.parseInt(apiCallTimeout))); + overrideConfiguration.apiCallTimeout(Duration.ofMillis(convertToMillis(apiCallTimeout))); } if (StringUtils.isNotBlank(apiCallAttemptTimeout)) { - overrideConfiguration.apiCallAttemptTimeout(Duration.ofSeconds(Integer.parseInt(apiCallAttemptTimeout))); + overrideConfiguration.apiCallAttemptTimeout(Duration.ofMillis(convertToMillis(apiCallAttemptTimeout))); } return overrideConfiguration; } + + /** + * Convert given duration in seconds to milliseconds + * + * @param duration - duration in seconds + * @return integer + */ + public static Integer convertToMillis(String duration) { + double seconds = Double.parseDouble(duration); + return (int) (seconds * 1000); + } } From 91b4e9d580ea46bade6cf13cd20851ef292afc5f Mon Sep 17 00:00:00 2001 From: AmilaSamith Date: Wed, 23 Oct 2024 11:14:58 +0530 Subject: [PATCH 2/3] add release changes for v2.0.1 Change meta.json and README.md files --- .connector-store/meta.json | 2 +- README.md | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.connector-store/meta.json b/.connector-store/meta.json index 2bef8a1..9a3d17c 100644 --- a/.connector-store/meta.json +++ b/.connector-store/meta.json @@ -12,7 +12,7 @@ ], "releases": [ { - "tagName": "v2.0.0", + "tagName": "v2.0.1", "products": [ "MI 4.3.0", "MI 4.2.0", diff --git a/README.md b/README.md index ed32dc1..850c8bf 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,15 @@ The Amazon SQS connector allows you to access the exposed API through the WSO2 E ## Compatibility -| Connector version | Supported WSO2 ESB/EI version | -| ------------- |------------- | +| Connector version | Supported WSO2 ESB/EI version | +|--------------------------------------------------------------------------------------------------------------------|------------- | +| [2.0.1](https://github.com/wso2-extensions/esb-connector-amazonsqs/tree/v2.0.1) | MI 4.3.0 | | [2.0.0](https://github.com/wso2-extensions/esb-connector-amazonsqs/tree/v2.0.0) | MI 4.3.0 | -| [1.1.0](https://github.com/wso2-extensions/esb-connector-amazonsqs/tree/v1.1.0) | EI 7.0.x, EI 6.6.0, EI 6.4.0, EI 6.3.0, EI 6.1.1 | -| [1.0.8](https://github.com/wso2-extensions/esb-connector-amazonsqs/tree/v1.0.8) | EI 7.0.x, EI 6.6.0, EI 6.4.0, EI 6.3.0, EI 6.1.1 | -| [1.0.7](https://github.com/wso2-extensions/esb-connector-amazonsqs/tree/org.wso2.carbon.connector.amazonsqs-1.0.7) | EI 7.0.x, EI 6.6.0, EI 6.4.0, EI 6.3.0, EI 6.1.1 | -| [1.0.6](https://github.com/wso2-extensions/esb-connector-amazonsqs/tree/org.wso2.carbon.connector.amazonsqs-1.0.6) | EI 6.4.0, EI 6.3.0, EI 6.1.1 | -| [1.0.5](https://github.com/wso2-extensions/esb-connector-amazonsqs/tree/org.wso2.carbon.connector.amazonsqs-1.0.5) | EI 6.1.1, ESB 5.0.0, ESB 4.9.0 | +| [1.1.0](https://github.com/wso2-extensions/esb-connector-amazonsqs/tree/v1.1.0) | EI 7.0.x, EI 6.6.0, EI 6.4.0, EI 6.3.0, EI 6.1.1 | +| [1.0.8](https://github.com/wso2-extensions/esb-connector-amazonsqs/tree/v1.0.8) | EI 7.0.x, EI 6.6.0, EI 6.4.0, EI 6.3.0, EI 6.1.1 | +| [1.0.7](https://github.com/wso2-extensions/esb-connector-amazonsqs/tree/org.wso2.carbon.connector.amazonsqs-1.0.7) | EI 7.0.x, EI 6.6.0, EI 6.4.0, EI 6.3.0, EI 6.1.1 | +| [1.0.6](https://github.com/wso2-extensions/esb-connector-amazonsqs/tree/org.wso2.carbon.connector.amazonsqs-1.0.6) | EI 6.4.0, EI 6.3.0, EI 6.1.1 | +| [1.0.5](https://github.com/wso2-extensions/esb-connector-amazonsqs/tree/org.wso2.carbon.connector.amazonsqs-1.0.5) | EI 6.1.1, ESB 5.0.0, ESB 4.9.0 | ## Documentation From e945625ea4f4975658a863152bd0697152a08105 Mon Sep 17 00:00:00 2001 From: AmilaSamith Date: Wed, 23 Oct 2024 11:20:23 +0530 Subject: [PATCH 3/3] bump connector version 2.0.0 -> 2.0.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b28a305..4bdc1e9 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.connector org.wso2.carbon.connector.amazonsqs jar - 2.0.0 + 2.0.1 WSO2 Carbon - Mediation Library Connector For amazonsqs http://wso2.org