Commit Graph

237 Commits

Author SHA1 Message Date
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
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
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
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
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
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
Artem Bilan
fa4f5d7903 Upgrade dependencies; fix compatibility; release 2021-05-20 11:18:29 -04:00
Edgar Herrero Uría
537e6f6861 GH-193: Migrate to new Spring Cloud AWS group
Fixes https://github.com/spring-projects/spring-integration-aws/issues/193

Starting with version `2.3` Spring Cloud AWS has been moved
to new Maven coordinates.

* Change `org.springframework.cloud` for SC-AWS to new `io.awspring.cloud`
* Fix imports for new package
* Fix links, coordinates and pacakges in docs
2021-04-12 12:45:11 -04:00
Artem Bilan
57ccd1fb5b Start version 2.5
* Upgrade some dependencies; fix compatibilities
2021-04-09 14:57:20 -04:00