Commit Graph

11324 Commits

Author SHA1 Message Date
abilan
dd53de8bfc Bring back Kotlin version 1.8.10
There is no Dokka plugin `1.8.20` yet
2023-04-19 09:46:03 -04:00
abilan
fe1a3ee096 Upgrade some dependencies 2023-04-19 09:43:16 -04:00
Artem Bilan
8dd1332d0a Fix NPEs in DSL Specs (#8597)
* Fix NPEs in DSL Specs

The `BaseWsInboundGatewaySpec` and `TailAdapterSpec` don't override super methods
and when we call them we fail with NPE since `target` was not populated.

* Fix `BaseWsInboundGatewaySpec` and its inheritors to populate the `target`
from their ctors.
* Remove redundant methods from `BaseWsInboundGatewaySpec` hierarchy
* Propagate `AbstractWebServiceInboundGateway` properties directly to the target
from the `BaseWsInboundGatewaySpec` inheritors
* Override `MessageProducerSpec` methods in the `TailAdapterSpec`
to populate respective option into the `FileTailInboundChannelAdapterFactoryBean`
* Expose more missed options for producer endpoint in the `FileTailInboundChannelAdapterFactoryBean`

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

* * `acceptIfNotNull()` for `errorMessageStrategy` in the `FileTailInboundChannelAdapterFactoryBean`

* * Fix `Unmarshaller` population logic in the `MarshallingWsInboundGatewaySpec`
2023-04-18 11:12:23 -04:00
Artem Bilan
feb4705e79 Improve Java DSL for Rabbit Streams (#8598)
* Improve Java DSL for Rabbit Streams

* Expose simple properties for `streamName` and `superStream`
on the `RabbitStreamInboundChannelAdapterSpec`
* Add `superStream(String superStream, String name, int consumers)` option
* Add `outboundStreamAdapter(Environment environment, String streamName)` factory for
simple use-cases
* Add `RabbitStreamTests` integration test to cover Rabbit Streams support
 and demonstrate respective Java DSL
* Mention the change in the docs

* * Fix typos in code and docs
2023-04-18 10:16:19 -04:00
abilan
fa178c3da6 Fix new Sonar smells
* And more convenient Kotlin methods based on `IntegrationFlow`
2023-04-16 14:49:45 -04:00
abilan
869c5c7088 Fix new Sonar smells 2023-04-15 20:00:38 -04:00
abilan
d5181bf0d7 Add Nullability support into Java DSL 2023-04-14 14:16:36 -04:00
Artem Bilan
053cc00484 GH-3557: Add maxDepth, dirPredicate to FileReadMS (#8596)
* GH-3557: Add maxDepth, dirPredicate to FileReadMS

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

* Expose a `watchMaxDepth` on the `FileReadingMessageSource` for its `Files.walkFileTree()` API usage
* Add `watchDirPredicate` option ot the `FileReadingMessageSource` to skip sub-tree for `Files.walkFileTree()`
scanning according to some condition against directory `Path`

* Fix language in docs

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

---------

Co-authored-by: Gary Russell <grussell@vmware.com>
2023-04-13 17:03:39 -04:00
Artem Bilan
aaaa489f0c Optimize MessageTriggerAction for Java DSL (#8595)
Currently, the `MessageTriggerAction.trigger` is configured
on the `BaseIntegrationFlowDefinition` to be called via reflection
in the `MessagingMethodInvokerHelper`

* Represent a `MessageTriggerAction.trigger` as a `Consumer<Message<?>>` method reference
and use a `LambdaMessageProcessor` for direct call
* Add a `Consumer` support for `LambdaMessageProcessor`
2023-04-13 12:56:45 -04:00
Artem Bilan
b99729544d GH-8586: Deprecate IntegrationComponentSpec.get() (#8594)
* GH-8586: Deprecate IntegrationComponentSpec.get()

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

The `IntegrationComponentSpec` is not a plain wrapper around single component.
Sometimes it comes with several components where all of them must be registered
as beans.
If `IntegrationComponentSpec.get()` is called from end-user code, we may lose
other related components, for example filters in the `FileInboundChannelAdapterSpec`.

* Deprecate `IntegrationComponentSpec.get()` with no-op for end-user,
rather encourage to leave it as is and let the framework take care about its lifecycle
and related components registration
* Fix `IntegrationComponentSpec` logic to deal as a simple `FactoryBean` instead of
extra overhead via `AbstractFactoryBean`
* Use `IntegrationComponentSpec.getObject()` in the framework code where `get()` was called
* Fix tests to expose `IntegrationComponentSpec` as beans instead of previously called `get()`
* Some other clean up and typos fixes in the affected classes
* Document the change

* * Revert `ObjectStringMapBuilder` in the `KafkaInboundGatewaySpec.getComponentsToRegister()`

* Fix language in docs

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

* * Remove trailing whitespace in the `ScriptMessageSourceSpec`

---------

Co-authored-by: Gary Russell <grussell@vmware.com>
2023-04-13 09:16:42 -04:00
abilan
bbaffb22bf Fix Checkstyle violations
* Fix new Sonar smells
2023-04-11 16:54:30 -04:00
abilan
bbbfc47ca4 Use StandardEvalCtx in the ZeroMqMessageHandler
A simple one was used by mistake
2023-04-11 16:15:27 -04:00
abilan
e69285a06f Fix sample image link in the amqp.adoc 2023-04-11 15:41:29 -04:00
abilan
e03d125fdb Improve some tests performance 2023-04-10 14:55:45 -04:00
Artem Bilan
4f5250b470 Propagate Reactor context over headers (#8591)
* Propagate Reactor context over headers

When we do something like `Flux.from(Publisher)`
and don't compose it with the one involved in the `Subscriber` context,
we lose this context.

* Provide a mechanism to propagate a Reactor context over message header
produce within that context.
* Restore this context in the `FluxMessageChannel` for a new publisher
we use in this channel

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

* Fix language in docs

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

---------

Co-authored-by: Gary Russell <grussell@vmware.com>
2023-04-10 11:53:45 -04:00
tinyhhj
6dcdfa8fe4 Fix typo in the configuration.adoc 2023-04-05 14:16:45 -04:00
Adel Haidar
bfc6931329 GH-3869: Add ContextHolderRequestHandlerAdvice
Fixes https://github.com/spring-projects/spring-integration/issues/3869

* Move `ContextHolderRequestHandlerAdvice` to the `core` module for more general purposes
* Add `ContextHolderRequestHandlerAdviceTests`
* Rework `DelegatingSessionFactoryTests` to rely on the `ContextHolderRequestHandlerAdvice`.
This allows us to remove unnecessary XML configuration for this test class
* Document the feature
2023-03-31 17:44:19 -04:00
abilan
b0093ef161 TestXmlAppCtxHelper: Fix trailing white space 2023-03-30 10:47:46 -04:00
abilan
63937abf3e Migrate XML module tests to JUnit 5
* Use Java text blocks for xml snippets
2023-03-30 10:36:53 -04:00
Igor Lovich
e39449b643 GH-8582: Add TX support for PostgresSubChannel
Fixes https://github.com/spring-projects/spring-integration/issues/8582

* Introduce a `PostgresSubscribableChannel.setTransactionManager()`
to wrap a message polling and dispatching operation into a transaction
* In addition add a `RetryTemplate` support around transaction attempts

**Cherry-pick to `6.0.x`**
2023-03-29 12:34:47 -04:00
abilan
b326225df7 Fix tests for replyTimeout
Some tests deliberately don't expect a reply, but they still block
on a gateway's `sendAndReceive()`

* Improve `Jsr223ScriptExecutingMessageProcessorTests`
to verify that script variables work
2023-03-29 12:17:00 -04:00
abilan
8f83be2a91 Move adjustments for ImapMailReceiverTests 2023-03-29 10:36:24 -04:00
abilan
22acf51caa Increase timeout in the ImapMailReceiverTests 2023-03-29 10:27:16 -04:00
Artem Bilan
4fdbdf180e GH-8577: Revise ImapIdleChannelAdapter logic (#8588)
* GH-8577: Revise `ImapIdleChannelAdapter` logic

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

When we process mail messages in async manner, it is possible that we end up
in a race condition situation where the next idle cycle closes the folder.

It is possible to reopen the folder, but feels better to block the current idle
cycle until we are done with the message and therefore keep folder opened.

* Deprecate `ImapIdleChannelAdapter.sendingTaskExecutor` in favor of an `ExecutorChannel`
as an output for this channel adapter or similar async hand-off downstream.
* Make use of `shouldReconnectAutomatically` as it is advertised for this channel adapter
* Optimize the proxy creation for message sending task

* * Remove `ImapIdleChannelAdapter.sendingTaskExecutor`

* Fix language in docs

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

---------

Co-authored-by: Gary Russell <grussell@vmware.com>
2023-03-29 10:15:47 -04:00
abilan
22d47e72e9 Use Java text blocks for scripts in code
* Fix `WebServiceInboundGatewayParserTests` for reply timeout for
replies which never come accoridn the test logic
2023-03-28 18:50:34 -04:00
Auke Zaaiman
775e6fdac5 GH-8581: Don't overwrite external SshClient
Fixes https://github.com/spring-projects/spring-integration/issues/8581

Do not overwrite configuration of externally provided `SshClient` in the `DefaultSftpSessionFactory`

* Replace JUnit `assertDoesNotThrow` by AssertJ `assertThatNoException` in test

**Cherry-pick to `6.0.x`**
2023-03-28 11:23:39 -04:00
Spring Builds
6d7ee4616d [artifactory-release] Next development version 2023-03-22 21:39:30 +00:00
Spring Builds
531228bdb3 [artifactory-release] Release version 6.1.0-M2 2023-03-22 21:39:26 +00:00
abilan
047c8f3d9d Increase poll timeout in MessageGroupQueueTests
`100` milliseconds is not enough for all the environments
to achieve a proper async barrier
2023-03-22 16:58:50 -04:00
abilan
79870dc78c Upgrade dependencies; prepare for release
* Add `spring-web` test dep for `spring-integration-graphql` module
* Fix `MultipartAsRawByteArrayTests` according to the changes in the
`ByteArrayHttpMessageConverter` where it uses `ReadNBytes()` even for
`0` in `Content-Length` header
* Fix Kafka tests to use `RetryListener` interface with `default`
methods instead of already deprecated `RetryListenerSupport`
2023-03-22 16:41:03 -04:00
Artem Bilan
1bec420fd1 Do not block by default (#8580)
Currently, many timeouts in the project are like `-1` or other negative value
with a meaning to wait indefinitely.

According to distributed systems design and bad demo developing experience
it is not OK to block forever.

* Rework most of the timeouts in the framework to be `30` seconds.
Only one remained as `1` seconds is a `PollingConsumer` where it is
better to not block even for those 30 seconds when no messages in the queue,
but let the polling task be rescheduled.
* Remove the `MessagingGatewaySupport.replyTimeout` propagation down to the
`PollingConsumer` correlator where it was a `-1` before and blocked
the polling thread on the `Queue.poll()`.
This fixed the problem with a single thread in a pool for auto-configured `TaskScheduler`.
Now with 1 seconds wait time we are able to switch to other scheduled tasks
even with only 1 thread in the pool
2023-03-21 17:43:00 -04:00
Artem Bilan
fcb06bac61 Warn about dropped message in filter (#8579)
* Warn about dropped message in filter

Buy default the `MessageFilter` just drops a discarded message silently.
If a request-reply gateway is used upstream, then it becomes unclear
why the flow sometimes doesn't work.

* Add a waring log ot emit for default behavior.
This still doesn't fix the request-reply problem, but at least it can
give a clue what is going on

* * Mention `nullChannel` variant to ignore even warn

* Fix language in docs

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

---------

Co-authored-by: Gary Russell <grussell@vmware.com>
2023-03-20 13:19:19 -04:00
Artem Bilan
8ed4e5f444 Doc for @Gateway in the @MessagingGateway (#8578)
It is not obvious from the `@MessagingGateway` Javadocs how to configure
an individual service method

* Add links and explanation about per-method `@Gateway`
annotation into the `@MessagingGateway`
2023-03-20 12:52:47 -04:00
Artem Bilan
05f1fd89ba GH-8573: Fix KafkaMessageSource samples in docs (#8575)
Fixes https://github.com/spring-projects/spring-integration/issues/8573

* Also add a Kotlin DSL sample

**Cherry-pick to `6.0.x` & `5.5.x`**
2023-03-20 10:59:25 -04:00
Artem Bilan
1c90a60def GH-8566: Fix SftpSession.append() for Write (#8576)
Fixes https://github.com/spring-projects/spring-integration/issues/8566

Turns out some SFTP servers are strict enough to not let to append into existing file
if we don't give in addition a `Write` open mode flag as well

**Cherry-pick to `6.0.x`**
2023-03-20 10:56:03 -04:00
abilan
f2b88b4c6a Fix sonar smell in the MessagingGatewaySupport 2023-03-17 14:52:41 -04:00
abilan
db90e68ca7 Fix Sonar and JaCoCo relationship
* Explicitly enable Jacoco XML report
Must be `xml.required = true`
* Starting with version 3 the Sonarqube Gradle plugin
does not do any automatic dependencies on other tasks:
https://docs.sonarqube.org/latest/analyzing-source-code/scanners/sonarscanner-for-gradle/
* It is also does not apply the task to sub-projects.
So, to make the root `sonarqube` task we need to have config like this:
```
 rootProject.tasks['sonarqube'].dependsOn jacocoTestReport
```
Note: the `sonarqube` task is deprecated in favor of `sonar`,
but that is exactly what our current Bamboo Sonar plugin does.
So, when that is upgraded, we need to revise our config again
* We don't need `xml.outputLocation` since its default is what Sonar expects
2023-03-17 14:45:52 -04:00
Lyam Hunt
8b99178227 Fix typo in README.md 2023-03-16 16:37:09 -04:00
Anton Gabov
d7150685b1 RedisLockRegistry: Don't expire not acquired lock
Fix race condition, when methods `RedisLockRegistry#expireUnusedOlderThan` and `RedisLockRegistry#obtain` are executed successively. 

It's possible to delete the lock from `RedisLockRegistry#expireUnusedOlderThan` method, when lock is created but is not acquired (`RedisLock#getLockedAt = 0`)
It can lead to the situation, when `RedisLockRegistry#obtain` returns multiple locks with the same redis-key, which shouldn't happen at all.

* Skip locks from expiration when their `lockedAt == 0` - new, not acquired yet.

**Cherry-pick to `6.0.x` & `5.5.x`**
2023-03-15 11:18:03 -04:00
Artem Bilan
8fbf75f42c Some LockRegistryLeaderInitiator improvements (#8570)
* Some `LockRegistryLeaderInitiator` improvements

It is better to not go to the target lock provider at all
if the current thread is already interrupted.

* Check for the `Thread.currentThread().isInterrupted()` in the `while` loop
and `restartSelectorBecauseOfError()` immediately without checking for a lock
* Fix some other simple typos in the `LockRegistryLeaderInitiator`

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

* * Introduce a `LeaderSelector.yielding` flag
to revoke leader smoothly.
Turns out just canceling the `Future` may lead to a broken lock
where we cannot unlock it because the target lock repository may not work
with interrupted threads.
This way a new leader must wait until the lock is expired in the store
2023-03-15 10:10:02 -04:00
abilan
65271fc935 Fix Checkstyle for leading whitespaces 2023-03-07 12:09:49 -05:00
abilan
f0d21040b8 Fix new Sonar smells 2023-03-07 12:01:42 -05:00
abilan
f128a3f2eb Use sonar instead of deprecated sonarqube 2023-03-07 10:01:01 -05:00
abilan
1022d94dec Upgrade to Sonar 4.0.0.2929 2023-03-07 09:47:30 -05:00
abilan
4cbd22b583 Gradle 8.0.2, Dokka 1.8.10, Checkstyle 10.8.0 2023-03-06 09:23:03 -05:00
Chris Bono
3fad7cd96b Reduce instance supplier use to appease AOT
* Remove the use of instance suppliers on bean definitions
that are processed during the AOT phase.

* The remaining areas that use instance suppliers do so
at runtime and do not use reflection, but instead
are passed the configured bean to register.

See https://github.com/spring-cloud/spring-cloud-stream/issues/2655

**Cherry-pick to `6.0.x`**
2023-03-02 19:00:25 -05:00
Artem Bilan
dfe45c7c29 GH-8559: Document how to enable SOCKS for SFTP (#8565)
* GH-8559: Document how to enable SOCKS for SFTP

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

An out-of-the-box `SshClient` does not provide a smooth HTTP/SOCKS proxy configuration.

* Mention in the `sftp.adoc` that `JGitSshClient`, configured with SOCKS,
can be injected into a `DefaultSftpSessionFactory`
* Fix Javadocs for `DefaultSftpSessionFactory`, respectively

* Fix language in doc

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

---------

Co-authored-by: Gary Russell <grussell@vmware.com>
2023-02-28 17:33:31 -05:00
abilan
38f19348cf Upgrade to rome-2.0.0; fix deprecation
* Fix `FeedInboundChannelAdapterParser` to properly populate a `Resource` ctor arg
2023-02-28 16:48:30 -05:00
Artem Bilan
ce9f7f4321 GH-8562: Fix streaming source for remote calls (#8564)
* GH-8562: Fix streaming source for remote calls

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

The `AbstractRemoteFileStreamingMessageSource.doReceive()` takes files first from a `toBeReceived` queue.
When `AbstractRemoteFileStreamingMessageSource.remoteFileToMessage()` fails to fetch the file content
because of interim connection issue, we reset this file from a filter and rethrow an exception.
The next `receive()` call will just go ahead to the next entry in the `toBeReceived` queue, but the
file we have just failed for will be retried only on the next list call to the remove directory.
This essentially breaks a possible in-order target application logic.

* Introduce `AbstractRemoteFileStreamingMessageSource.strictOrder` option to clear the `toBeReceived` queue
 when we fail in the `remoteFileToMessage()`, so the next `receive()`
 call would re-fetch files from remote dir, because the filter has been reset for those files.
* Fix `AbstractFileInfo.toString()` to not perform remote calls when we just log this file.
For example, we reset the file for connection failure and log the message about it,
but it fails again because we request `size` of the file which may require a remote connection.

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

* * Revert `AbstractFileInfo` changes
* Override `toString()` in `SmbFileInfo` instead -
exactly the place where connection is used to obtain
file attributes like `size` or `lastModified`
2023-02-28 16:34:19 -05:00
Spring Builds
a09d6dcd2c [artifactory-release] Next development version 2023-02-22 22:41:07 +00:00