Commit Graph

273 Commits

Author SHA1 Message Date
Artem Bilan
f64f77c4ac GH-244: Add UserRecordResponse adapter for UserRecordResult
Fixes: #244

The `UserRecordResult` has an `attempts()` property which might be used post-put request logic
in the output channel.

* Introduce a `KinesisResponse` extension to adapt a `UserRecordResult`.
This way the further flow logic may consult low-level result from KPL via existing `AwsHeaders.SERVICE_RESULT`
header in the reply message
2024-07-16 11:28:29 -04:00
Minkyu Moon (Manggo)
6703813786 KCL: metricsFactory to NullMetricsFactory if metrics level is NONE
* GH-241: Support changing metrics-level for `KclMessageDrivenChannelAdapter`

* Add test that `metricsLevel` is set correctly

* Modify test body and add author

* Add reference to instance variable

* Set `metricsFactory` to `NullMetricsFactory` if metrics level is `NONE`
2024-04-08 09:43:44 -04:00
Minkyu Moon (Manggo)
cf12660c18 GH-241: Add metrics-level option to KclMessageDrivenChannelAdapter
Fixes: #241

* Add test that `metricsLevel` is set correctly
2024-03-15 12:07:12 -04:00
Artem Bilan
f2aded0686 S3MH: use AsyncRequestBody.fromFile()
Related to the fix for the https://github.com/aws/aws-sdk-java-v2/issues/3839
2024-02-26 12:01:08 -05:00
Artem Bilan
3e0352ef5a GH-238: Fix KinesisMDCA for highest offset
Fixes https://github.com/spring-projects/spring-integration-aws/issues/238

The `shardIterator` from Kinesis reply for records is not a sequence number anymore in AWS SKD v2.

* Fix `rewindIteratorOnError()` logic to extract the highest offset from the current failed `GetRecordsResponse`
to see if we have checkpointed it or we need to re-request the current `shardIterator`
2023-12-04 11:36:24 -05:00
Artem Bilan
875823c473 Upgrade dependencies, prepare for release
* Remove `bamboo_vault.github.password` from `LocalstackContainerTest`
since we don't build on Bamboo anymore
2023-11-14 15:36:14 -05:00
Rogério Lino
33f1061a9f Fix S3Session for pagination
According with AWS SDK doc the nextMarker field is only returned when defining the delimiter query param:


>    NextMarker
    When the response is truncated (the IsTruncated element value in the response is true), you can use the key name in this field as the marker parameter in the subsequent request to get the next set of objects. Amazon S3 lists objects in alphabetical order.
    Note
    This element is returned only if you have the delimiter request parameter specified. If the response does not include the NextMarker element and it is truncated, you can use the value of the last Key element in the response as the marker parameter in the subsequent request to get the next set of object keys.

https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjects.html#API_ListObjects_ResponseElements

After upgrading my project to newest version of `spring-integration-aws` I've started facing this loop issue for buckets with more than `1000` items, where `isTruncated` is true and `nextMarker` is `null`.

* Update the `S3Session` code to use the `key` from last item as `nextMarker` in next the request when response `isTruncated`, avoiding infinite loop.
2023-11-14 14:27:16 -05:00
siddharthjain210
89b19f1e7a GH-235: Fix Retrieval & Lifecycle Config for KCL
Fixes: https://github.com/spring-projects/spring-integration-aws/issues/235

* Corrected the initialization of Retrieval and Lifecycle Config. 
The start Scheduler was creating different instances.
* GH-235 Fixing the failing tests for Enhanced Fan Out.
2023-10-30 11:04:24 -04:00
Artem Bilan
2705936fa8 Fix race condition for multi-stream test
* Fix GE `user.name`
* Attempt to fix the path to test results from GH action
2023-10-19 16:12:57 -04:00
Artem Bilan
2dd8a89f6a Use Flux for KCL multi stream load
* Upgrade to `com.gradle.enterprise:3.15`
* Use `setFanOut(false)` in the `KclMessageDrivenChannelAdapterTests` to cover the polling mode for KCL
2023-10-04 15:46:28 -04:00
Siddharth Jain
3a4f3552f5 GH-232: Fix KCL support for multi streams
Fixes https://github.com/spring-projects/spring-integration-aws/issues/232

* Corrected issues with indentations
* Fixing Code Review Comments. Lazy initializing the Stream Configs, using kinesis stream summary API, removing lease table from the tests
* Fixing Code Review Comments #2, handling formatting.
* Fixing Code Review Comments #3, handling formatting and reducing line lengths to improve readability.
* Some code clean up
2023-10-04 15:02:51 -04:00
Artem Bilan
5fc8659b70 Fix author name in KclMessageDrivenChannelAdapter 2023-10-03 14:49:24 -04:00
Artem Bilan
59415106f3 GH-233: Add KCL polling config support
Fixes https://github.com/spring-projects/spring-integration-aws/issues/233
2023-10-02 17:07:50 -04:00
Artem Bilan
0b41aa23d8 Mention AWS CRT client in the README
* Use an explicit `S3AsyncClient.crtBuilder()` according to the warning in the logs for test
* Some code clean up in the `S3MessageHandler`
2023-09-21 10:20:32 -04:00
Artem Bilan
f184d7be29 Try other Bamboo ENV var 2023-09-20 14:17:07 -04:00
Artem Bilan
7bef950202 Propagate Bamboo GH token to LocalStack 2023-09-20 14:08:10 -04:00
Artem Bilan
8664107092 Upgrade dependencies including Gradle
* Fix Checkstyle violations
* Add `aws-crt-client` to support latest S3 transfer protocol
* Explicitly set respective system properties for AWS HTTP clients
to avoid classpath conflicts
2023-09-20 13:18:28 -04:00
abilan
29235e643a Fix S3MessageHandler for key from file 2023-07-13 15:57:57 -04:00
Giacomo Baso
baa7cc1b2a GH-226: Fix AWS SDK v2 utils imports
Fixes https://github.com/spring-projects/spring-integration-aws/issues/226

* GH-226: fix additional imports
* Replace `com.amazonaws.util` from AWS SKD v1 to `software.amazon.awssdk.utils` in AWS SKD v2
2023-06-22 11:02:59 -04:00
abilan
2e27339594 Use edge endpoint for Localstack services
* Upgrade to Testcontainers `1.18.3`
* Simplify `LocalstackContainerTest` to rely on the `LocalStackContainer.getEndpoint()`
for all the AWS services requested
2023-06-08 10:53:12 -04:00
abilan
31a4dc67f4 GH-224: Fix SnsBodyBuilder usage in the Doc
Fixes https://github.com/spring-projects/spring-integration-aws/issues/224

* Fix `SnsMessageBuilder` -> `SnsBodyBuilder` in the `SnsMessageHandler.onInit()` comment
for SpEL import registration
* Upgrade to Localstack `2.1.0`
* Rename `SnsMessageBuilderTests` -> `SnsBodyBuilderTests` for consistency of its purpose
2023-06-05 11:59:55 -04:00
abilan
d7a2dd590d Fix KinesisMDChA rewindIteratorOnError() for NPE
The error in the `KinesisMessageDrivenChannelAdapter.ShardConsumer.processTask()`
might be also thrown just direct from the `amazonKinesis.getRecords(getRecordsRequest)`.
If it happens first time, the `ShardCheckpointer` is not initialized with sequence numbers.
Therefore, a condition `highestSequence.equals(lastCheckpoint)` may lead to NPE.

* Rework the logic in the `KinesisMessageDrivenChannelAdapter.ShardConsumer.rewindIteratorOnError()`
to deal with a `null` for `this.checkpointer.getHighestSequence()` and reuse the current `shardIterator`
in the next request if no any commits happened.
* Remove `ShardCheckpointer.firstSequenceInBatch` since this is exactly a meaning of `shardIterator` representation.

Related to: https://github.com/spring-projects/spring-integration-aws/issues/223
2023-05-08 12:19:50 -04:00
abilan
bfde46ad41 GH-223: Fix errors in KinesisMDChA.getRecords()
Fixes https://github.com/spring-projects/spring-integration-aws/issues/223

A `amazonKinesis.getRecords(getRecordsRequest).join()` throws `CompletionException`
where the target reason is in a `cause`

* Fix `KinesisMessageDrivenChannelAdapter.getRecords()` to `catch (CompletionException)`
and then process its `cause` respectively
* Upgrade to Spring Cloud AWS `3.0.0` GA
* Upgrade other deps to the latest versions
2023-05-02 17:00:05 -04:00
abilan
bc9a0825fb GH-221: Revise an at-least-once delivery
Fixes https://github.com/spring-projects/spring-integration-aws/issues/221

* Modify the logic of the `KinesisMessageDrivenChannelAdapter` to rewind
a shard iterator to the failed sequence for any errors.
A rewinding sequence is determined from extra properties in the `ShardCheckpointer`
* Remove `RequestShardForSequenceException` since more natural behavior to
react for any record processor error without end-user interaction
2023-04-25 17:11:07 -04:00
abilan
63b40836ce GH-221: Revise the manual checkpoint logic
Fixes https://github.com/spring-projects/spring-integration-aws/issues/221

* Introduce a `RequestShardForSequenceException` to control the flow for
requesting the `KinesisMessageDrivenChannelAdapter` for shard iterator at specific sequence
2023-04-24 17:20:23 -04:00
abilan
136cce6177 Upgrade to testcontainers-1.18.0
* Localstack 2.0.0
2023-04-04 14:05:51 -04:00
abilan
853c410f70 Fix FIFO logic in the SnsMessageHandler
The `messageGroupId` and `messageDeduplicationId` properties
must be set into a `PublishRequest` when topic is in FIFO mode.
Otherwise, they must not be set and fully ignoring them is enough
2023-03-31 14:27:48 -04:00
abilan
10b94e386d GH-112: Add KinesisShardEndedEvent to KclMDChA
Fixes https://github.com/spring-projects/spring-integration-aws/issues/112
2023-03-31 13:43:59 -04:00
abilan
75cd725401 Upgrade to AWS SDK 2.20.35
* Simplify some code in the `KclMessageDrivenChannelAdapter`
* Tried to upgrade to LocalStack `2.0` - failed on S3 `createBucket`
with `Length Required` error.
Sounds like there was no LocalStack and AWS SDK integration testing
2023-03-31 13:34:13 -04:00
abilan
ba6116428f Fix KCL deprecation for streamInitialSequence 2023-03-27 14:12:05 -04:00
abilan
ae2403e196 Downgrade to SI-6.0.x for SC compatibility
* Check for streams configured for `KclMessageDrivenChannelAdapter`
2023-03-24 17:12:40 -04:00
abilan
bd1371fa61 Fix README.md for new state of code in project 2023-03-16 17:40:51 -04:00
abilan
f7bec6a4f5 Fix KCL channel adapter
* Fix config mutation and its propagation down to the `Scheduler`
* Fix conversion from `ByteBuffer`
* Add `KclMessageDrivenChannelAdapterTests` to verify KCL in real action.
The test is slow enough because KCL has a long initialization phase
* Disable `KplKclIntegrationTests` back because KPL native daemon
makes some real calls to EC2 and does not understand credentials
from Testcontainers
2023-03-16 15:45:23 -04:00
abilan
1861a98625 Tweak KPL/KCL integration 2023-03-16 12:12:42 -04:00
abilan
01659911d9 Localstack for S3 Input channel adapter tests
* Enable KPL test for non-Windows OS
2023-03-16 10:47:04 -04:00
abilan
75469c909a Fix S3MessageHandler for upload
Additional change is made to workaround AWS SDK bug: https://github.com/aws/aws-sdk-java-v2/issues/3839
2023-03-16 08:59:59 -04:00
abilan
aee5bdc1af Localstack for SqsMessageDrivenChannelAdapterTest
* Remove `AwsHeaders` which are now covered by the `SqsHeaders`
2023-03-15 13:41:05 -04:00
abilan
d003e1b850 Test SqsMessageHandler against Localstack
* Fix `SqsMessageHandler` to check for `sequenceNumber` before populating it
to replay headers
2023-03-15 12:32:44 -04:00
abilan
f13ef11798 Some tweaks around locks and their tests 2023-03-15 09:42:29 -04:00
Artem Bilan
2947ce496e Disable leader election test 2023-03-14 22:22:21 -04:00
Artem Bilan
c6f90fac87 Some tweaks to leader election test 2023-03-14 20:47:21 -04:00
abilan
a1d2b0d3a8 GH-155: Migrate to AWS SDK v2
Fixes https://github.com/spring-projects/spring-integration-aws/issues/155

* Upgrade to the latest deps including Gradle
* Remove XML configuration support
* Make use of SC-AWS 3.0 SQS and SNS support in respective channel adapters
2023-03-14 18:54:36 -04:00
abilan
283ac42d4e Use Instant for Unix epoch seconds 2023-02-28 12:58:47 -05:00
abilan
ff658f2f84 Some fixes for the DynamoDbLockRepository
* Increase a `DEFAULT_LEASE_DURATION` to `1 min`
* Upgrade to `localstack:1.4.0` Docker image
2023-02-28 10:32:59 -05:00
abilan
88cc93018e Fix DynamoDbLockRepository.renew() logic
The new `TTL` must come with `+leaseDuration`
2023-02-27 17:20:40 -05:00
abilan
620f327483 Fix another Checkstyle violation 2023-02-27 12:25:51 -05:00
abilan
15d149d36d Fix Checkstyle in the DynamoDbLockRegistryTests 2023-02-27 12:20:50 -05:00
abilan
594ea58f28 Implement our own DynamoDb lock repository
The existing `com.amazonaws:dynamodb-lock-client` does not implement
a locking algorithm properly and there is no easy way to determine if
lock has been abandoned according to the current `leaseDuration` behavior.

* Implement `DynamoDbLockRepository` to interact with lock table in this manner:
 - `lockKey` as a primary key
 - `lockOwner` as a unique owner client for the lock
 - `createdAt` just an info when the lock was created by the client
 - `expiredAt` the time in epoch seconds how long the lock is treated as valid
 - this `expiredAt` can be configured as a DynamoDb `TTL` feature
* The `DynamoDbLockRepository` uses a `leaseDuration` to calculate an `expiredAt`
and compares it with the current epoch seconds to see if lock is not valid anymore
* Rework `DynamoDbLockRegistry` to rely on the `DynamoDbLockRepository`
* Remove `com.amazonaws:dynamodb-lock-client` dependency as we don't need it anymore
* Implement `RenewableLockRegistry` contract for simple `expiredAt` update
2023-02-27 12:00:46 -05:00
abilan
2f2675dd6c Fix DynamoDbLockRegistry for additionalTimeToWait
Fixes https://github.com/spring-cloud/spring-cloud-stream-binder-aws-kinesis/issues/186

The `DynamoDbLockClient` waits extra `leaseDuration` time in a loop breaking a `tryLock()` contract.

* Fix `DynamoDbLockRegistry.tryLock()` to decrease an actual `additionalTimeToWait` by `leaseDuration`,
so the target `DynamoDbLockClient` when it adds this `leaseDuration` will wait an actual timeout requested
by the `tryLock()` contract.
This way a `tryLock(0)` will definitely return immediately since we really are not interested in blocking

**cherry-pick to 2.5.x**
2023-02-14 14:12:49 -05:00
abilan
8a1451fc98 Fix KinesisMDCA for closed shard consumption
Fixes https://github.com/spring-cloud/spring-cloud-stream-binder-aws-kinesis/issues/187

The `ShardConsumer` performs a `getShardIterator()` request with some sequence number from checkpointer.
When the shard is closed, it fails with an `InvalidArgumentException` not letting us mark such a consumer a stopped.

* Catch `InvalidArgumentException` on the `getShardIterator()` and see if error is related to a closed shard.
Log such a message and proceed to a `STOP` state for the current `ShardConsumer`.

**Cherry-pick to `2.5.x`**
2023-02-08 12:10:58 -05:00