Commit Graph

10998 Commits

Author SHA1 Message Date
Artem Bilan
6fe59a76aa GH-3826: Fix SimplePool for resizing from MAX
Fixes https://github.com/spring-projects/spring-integration/issues/3826

By default, the `SimplePool` is used with an `Integer.MAX_VALUE` pool size.
There is a performance degradation in the `setPoolSize()` when we try to
decrease the pool size: the `while` for `permits.tryAcquire()` is too long
close to the current `Integer.MAX_VALUE` pool size

* Revise the logic in the `setPoolSize()` to use `Semaphore.reducePermits()`
instead of the loop.
* Change the calculation for a new pool size for the current pool state:
or it is a size of a new request, or iti s equal to the `inUse.size()`.
It will be reduced on subsequent `releaseItem()` calls
* Reduce the number of `available` according a new pool size based on the `inUse`.
So, if `inUse > newPoolSize`, the `available` is cleared.
Otherewise, it is reduced to the number which would give `newPoolSize` together
with the `inUse` size

**Cherry-pick to `5.5.x`**
2022-06-27 13:47:55 -04:00
Artem Bilan
b14e0014da Fix MongoDbAvailableRule for assumeTrue()
Currently, the `MongoDbAvailableRule` logs a warning about missed availability
of the MongoDb server and returns from the `Statement.evaluate()` making the
test not ignored but as passed

* Fix the exception handling in the `MongoDbAvailableRule` for the `Statement`
to call `Assume.assumeTrue()` instead of the plain logging to mark the test as
ignored.
This will make a JUnit test report looking correctly and also will let Sonar Cube
to report test coverage as adequate

**Cherry-pick to `5.5.x`**
2022-06-23 16:33:58 -04:00
Artem Bilan
04c7a87bd9 Use lookupHost = false by default for TCP & UDP (#3825)
* Use `lookupHost = false` by default for TCP & UDP

The applications these days more and more are deployed and managed in the containers
where DNS is not configured by default.
Having `lookupHost = true` by default leads to a bad experience when some delays happen
for reverse host lookups.

* Use `lookupHost = false` by default for both TCP & UDP to have a reliable behavior
independently of the environment.
The `hostName` is used for `connectionId` and as a header in the message -
semantically it doesn't matter for the application logic what value is present over there.

* * Fix language in docs

Co-authored-by: Gary Russell <grussell@vmware.com>

Co-authored-by: Gary Russell <grussell@vmware.com>
2022-06-22 13:23:03 -04:00
Lucas Bowler
8cf5f9083b GH-3822: Reconnection for MQTTv5 channel adapters
Fixes: https://github.com/spring-projects/spring-integration/issues/3822

* Apply spring-framework code style on modified class
* Remove unwanted formatting
* Take pull request comments into account
* Code and JavaDocs clean up
* Improve `Mqttv5BackToBackAutomaticReconnectTests` removing non-related code
* Improve `mqtt.adoc` for this new manual reconnection feature

**Cherry-pick to `5.5.x`**
2022-06-17 14:06:04 -04:00
unseok kim
cf6ce961a2 GH-3805: Introduce RedisLockRegistry.RedisLockType mode
Fixes https://github.com/spring-projects/spring-integration/issues/3805

The Redis Pub-Sub doesn't work in all the environment, therefore there has to
be a choice to use old busy-spin algorithm

* Change to select between spinLock method and pub-sub method
* Make spinLock as a default one to let the `RedisLockRegistry` work everywhere
* Fix javadoc, convention, lazy init
* Fix javadoc, convention
* Code clean up and docs for `RedisLockType` feature

**Cherry-pick to 5.5.x**
2022-06-08 13:15:30 -04:00
Artem Bilan
e855f13d8e GH-3797: Improve batch processing in the framework (#3820)
* GH-3797: Improve batch processing in the framework

Fixes https://github.com/spring-projects/spring-integration/issues/3797

* Handle `Message` items of the `Iterable` payload properly in the `JdbcMessageHandler`.
Otherwise, they've been wrapped into an extra `Message`
* Produce a single message with a `Collection<Message<?>>` payload in the `AggregatingMessageHandler`
when the `getOutputProcessor()` is not an instance of `SimpleMessageGroupProcessor`
* Mention these changes in docs
* Point to the error handling sample from docs

* * Fix language in docs

Co-authored-by: Gary Russell <grussell@vmware.com>

Co-authored-by: Gary Russell <grussell@vmware.com>
2022-06-07 10:14:53 -04:00
Artem Bilan
4f49038e17 Use bean CL for JdbcMessageStore.deserializer
Related to https://stackoverflow.com/questions/72305387/spring-integration-delayer-starts-sending-null-message-payloads-when-switched

In some async use-cases (e.g. `DelayHandler`), the context classloader
might be different for the data to be deserialized from message store.

* Fix `JdbcMessageStore` to populate a bean `ClassLoader` into default
`AllowListDeserializingConverter` from the application context.
The provided `Deserializer` must ensure such a `ClassLoader` itself
* Add warning message to the `LambdaMessageProcessor` when converter
returns `null` for the payload it cannot convert to expected type.
Cannot be raised as error since some applications may already rely
on the `null` conversion result in their method arguments

**Cherry-pick to `5.5.x`**
2022-06-01 12:46:17 -04:00
Artem Bilan
cdcc986d11 Fix KafkaMDChannelAdapter error handling
Current `IntegrationRecordMessageListener.onMessage()`
send a conversion error to the `errorChannel`, but
it does not return if it was successful leading to
the NPE `enhanceHeadersAndSaveAttributes()` because the `message`
is null

* Change the `IntegrationRecordMessageListener.onMessage()` logic to check
the result of the `sendErrorMessageIfNecessary()` and return immediately
if success.
Rethrow an exception otherwise.
2022-05-31 14:08:07 -04:00
Gregory Bragg
7174e8840b Add XSD for new SMB components
* Add namespace handler support for new XSD configs
* Add JUnit tests for outbound gateway XML config
* Add JUnit tests for streaming inbound adapter XML config
* Add Javadoc to new parser classes as per PR feedback
* Some code clean up
2022-05-31 13:32:44 -04:00
Gregory Bragg
0cf1dfee7e Some improvements for SMB module
* Improve permission information returned in `SmbFileInfo`
* Improve documentation for `SmbFileInfo.getPermissions()`
* Add Junit tests to verify all outbound gateway functionality
* Clean test directory of mistakenly migrated SMB extension code
2022-05-26 12:55:37 -04:00
Artem Bilan
751d8084b4 Improve Hazelcast test suite performance
* Add recommended JVM args to the Gradle module for HZ performance
* Move `IdempotentReceiverIntegrationTests` from JMX module to HZ for consistency
* Remove component scan from the `HazelcastIntegrationOutboundTestConfiguration` - redundant
* Use `HazelcastInstance.shutdown()` during normal context lifecycle.
The `@AfterClass` may happen early, so the `stop()` of the channel adapters may fail with
an exception that HZ is not available causing the `LifecycleProcessor` to wait for 30 seconds
on the lifecycle barrier
* Wrap `AbstractEndpoint.doStop()` call into `try..catch` to log error instead of re-throwing
to avoid the mentioned above 30 secs delay of the application context stop
2022-05-25 16:45:00 -04:00
Robert Höglund
a322f5c35d Move spring-integration-hazelcast from extensions
* Update javadocs
* Upgrade from log4j to log4j2
* Remove unnecessary test deps.
* Change from implmementation to api
* Remove unneeded test deps.
* Fix HZ XSD to be "versionless"
* Use `com.google.code.findbugs:annotations` dep to avoid warning from HZ code base
2022-05-25 12:26:28 -04:00
Dominic Stew
040438f5e9 Refresh README
* Modernize the homepage of Spring Integration
* Improve README.md file, so it has examples, explanations, and logo
2022-05-24 12:31:54 -04:00
Gregory Bragg
1f666bcc49 Documentation For new SMB components
* Updated SMB Module documentation for new components
`SmbStreamingMessageSource` and `SmbOutboundGateway`
* Update based on PR review feedback
* Omit XML config examples based on PR review feedback
2022-05-24 10:12:41 -04:00
Artem Bilan
4cc9b300d4 The testWindowTimespan() is time-sensitive
The `FluxAggregatorMessageHandlerTests.testWindowTimespan()`
relies on the time-based window function of `100` millis.
Looks like a delay of `Thread.sleep(20)` may cause a resources race
condition and window is released only with one item.

* Disable `testWindowTimespan()` since there is no guarantee with what
timing settings it is going to work stably

**Cherry-pick to `5.5.x`**
2022-05-23 12:08:03 -04:00
Gregory Bragg
4203a2369f SmbOutboundGateway: Other remote file operations
* Enhanced SmbOutboundGateway with supported remote file operations
* Updated SmbOutboundGateway code based on PR review feedback
* Fully implemented listNames() in SmbSession, added more JUnit tests
* Updated SmbSession code based on PR review comments
2022-05-20 16:37:39 -04:00
Artem Bilan
274b27270f * Improve time-sensitive ControlBusTests.testControlHeaderChannelReaper()
The `Thread.sleep(1000);` doesn't give a good async barrier to rely on
in the subsequent verification logic.
Use `await().until()` instead for several attempts until a condition is fulfilled
ot 10 seconds timeout is exhausted.
Also decrease `reapDelay` to `500` for better test suite performance
2022-05-20 11:59:09 -04:00
Artem Bilan
7262c5f6fd 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 afte JVM exit.

**Cherry-pick to `5.5.x`**
2022-05-19 12:15:43 -04:00
Matthias Stock
e645d046a8 Removed dead link from jdbc.adoc
The linked resource is not available anymore:
https://web.archive.org/web/20210228160648/https://blog.engineyard.com/5-subtle-ways-youre-using-mysql-as-a-queue-and-why-itll-bite-you
2022-05-19 11:13:04 -04:00
Spring Builds
76d571f649 [artifactory-release] Next development version 2022-05-18 20:28:17 +00:00
Spring Builds
8cb8690dc7 [artifactory-release] Release version 6.0.0-M3 2022-05-18 20:28:13 +00:00
Gregory Bragg
ac6af716e1 Add Java DSL for SMB module
* Added supporting classes for DSL, fixed checkstyle build errors
* Added JUnit tests for DSL package
* Updated Java Doc with instructions to setup an external SMB share
* Updated AsciiDoc to include instructions on Java DSL configurations
* Updated implementation based on PR review feedback
* Clean up the code
* Add more info to `whats-new.adoc` for these SMB changes
2022-05-18 15:37:08 -04:00
Artem Bilan
1790f235b7 Fix Checkstyle violations
* Upgrade to Spring Security `6.0.0-M5`
2022-05-18 13:58:05 -04:00
Artem Bilan
ed6f26104f Rely on the official ENV var for Docker repo
* Remove obsolete `TestUtils.dockerRegistryFromEnv()`
* Upgrade to Spring GraphQL `1.0.0`
2022-05-18 13:04:13 -04:00
Artem Bilan
f5ab0c1665 Upgrade dependencies; fix compatibilities
* Fix new Checkstyle rules violations
2022-05-17 17:00:37 -04:00
Artem Bilan
627a797d49 GH-3800: Fix Kotlin docs for route() DSL
Fixes https://github.com/spring-projects/spring-integration/issues/3800

* Mention `Message` as a type for reified generic argument in Kotlin DSL docs

**Cherry-pick to `5.5.x`**
2022-05-17 15:04:21 -04:00
Artem Bilan
5a92d1fcdd * Shorten description of Configuration content item 2022-05-11 16:43:27 -04:00
Artem Bilan
ad19029378 * Remove Pivotal GemFire from content item 2022-05-11 16:43:27 -04:00
Artem Bilan
709f5585df Some Docs improvements
* Add short description to content link in the `index.adoc`
to make it more clear what target chapter is about
* Fix `index-header.adoc` to not show a links to other doc formats.
Instead, use correct link to single/multi according the current context
* Add `Feedback` and `Getting Started` sections to `preface.adoc`
2022-05-11 16:43:27 -04:00
Artem Bilan
9075453add GH-3794: Use less memory with scheduled tasks
Fixes https://github.com/spring-projects/spring-integration/issues/3794

* Replace hard reference to message group with its `id` in the
`AbstractCorrelatingMessageHandler.removeEmptyGroupAfterTimeout()`
* Replace hard reference to message with its `id` in the
`DelayHandler.rescheduleAt()`

**Cherry-pick to `5.5.x`**
2022-05-10 14:34:22 -04:00
Artem Bilan
6d7aebc65a GH-3592: Scatter-Gather: applySeq=true by default
Fixes https://github.com/spring-projects/spring-integration/issues/3592

* Configure XML parser & Java DSL for Scatter-Gather, based on the
`RecipientListRouter` to set an `applySequence` to `true` by default.
This will make a `gatherer` part to fully rely on the default correlation
strategies
2022-05-10 11:03:34 -04:00
Artem Bilan
db287cf98f Remove unused import in the SmbMessageHandler 2022-05-10 10:55:27 -04:00
Gregory Bragg
b64e37973e Add documentation for SMB Support
* Updated, polished documentation prior to PR review
* Updated after PR review comments, changed Adapter verbiage to Support
* Add `SmbMessageHandler(SmbRemoteFileTemplate)` ctors
* Clean up `smb.adoc` for extra redundant interim headlines
2022-05-10 10:48:23 -04:00
Artem Bilan
18e410afbe GH-3679: Better caching for SpringIntegrationTest (#3792)
* GH-3679: Better caching for SpringIntegrationTest

Fixes https://github.com/spring-projects/spring-integration/issues/3679

The `@SpringIntegrationTest` makes a test cache key based on its attributes values
when the same application context can be used in different test classes
with different endpoints to have stopped originally.

* Rework an `IntegrationEndpointsInitializer` to the `SpringIntegrationTestExecutionListener`
which consult a `MockIntegrationContext` for endpoints to be started or not before
the test execution and definitely stopped after the test execution to have a flexibility
with the cached context
* Improve a `MockIntegrationContext` to gather `AbstractEndpoint` beans and have them
marked for stopping in the beginning of the application context.
The `SpringIntegrationTestExecutionListener` takes care about startup in its `beforeTestClass()`
* Verify different state for the `SpringIntegrationTest` with the `CachedSpringIntegrationTestAnnotationTests`

* * Improve `SpringIntegrationTestExecutionListener` performance
when no `@SpringIntegrationTest.noAutoStartup()` is configured
* Fix `CachedSpringIntegrationTestAnnotationTests` check `isRunning()`
for the endpoint under the testing instead of `isAutoStartup()`
which is changed in one test class, but not other, and the order
of their execution would matter
* Migrate `MockMessageSourceTests` to JUnit 5 as a roadmap of the whole project

* Fixes https://github.com/spring-projects/spring-integration/issues/3787
2022-05-09 13:38:10 -04:00
Artem Bilan
0ad89147b2 Add distribution to setup-java@v3 GH action 2022-05-09 11:24:12 -04:00
Gregory Bragg
7ad71d38d9 Migrate SMB extension project to respective module
* Removed deprecated replaceFile and useTempFile session configs
* Refactored to use AssertJ instead of JUnit asserts as per PR feedback
* Code clean up for SMB module
2022-05-06 16:20:43 -04:00
Artem Bilan
392455eb34 Fix version for gradle-build-action GH action 2022-05-06 14:16:24 -04:00
Artem Bilan
e2c13874d2 Clean up pr-build-workflow.yml 2022-05-06 14:04:57 -04:00
Artem Bilan
22b74c7a33 GH-3790: Use new header constants for Kafka headers
Fixes https://github.com/spring-projects/spring-integration/issues/3790

Some `KafkaHeaders` constants have been removed and replaced with new
more meaningful

* Fix removed constants everywhere in the code and docs in favor of
newly introduced, which replaces old
2022-05-05 21:51:16 -04:00
Artem Bilan
da5d2ca4eb GH-3788 Support byte[] for JMS properties mapping
Fixes https://github.com/spring-projects/spring-integration/issues/3788

Some JMS vendors carry some important information in their JMS messages.
That information can be stored in the specific properties as `byte[]`.

* Add `byte[]` as a supported property type into a `DefaultJmsHeaderMapper`
* Verify `byte[]` property mapping and propagation via embedded ActiveMQ
broker.

**Cherry-pick to `5.5.x`**
2022-05-05 13:33:15 -04:00
Artem Bilan
78142fc62e Gemfire testing: --add-opens for JDK management 2022-05-05 09:42:02 -04:00
Artem Bilan
0154618182 Fix configuration doc sections id ambiguity 2022-05-04 14:01:00 -04:00
Artem Bilan
517b9d9625 Upgrade Kotlin to 1.6.21 and use jvmTarget=17 2022-05-04 13:19:37 -04:00
Artem Bilan
e454f59180 GH-3785: Close stream for persistent collection (#3786)
* GH-3785: Close stream for persistent collection

Fixes https://github.com/spring-projects/spring-integration/issues/3785

* Fix `CollectionArgumentResolver` and `PayloadsArgumentResolver` to
close the `Stream` of message after its usage
* Rework `AbstractKeyValueMessageStore.removeMessagesFromGroup()`
to iterate input collection of messages not its stream to avoid
the mentioned problem

**Cherry-pick to `5.5.x`**

* * Add `JdbcMessageStoreTests.testMessageGroupStreamNoConnectionPoolLeak()`
to ensure that no leaks in the connection pool anymore.
* Improve `MessageGroupStore.streamMessagesForGroup()` JavaDocs about
requirements to close the `Stream` from persistent message store impls
2022-04-25 10:18:34 -04:00
Artem Bilan
860f9fea3f Fix MongoDb module for the latest Spring Data
The `MappingMongoConverter` now used different path when it
iterates documents form conversion from a DB cursor

* Fix `MongoDbMessageStore.MessageReadingMongoConverter` to override
a `read(TypeInformation<S>, Bson)` method to convert a `MessageWrapper` properly
* Upgrade to the latest MongoDb driver
2022-04-20 13:58:36 -04:00
Artem Bilan
55c5bef6fa Fix GraphQL tests for latest Spring GraphQL 2022-04-20 11:01:27 -04:00
Artem Bilan
97ab596841 GH-2708: Make messaging annotations as repeatable
Fixes https://github.com/spring-projects/spring-integration/issues/2708

There are some requests to use the same service method for different input channels

* Make all the messaging annotations as `@Repeatable` with their
respective container annotations
* Modify `MessagingAnnotationPostProcessor` logic to deal with the mentioned repeatable
requirements
2022-04-19 11:35:24 -04:00
Artem Bilan
f54d4b3d75 Move to SNAPSHOTs
* Downgrade to Micrometer-1.10.0
* Updates according compatibility with the latest SF changes
2022-04-14 12:27:46 -04:00
Artem Bilan
4b57363a05 GH-3733 Configure TxManager for DefLockRepository (#3782)
* GH-3733 Configure TxManager for DefLockRepository

Fixes https://github.com/spring-projects/spring-integration/issues/3733

The `@Transactional` resolves a primary `TransactionManager` bean
from the application context which might not be sufficient for all
the use-case.

To make it work with the custom (or specific) `TransactionManager`
we have to extend a `DefaultLockRepository` and override all those
`@Transactional` method

* Change the logic of the `DefaultLockRepository` from `@Transactional`
to the `TransactionTemplate` and use provided `TransactionManager`
or resolve one from the application context
* Adjust tests to use explicit `TransactionManager` and call
`afterSingletonsInstantiated()` to initialize a default `TransactionTemplate`
* Mention the change in the docs

* * Extracted all the `TransactionTemplate`s to the properties for caching
* Add `BeanInitializationException` for no-unique `PlatformTransactionManager`
bean in the `afterSingletonsInstantiated()`

* Fix language in the exception message

Co-authored-by: Gary Russell <grussell@vmware.com>

Co-authored-by: Gary Russell <grussell@vmware.com>
2022-04-12 12:13:15 -04:00
Artem Bilan
cd84f1699a GH-3765 Resolve Lookup ctor lazily via reflection
Fixes https://github.com/spring-projects/spring-integration/issues/3765

The `DefaultMethodInvokingMethodInterceptor` has several strategies
for `default` method invocations in the messaging gateway.
One of them is based on the `Lookup` constructor which causes
a `WARNING: An illegal reflective access operation has occurred`.
This can be done lazily when there is no `MethodHandles.privateLookupIn`
in Java version used for the project.

* Fix `OPEN` enum value for the `Constructor<Lookup>` to be resolved in
a lazy manner via `Supplier` and `boolean` flag

**Cherry-pick to `5.5.x`**
2022-04-11 14:29:21 -04:00