Commit Graph

325 Commits

Author SHA1 Message Date
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
abilan
07603e4aa1 Some tweaks for DynamoDB locks heartbeat
Related to https://github.com/spring-cloud/spring-cloud-stream-binder-aws-kinesis/issues/180

* Treat non-positive `DynamoDbLockRegistry.heartbeatPeriod` as no heartbeat.
This way locks renewal is a responsibility of the target `DynamoDbLockRegistry` consumer.
For example, the `KinesisMessageDrivenChannelAdapter` does call `tryLock()` in a loop
for locks on shards it is consuming at the moment
* Increase locks loop sleep timeout in the `KinesisMessageDrivenChannelAdapter` to one second
to avoid many requests to DynamoDB

**Cherry-pick to `2.5.x`**
2023-01-10 10:50:55 -05:00
abilan
5d9b464f1b GH-219: Fix DynamoDbLockReg for skip blocking
Fixes https://github.com/spring-projects/spring-integration-aws/issues/219

Turns out the `AmazonDynamoDBLockClient` doesn't have a proper logic to
determine correct `lookupTime` and if we want to skip blocking waits,
the item is always treated as not expired because just obtained item from DB
is updated to the current time for its `lookupTime` property

* Remove the logic in the `DynamoDbLockRegistry` setting `withShouldSkipBlockingWait(true)`

**Cherry-pick to `2.5.x`**
2023-01-03 17:20:13 -05:00
abilan
cd5a114ad3 GH-218: Fix logging for AbstMesAttrsHeaderMapper
Fixes https://github.com/spring-projects/spring-integration-aws/issues/218

The `AbstractMessageAttributesHeaderMapper` incorrectly logs only for
SQS service.

* Fix `logger` property to be a `protected` and not `static` to make it
rely on the `getClass()` context
* Fix logging message in the `fromHeaders()` from just `SQS` to `the current AWS service`

**Cherry-pick to `2.5.x`**
2023-01-03 13:24:39 -05:00
abilan
eec9e4546d Upgrade to the latest dependencies
* Upgrade to Gradle `7.6`
* Apply Spring Integration code style
* Replace obsolete Travis CI with GitHub Actions
* Fix test XML configs for the latest Mockito
2022-12-21 13:03:14 -05:00
Christopher Smith
5997fe1a94 GH-214: Filter out nativeHeaders header for SNS mapping
Fixes https://github.com/spring-projects/spring-integration-aws/issues/214

**Cherry-pick to `2.5.x`**
2022-12-20 12:22:26 -05:00
Christopher Smith
2b77c3810f GH-196: Add SNS FIFO support
Fixes https://github.com/spring-projects/spring-integration-aws/issues/196

* Add support for SNS FIFO message group and deduplication IDs
* Add Javadoc, clean up formatting
* Fix Javadoc formatting
* Add SNS FIFO information to README
* Change XML snippet indentation to tabs
* Code samples throughout the README mix tabs and spaces, but this
snippet was using tabs, so this updates the new lines to match.
* Minor code style clean up

**Cherry-pick to `main`**
2022-12-12 14:09:21 -05:00
abilan
2eb0ba2c3f GH-210: Short-circuit Kinesis consumer for stop
Fixes https://github.com/spring-projects/spring-integration-aws/issues/210

To avoid extra cycles for tasks and locks renewal check for a closed shard
just after `getShardIterator()` request in a `NEW` consumer task

**Cherry-pick to `2.5.x`**
2022-11-30 11:28:46 -05:00
abilan
f5b31d2495 Upgrade to the latest dependencies
Fix compatibility and deprecations
2022-11-29 16:02:47 -05:00
Aleksey Krichevskiy
217c675caa GH-207: Add SQS fail-on-missing-queue
Fixes https://github.com/spring-projects/spring-integration-aws/issues/207

* Expose `failOnMissingQueue` flag support for `SqsMessageDrivenChannelAdapter`
* Upgrade to `spring-cloud-aws-2.4.2`
* `fail-on-missing-queue` property support
* `SqsMessageDrivenChannelAdapterParserTests` update

**Cherry-pick to `main`**
# Conflicts:
#	build.gradle
2022-08-16 12:24:42 -04:00
Artem Bilan
4de6c0f0c9 GH-206: Add Glue Schema support into KplMH
Fixes https://github.com/spring-projects/spring-integration-aws/issues/206

* Provide a Glue Schema support for `KplMessageHandler`.
When `UserRecord` is built from the request message, a
`glueSchemaExpression` is evaluated to supply into a `UserRecord`
to produce.
The `GlueSchemaRegistryConfiguration` must be supplied into a `KinesisProducerConfiguration`
* Fix the `buildPutRecordRequest()` algorithm to copy the data
from the `UserRecord` in the request message payload instead of
false-leading expression evaluations and conversions from the request message

**Cherry-pick to `2.5.x`**
2022-06-03 15:21:31 -04:00
Spring Builds
b00ea38142 [artifactory-release] Next development version 2022-05-19 20:11:54 +00:00
Spring Builds
b0a8673a32 [artifactory-release] Release version 3.0.0-M1 2022-05-19 20:11:53 +00:00
Artem Bilan
28554c1187 Disable KplKclIntegrationTests for real calls
The KPL native process does a real Internet call to http://169.254.169.254
for some metadata.
That resource is not always available.
2022-05-19 16:00:55 -04:00
Artem Bilan
246e8e8db1 Upgrade dependencies; prepare for release 2022-05-19 14:55:51 -04:00
Artem Bilan
04b6b9eabf Really reuse Testcontainers
The `withReuse(true)` and `testcontainers.reuse.enable=true` don't work together with `@Container`.
The JUnit extension gathers those containers and stop them in the end of test class unconditionally.

* Remove `@Container` annotation usage
* Use `@BeforeAll` and `GenericContainer.start()` manually
This way the container ensures to reuse existing running container and don't start a fresh one.
Since the container instance is stored in a `static` property, it is really started only once.
The rest tests in a suite just reuse that existing container.
Ryuk container will take care about their stopping and removal eventually after JVM exit.
2022-05-19 11:34:10 -04:00
Artem Bilan
35a48de428 Bring back disabledWithoutDocker = true 2022-05-18 13:00:14 -04:00
Artem Bilan
bbb1dfe241 Check with Docker failure 2022-05-18 11:33:33 -04:00
Artem Bilan
593073120d Improve KinesisMessageDrivenChannelAdapterTests 2022-05-18 10:13:17 -04:00
Artem Bilan
e0e4b0748c Debug Testcontainers 2022-05-17 18:33:37 -04:00
Artem Bilan
34c43a4748 Remove unused import 2022-05-17 17:57:57 -04:00
Artem Bilan
1abea5ec2a Remove Docker registry ENV var usage
Rely on the official `TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX` instead
2022-05-17 17:53:38 -04:00
Artem Bilan
7ca09d89c2 Revert attempts for Harbor Docker mirror 2022-05-17 16:04:40 -04:00
Artem Bilan
91d93b935f Other localstack image variant 2022-05-17 15:47:14 -04:00
Artem Bilan
1b785a0215 Upgrade to Testcontainers 1.17.1 2022-05-17 15:36:44 -04:00
Artem Bilan
8e2a00a652 Try some other way for image compatibility #2 2022-05-17 15:30:21 -04:00
Artem Bilan
0321167eae Try some other way for image compatibility 2022-05-17 14:50:19 -04:00
Artem Bilan
91b5a3633d Add asCompatibleSubstituteFor("localstack") 2022-05-17 14:46:10 -04:00
Artem Bilan
18aaaecea3 Use specific tag for Localstack Docker image
* Use `withReuse(true)` for better performance with Testcontainers
2022-05-17 14:37:34 -04:00
Artem Bilan
dfc25dd01d GH-205: Skip block in DynamoDbLockReg.tryLock()
Fixes https://github.com/spring-projects/spring-integration-aws/issues/205

The `AmazonDynamoDBLockClient.acquireLock()` steps into a busy-wait loop with a sleep timeout.

* Use `AcquireLockOptions.shouldSkipBlockingWait = true` for `tryLock()` without timeout
to have an immediate answer according `tryLock()` contract
* Reset flag to `false` for all other use-cases with `AcquireLockOptions`

**Cherry-pick to `2.5.x`**
2022-05-17 13:53:50 -04:00
Anton Barkan
f771f924b5 Cancel KinesisMDChA.shCMFuture after active=false
It's misleading to see an error for interrupted `KinesisMessageDrivenChannelAdapter.ShardConsumerManager`
on shutdown.

* Move `this.shardConsumerManagerFuture.cancel(true)` in the `doStop()` after `this.active = false;`
2022-04-28 11:04:23 -04:00
Artem Bilan
d818175db0 Fix @since in the LocalstackContainerTest 2022-04-01 10:02:40 -04:00
Artem Bilan
15ea0b181e Increase poll timeouts in tests
* Add `describeStream()` requests to Kinesis tests
to wait for `ACTIVE` before starting to interaction with the stream
2022-03-31 10:26:34 -04:00
Artem Bilan
62b54d1cdf Use unique Kinesis streams for different tests 2022-03-30 17:23:41 -04:00
Artem Bilan
a2f644a353 Use custom Docker registry for Testcontainers 2022-03-30 17:14:56 -04:00
Artem Bilan
6cd191fa8f Fix leftovers for Localstack API 2022-03-30 16:27:41 -04:00
Artem Bilan
620b741ba8 Start version 3.0
* Upgrade to Jakarta EE
* Upgrade to Spring Integration 6.0
* Use Testcontainers instead of direct Localstack
2022-03-30 16:19:40 -04:00
Artem Bilan
055307e7ba Downgrade Checkstyle to 9.3 for Java 8 2022-03-30 13:25:01 -04:00
Artem Bilan
96352a7580 Upgrade dependencies; fix compatibility 2022-03-30 13:16:04 -04:00
Spring Builds
8975c51c0a [artifactory-release] Next development version 2021-06-03 18:47:25 +00:00
Spring Builds
a02c1e89f7 [artifactory-release] Release version 2.5.1 2021-06-03 18:47:21 +00:00
Jonathan Nagayoshi
a002646f63 No NextShardIterator if not processed manual ack batch
* fix(KinesisMessageDrivenChannelAdapter): added logic to not use the NextShardIterator if Manual Checkpointer hasnt reached the last checkpoint

* fix(KinesisMessageDrivenChannel): added logs for getNextShardIterator

* fix(KinesisMessageDrivenChannelAdapter): fixed logic and comments issue

* feat(KinesisMessageDrivenChannelAdapter): implemented integration tests for getNextShardIterator new usecase

* feat(KinesisMessageDrivenChannelAdapter): updated @author

* feat(KinesisMessageDrivenChannelAdapterTests): added author data
2021-05-25 13:52:53 -04:00
Spring Builds
f10d6c6620 [artifactory-release] Next development version 2021-05-20 15:37:21 +00:00
Spring Builds
16c8bd1d8f [artifactory-release] Release version 2.5.0 2021-05-20 15:37:18 +00:00