Commit Graph

10185 Commits

Author SHA1 Message Date
Artem Bilan
0cd669fee9 Revert "Fix @InChAdapter for several suppliers"
This reverts commit cd9173cd95.
2020-10-22 12:06:07 -04:00
Artem Bilan
cd9173cd95 Fix @InChAdapter for several supplier beans
The `InboundChannelAdapterAnnotationPostProcessor` doesn't use a bean method name
when it parses a `Supplier` bean and only uses a configuration class name + `get`
for method part

* Fix `InboundChannelAdapterAnnotationPostProcessor` to also include a bean method
name into the final bean name for the `MethodInvokingMessageSource` based on
the `Supplier` bean
* Modify `ReactiveInboundChannelAdapterTests` to add one more `Supplier` with the
`@InboundChannelAdapter` to ensure that configuration is still valid after the fix

**Cherry-pick to 5.2.x & 5.1.x**
2020-10-22 12:03:06 -04:00
Artem Bilan
3b60e45679 Gateway: Propagate Error to the errorChannel
See SO for more info:
https://stackoverflow.com/questions/64456946/handle-exceptions-errors-other-than-messagingexception-ie-other-error-excepti

In the versions before `5.2.x` the `Error` was wrapped to the `MessagingException`
in the `AbstractRequestHandlerAdvice` and this one was handled properly
on the gateway level with its `errorChannel` configured

* Fix `MessagingGatewaySupport` to catch all the `Throwable` and try to send them as `ErrorMessage`
to the `errorChannel`.
Otherwise unwrap returned `MessagingException` and re-throw an `Error` as is to keep
the current behavior for non-handled exceptions

* Do not wrap `Error` into a `MessagingException` and re-throw as is if there is no `errorChannel`

**Cherry-pick to 5.3.x & 5.2.x**
2020-10-22 11:42:26 -04:00
Artem Bilan
d60f23549c Fix MeterRegistry eager load
If there is a `MeterRegistry` bean (any) in the application context,
we add a `MicrometerMetricsCaptor` bean which populates meters further
from the components.
In some case we may load a `MicrometerMetricsCaptor` bean too early
so, not all the stuff around `MeterRegistry` maybe ready.
See Spring Boot and its `MetricsAutoConfiguration`

* Fix the `MicrometerMetricsCaptorRegistrar` the way to rely on the
`ObjectProvider<MeterRegistry>` instead
* Add package protected ctor to the `MicrometerMetricsCaptor` to
provide a target `MeterRegistry` on demand

All of that will ensure that we use an already post-processed `MeterRegistry`
including Spring Boot auto-configuration

**Cherry-pick to 5.3.x & 5.2.x**
2020-10-15 15:17:28 -04:00
Gary Russell
cab16c41f4 GH-3395: Fix XML expression default for ARFOGateway
Resolves https://github.com/spring-projects/spring-integration/issues/3395

Outbound remote file gateway parser requires `expression` even though some
commands don't need or use it.

* Propagate the empty string for `expression` attribute
* Fix default (`payload`) expression logic in the `AbstractRemoteFileOutboundGateway`

**Cherry-pick to `5.3.x`**
2020-10-02 14:34:46 -04:00
Artem Bilan
e649480350 Fix IntegrationReactiveUtils
The `Mono.doOnSuccess()` is always called for completed `MonoSink`
even if the value is `null`

* Fix `IntegrationReactiveUtils.messageSourceToFlux()` to check a
message for `null` before calling `AckUtils.autoAck()`
* Add an `logger.error()` message when `doOnError()` is invoked for that `Mono`

**Cherry-pick to 5.3.x**
2020-09-24 09:48:51 -04:00
Artem Bilan
d0cab670eb GH-3376: Remove gauges on application ctx close (#3377)
* GH-3376: Remove gauges on application ctx close

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

The `MeterRegistry` may request meters on application shutdown.
The gauges for channels, handlers and message sources don't make sense
at the moment since all those beans are going to be destroyed.

* Remove gauges for channel, handler and message source numbers from the
`IntegrationManagementConfigurer.destroy()`

**Cherry-pick to 5.3.x & 5.2.x**

* * Add `MicrometerImportSelector` to conditionally load
a  `MicrometerMetricsCaptorConfiguration` when `MeterRegistry`
is on class path.
* Make `MicrometerMetricsCaptorConfiguration.integrationMicrometerMetricsCaptor()`
 bean dependant on the `ObjectProvider<MeterRegistry>`
* Make `IntegrationManagementConfiguration.managementConfigurer()`
dependant on the `ObjectProvider<MetricsCaptor>`.
This way the `IntegrationManagementConfigurer` is destroyed before
`MeterRegistry` when application context is closed
* Deprecate `MicrometerMetricsCaptor.loadCaptor()` in favor of
`@Import(MicrometerImportSelector.class)`

* * Add `MicrometerMetricsCaptorRegistrar` to register a `MICROMETER_CAPTOR_NAME`
bean when `MeterRegistry` is on class path and no `MICROMETER_CAPTOR_NAME` bean yet.
* Make `IntegrationManagementConfiguration.managementConfigurer()`
dependant on the `ObjectProvider<MetricsCaptor>`.
This way the `IntegrationManagementConfigurer` is destroyed before
`MeterRegistry` when application context is closed
* Deprecate `MicrometerMetricsCaptor.loadCaptor()` in favor of
`@Import(MicrometerMetricsCaptorRegistrar.class)`
* Fix test to make a `MeterRegistry` bean as `static` since
`@EnableIntegrationManagement` depends on this bean definition now

# Conflicts:
#	spring-integration-core/src/main/java/org/springframework/integration/config/EnableIntegrationManagement.java
#	spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationManagementConfiguration.java
#	spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationManagementConfigurer.java

* Fix some deprecation warnings
2020-09-16 11:24:44 -04:00
Artem Bilan
411e9945c3 GH-3372: Expose (S)FTP remoteComparator for DSL
Fixes https://github.com/spring-projects/spring-integration/issues/3372

**Cherry-pick to 5.3.x & 5.2.x**
2020-09-14 16:50:11 -04:00
Artem Bilan
059bc896ff GH-3373: Support IPV6 in AbstractInboundFileSynch
Fixes https://github.com/spring-projects/spring-integration/issues/3373

The `AbstractInboundFileSynchronizer` doesn't consider that
`hostPort` from `Session` could be in an IPv6 syntax

* Parse the `hostPort` from `Session` in a manner that only the last
`:` is treated as a port delimiter

**Cherry-pick to 5.3.x & 5.2.x**
2020-09-14 16:07:35 -04:00
Artem Bilan
5e98f6d7f3 GH-3374: Fix scan for BF propagation (#3378)
* GH-3374: Fix scan for BF propagation

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

An internal `ClassPathScanningCandidateComponentProvider` instance in the `IntegrationComponentScanRegistrar`
does not propagate a provided `registry`.

* Implement `getRegistry()` on the internal `ClassPathScanningCandidateComponentProvider` to propagate
a provided into the `registerBeanDefinitions()` a `BeanDefinitionRegistry`
* Add `@Conditional` on some scanned `@MessagingGateway` in the `EnableIntegrationTests`

**Cherry-pick to 5.3.x & 5.2.x**

* * Remove unused import

* Restore `unused` warning on the unused registry arg
2020-09-11 09:49:06 -04:00
Artem Bilan
30e4642a18 GH-3370: Remove synchronized from RemoteFileUtils (#3380)
* GH-3370: Remove synchronized from RemoteFileUtils

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

The `synchronized` on the `RemoteFileUtils.makeDirectories()` makes an application too
 slow, especially when we deal with different paths in different sessions

* Remove the `synchronized` from that method and rework `SftpSession.mkdir()`
to return `false` when "A file cannot be created if it already exists" exception
is thrown from the server.
Essentially make an `exists()` call to be sure that an exception is really related
to "file-already-exists" answer from the server

**Cherry-pick to 5.3.x, 5.2.x & 4.3.x**

* * Re-throw an exception in the `SftpSession.mkdir()`
when error code is not `4` or remote dir does not exist

* * Check `session.mkdir()` result in the
`RemoteFileUtils` to throw an `IOException` when `false`

* * Fix mock test to return `true` for `mkdir` instead of `null`
2020-09-10 13:47:31 -04:00
Artem Bilan
2cba979129 Fix count and update in MongoDb stores
* The `into()` query can't infer the type for entity if we provide `Object.class`
* The `updateFirst()` does not support sort queries any more - replace with `findAndModify()`
* Add `getMessageGroupCount()` into tests

**Cherry-pick to 5.3.x & 5.2.x**
2020-08-20 16:46:03 -04:00
Artem Bilan
b20d27644b Add gauges for queue channel size (#3349)
* Add gauges for queue channel size

The `QueueChannel` provides a current size and remaining capacity metrics

* Add Micrometer gauges into `QueueChannel` to expose the current values
of the size and remaining capacity

**Cherry-pick to 5.3.x, 5.2.x & 5.1.x**

* * Revert `@SuppressWarnings("unchecked")` for test
* Document new gauges for queue channel

* * Fix IntegrationManagementConfigurer for NPE on `metricsCaptor`

* Fix wording in meter descriptions

Co-authored-by: Michel Jung <michel.jung89@gmail.com>

Co-authored-by: Michel Jung <michel.jung89@gmail.com>
2020-07-28 17:00:28 -04:00
Spring Buildmaster
84234b286a [artifactory-release] Next development version 2020-07-22 17:57:59 +00:00
Spring Buildmaster
081b145843 [artifactory-release] Release version 5.3.2.RELEASE 2020-07-22 17:57:54 +00:00
Artem Bilan
e3be340bad Improve MessageKryoRegistrar for registrations
(cherry picked from commit 5ec71d4b4a)
2020-07-22 13:36:38 -04:00
Artem Bilan
66be7fde2d Upgrade dependencies; prepare for release 2020-07-22 12:45:14 -04:00
Artem Bilan
f6587e29de Fix typo in KryoCodecTests
(cherry picked from commit 5e45b09cd5)
2020-07-22 12:33:42 -04:00
Artem Bilan
23f3482e8f Improve Kryo Codec for registrations 2020-07-22 12:07:45 -04:00
Artem Bilan
f095f94c74 GH-3348: Upgrade to MQTT Paho-1.2.4
Fixed https://github.com/spring-projects/spring-integration/issues/3348

**Cherry-pick to 5.3.x, 5.2.x & 5.1.x**

# Conflicts:
#	build.gradle
2020-07-21 10:13:01 -04:00
Artem Bilan
dfa6c847f8 GH-3344: Treat kotlin.Unit return as null in MMIH (#3346)
* GH-3344: Treat kotlin.Unit return as null in MMIH

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

When function lambda doesn't return anything (e.g. a `void` method call is the last one),
Kotlin produces a `kotlin.Unit` instance as a return value which is not null and produced
as a reply message payload.

* Fix `MessagingMethodInvokerHelper` to treat a `kotlin.Unit` as `null` for reply
making Kotlin lambdas working the same way as Java lambdas when we don't return anything
from from there

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

* * Introduce `ClassUtils.isKotlinUnit(Class)` API;
use it in the `MessagingMethodInvokerHelper` instead of
`.getName().equals()`

* * Fix since on new `isKotlinUnit()` API
2020-07-20 13:52:41 -04:00
Artem Bilan
ca60db50a3 SO-62761903: Inject BF into Gateway's correlator
Related to https://stackoverflow.com/questions/62761903/spring-integration-reactive-streams-support-exception-in-creating-a-reactive

The `MessagingGatewaySupport` creates an internal endpoint
for consuming messages from the provided `replyChannel`.
The endpoint type depends on the channel type.
The `ReactiveStreamsConsumer` was missing a `BeanFactory` injection
causing an error when `ReactiveStreamsConsumer` tries to extract a default `ErrorHandler`
from `BeanFactory`

* Refactor `MessagingGatewaySupport` to inject a `BeanFactory` to all
the possible correlator endpoints.
Also always call `afterPropertiesSet()` for all of them

**Cherry-pick to 5.3.x & 5.2.x**
2020-07-08 14:59:23 -04:00
Gary Russell
a8c63e2991 Fix CachedSessionFactory Race
Close the pool so that any sessions returned after the factory is
`destroy()`ed are closed.

* Call `removeAllIdleItems()` in `close()`.

* Close sessions in `SftpStreamingMessageSourceTests`.

**cherry-pick to all supported branches**
2020-07-08 14:20:58 -04:00
Alexander Shaklein
3857157ac1 GH-3324. fix NPE in StdIntFlowContext
Fixes https://github.com/spring-projects/spring-integration/issues/3324

The `StandardIntegrationFlowContext.remove()` has a possible NPE

**Cherry-pick to 5.3.x & 5.2.x**

(cherry picked from commit 7424cb215c)
2020-07-04 15:59:32 -04:00
Artem Bilan
9082c12ba1 Fix MessagingGatewaySupport for reactive error (#3319)
* Fix MessagingGatewaySupport for reactive error

The `onErrorResume()` was in a wrong place for the
`doSendAndReceiveMessageReactive()`: we have to catch all the exceptions
from the top level `Mono`, not only a reply one as it was before.

Ensure in HTTP and WebFlux test that behavior is fixed

**Cherry-pick to `5.3.x` & `5.2.x`**

* * Remove unused imports

Co-authored-by: Artem Bilan <abilan@vmware.com>
2020-07-01 15:54:24 -04:00
Gary Russell
9cd8a4a0dd GH-3315: Fix (S)FTP Stream with Fair Rotation
Resolves https://github.com/spring-projects/spring-integration/issues/3315

`maxFetchSize` ignored with filters supporting single file filtering (default).
This breaks "fair" rotation with the `RotatingServerAdvice`.

Honor `maxFetchSize`, even with filters that support single file filtering.

**cherry-pick to 5.3.x, 5.2.x**
2020-07-01 15:48:40 -04:00
astrubel
434817fc2c GH-3307: Retry TransTimedEx in LockRepo.acquire
Fixes https://github.com/spring-projects/spring-integration/issues/3307

The `DefaultLockRepository.acquire()` is transactional method and
can fail with the `TransactionTimedOutException`.
When we call `JdbcLock.lock()`, we expect an attempt until we really obtain a lock.

* Treat a `TransactionTimedOutException` as a `TransientDataAccessException` and
therefore retry a locking attempt logic

**Cherry-pick to 5.3.x, 5.2.x & 4.3.x**

(cherry picked from commit b0cd0156c7)
2020-06-16 12:21:26 -04:00
Spring Buildmaster
8bacf36421 [artifactory-release] Next development version 2020-06-10 17:27:28 +00:00
Spring Buildmaster
08316577ce [artifactory-release] Release version 5.3.1.RELEASE 2020-06-10 17:27:24 +00:00
Artem Bilan
33b3ab9e0c Upgrade dependencies; prepare for release 2020-06-10 13:04:01 -04:00
Gary Russell
29e8f07d88 GH-3299: Fix client connectionId for TCP/NIO
Resolves https://github.com/spring-projects/spring-integration/issues/3299

Connect before creating the `TcpNioConnection` object and publishing the
`TcpConnectionOpenEvent`.

This was a regression caused by supporting connect timout; which moved
the connect to after the object was created and event published, causing
the `connectionId` to start with `unknown`.

**cherry-pick to 5.3.x, 5.2.x**
2020-06-10 09:43:55 -04:00
artembilan
d958e36671 Code clean up for JacksonJsonUtils
* Mention `trustedPackages` in the `redis.adoc`

**Cherry-pick to 5.3.x, 5.2.x, 5.1.x & 4.3.x**
2020-06-09 14:51:32 -04:00
astrubel
e3701746f3 GH-3294: Retry JdbcLock.unlock for TransDataAccEx
Fixes https://github.com/spring-projects/spring-integration/issues/3294

A `DeadlockLoserDataAccessException` occurs at `JdbcLockRegistry$JdbcLock.unlock()` - 
better to retry like in the `lock()`

**Cherry-pick to 5.3.x, 5.2.x, 5.1.x & 4.3.x**
2020-06-09 13:29:43 -04:00
artembilan
d7549a94ae Fix NPE for component name after FactoryBeans
SO: https://stackoverflow.com/questions/62190244/spring-integration-upgrade-from-5-2-x-to-5-3-problem

When the component is populated to the application context via `FactoryBean`,
all its `BeanFactory` callbacks should be propagated from that `FactoryBean` -
only lifecycle control for this component we have through its `FactoryBean`

**Cherry-pick to 5.3.x**
2020-06-09 11:06:05 -04:00
Gary Russell
8561518753 GH-2736: TCP Async GW - Fix async check
Checking for NIO cannot be done in `onInit()` because the factory is
not yet started.

**cherry-pick to 5.3.x**
2020-06-02 11:19:08 -04:00
Artem Bilan
e309ebb940 GH-3288: Add Kotlin DSL transform(Transformer)
Fixes https://github.com/spring-projects/spring-integration/issues/3288

* For better end-user experience with Kotlin DSL and get a gain from
existing `Transformer` implementations add a `transform(Transformer)`
EI-method into the `KotlinIntegrationFlowDefinition`
* Also add `filter(MessageSelector)` for any out-of-the-box `MessageSelector`

**Cherry-pick to 5.3.x**
2020-05-27 13:40:35 -04:00
Vladimir Plizga
28a5be7a64 GH-3286: Make FileTailingEvent#getMessage public
Fixes https://github.com/spring-projects/spring-integration/issues/3286

The `FileTailingEvent.getMessage()` is really meant to be as `public`

**Cherry-pick to 5.3.x, 5.2.x, 5.1.x & 4.3.x**
2020-05-21 09:49:26 -04:00
Artem Bilan
aec7bed522 GH-3282: Fix JdbcMetadataStore for DuplicateKeyEx (#3285)
* GH-3282: Fix JdbcMetadataStore for DuplicateKeyEx

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

The `INSERT INTO ... SELECT ... FROM ... HAVING` may fail with
`DuplicateKeyException` in between transactions.
* Catch `DuplicateKeyException` from in the `tryToPutIfAbsent()`
and return `0` as a fact of not inserted to let other logic to work
as expected.

There is no test coverage for this since it is almost impossible to
reproduce such a race condition on DB

**Cherry-pick to 5.3.x & 5.2.x**

* * Remove misleading message in the comment sentence
2020-05-20 14:46:15 -04:00
Gary Russell
42845f03f3 Convert (S)FTP Tests to JUnit5
* Fix SftpTestServer for latest RemoteFileTestSupport changes.
2020-05-18 14:27:45 -04:00
Spring Buildmaster
bc84d47da0 [artifactory-release] Next development version 2020-05-13 20:34:34 +00:00
Spring Buildmaster
8fd0f06854 [artifactory-release] Release version 5.3.0.RELEASE 2020-05-13 20:34:29 +00:00
Artem Bilan
9e1979f62a Upgrade dependencies; prepare for release 2020-05-13 16:03:18 -04:00
Artem Bilan
bf0260a616 GH-3276: reactive inbound: Fix onErrorResume
Fixes https://github.com/spring-projects/spring-integration/issues/3276

The `onErrorResume` for the `MessagingGatewaySupport.doSendAndReceiveMessageReactive()`
was in wrong place: only for the `buildReplyMono` which works only
when an outbound flow is fully based on reactive channels.
With a regular direct channel we can get an exception from the
`sendMessageForReactiveFlow` which is not covered with the mentioned
`onErrorResume` for the error handling on the configured `errorChannel`

Cherry-pick to `5.2.x & 5.1.x`
2020-05-13 15:24:18 -04:00
Artem Bilan
79056581f0 Fix RESOLVABLE_TYPE header population
* We should not build a RESOLVABLE_TYPE header when we map requests.
Only for replies. See: https://github.com/spring-projects/spring-integration-samples/issues/277
* We should log `ClassNotFoundException` only at debug level - to noise with info or warn

**Cherry-pick to 5.2.x**
2020-05-13 13:06:46 -04:00
Yury Kartsev
6bd5ca4cbe Fix XML examples in handler-advice reference doc
1. Add proper terminating tags for `request-handler-advice-chain`.
2. Replace `int:request-handler-advice-chain` with `int-http:request-handler-advice-chain` when used inside of an `int-http:outbound-gateway`.
3. Replace `<bean ref="*" />` with `<ref bean="*" />`
4. Replace `</int:int:service-activator>` with `</int:service-activator>`
2020-05-13 12:16:13 -04:00
Yury Kartsev
aa26d2fc64 Fix typo in reference manual
Fix typo in reference manual for transaction support.
2020-05-11 20:52:05 -04:00
Artem Bilan
d71fb2e5da GH-3271: Close session on error in stream source
Fixes https://github.com/spring-projects/spring-integration/issues/3271

When exception happens at `.withPayload(session.readRaw(remotePath))`
in the `AbstractRemoteFileStreamingMessageSource` we don't close session.
The resource leaking happens in the caching session factory

* Add `session.close();` into the `catch (IOException e) {`
in the `AbstractRemoteFileStreamingMessageSource.doReceive()`
to clean up resources properly

**Cherry-pick to 5.2.x, 5.1.x & 4.3.x**
2020-05-11 16:40:55 -04:00
Artem Bilan
f047f0528b Fix Checkstyle to rely on the absolute path
It turns out that relative path in the property
`<property name="file" value="src/checkstyle/checkstyle-suppressions.xml"/>`
in some cases is resolved against a Gradle deamon dir as a root for configs

* Fix Checkstyle plugin config to use an absolute path in the project for
the `configDirectory`.
* Since `configDirectory` is exposed as a Checkstyle config variable,
we can use its `${config_loc}` placeholder to rely on the absolute path
in the project
2020-05-06 15:53:28 -04:00
Gary Russell
3e63fe4eb7 BoundRabbitChannelAdvice - reject invalid config
Don't allow a `waitForConfirmsTimeout` if the factory is not configured
for simple publisher confirmations.

Otherwise, a runtime error will occur.

**cherry-pick to 5.2.x, 5.1.x**
2020-04-29 15:12:31 -04:00
Spring Buildmaster
346762a0e2 [artifactory-release] Next development version 2020-04-29 18:03:21 +00:00