Commit Graph

11011 Commits

Author SHA1 Message Date
abilan
01b6ff678b Fix ConfigurableMongoDbMessageGroupStoreTests
The test methods for JUnit 4 must be `public`
2023-07-24 09:51:58 -04:00
Artem Bilan
07a17206bd GH-8685: Re-fetch group after setting condition (#8686)
* GH-8685: Re-fetch group after setting condition

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

The `AbstractCorrelatingMessageHandler` updates the group metadata in DB
not only for provided `condition`, but also a `lastModified` field.
A subsequent scheduling for group timeout takes the `lastModified`
to compare with the value in the store after re-fetching group in task.
This does not reflect reality since adding `condition` modifies the data in DB,
but in-memory state remains the same.

* Re-fetch a group from the store in the `AbstractCorrelatingMessageHandler.setGroupConditionIfAny()`.
* Verify expected behavior via new `ConfigurableMongoDbMessageGroupStoreTests.groupIsForceReleaseAfterTimeoutWhenGroupConditionIsSet()`

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

* * Fix Checkstyle violation in the test
2023-07-24 09:15:19 -04:00
Julian Koch
758997ecbb Fix ClientWebSocketContainerTests for current API
**Cherry-pick to `5.5.x`**
2023-07-18 11:15:34 -04:00
Julian Koch
fcf33c1fad GH-8678: Add BufferOverflowStrategy for WebScoket
Within Spring Integration's WebSocket support, a `ConcurrentWebSocketSessionDecorator`,
which buffers outbound messages if sending is slow,
is used to decorate all websocket sessions in `IntegrationWebSocketContainer`,
the standard entrypoint for using websockets with Integration.

* Expose a `ConcurrentWebSocketSessionDecorator.OverflowStrategy` option on the `IntegrationWebSocketContainer`

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

(cherry picked from commit be53593af9)

# Conflicts:
#	spring-integration-websocket/src/test/java/org/springframework/integration/websocket/ClientWebSocketContainerTests.java
2023-07-18 11:09:13 -04:00
Gary Russell
def23154ae GH-8668: Doc Correction
Boot is no longer releasing 2.6.x with latest dependencies.
2023-07-13 09:58:32 -04:00
Gary Russell
5e6547c758 GH-8668: AMQP Docs for Exclusive and S-A Consumers
Resolves https://github.com/spring-projects/spring-integration/issues/8668

**cherry-pick to all supported branches**

(cherry picked from commit fc3c8d2c8d)

# Conflicts:
#	src/reference/asciidoc/amqp.adoc
2023-07-12 16:59:42 -04:00
pziobron
9a54c23955 GH-8659: Fix WatchService to react for renames
Fixes https://github.com/spring-projects/spring-integration/issues/8659

* GH-8659: Updating the documentation as requested

* GH-8659: Fixes requested after coder review

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

(cherry picked from commit 0798c8df95)

# Conflicts:
#	spring-integration-file/src/main/java/org/springframework/integration/file/FileReadingMessageSource.java
2023-06-29 14:29:02 -04:00
Artem Bilan
794aa0a56e Fix Kotlin DSL delegation (#8658)
The `ConsumerEndpointSpec` extensions for Kotlin
don't delegate to the provided `endpointFactoryBean`

* Introduce `KotlinConsumerEndpointSpec` extension for `ConsumerEndpointSpec`
with the proper delegation to the provided spec
* Use `KotlinConsumerEndpointSpec` in the Kotlin-specific `Spec` classes

**Cherry-pick to `6.1.x`, `6.0.x` & `5.5.x`**
2023-06-26 15:13:18 -04:00
Vladislav Fefelov
42ed81faa9 Optimise maybeIndex() in JsonPropertyAccessor
The `NumberFormatException` flow control is costly
operation

* Use `Character.isDigit()` check iterating through property String
instead of `NumberFormatException` flow control

**Cherry-pick to `6.1.x`, `6.0.x` & `5.5.x`**
2023-06-16 13:45:33 -04:00
abilan
30f1420d73 Disable Rsocket fire-n-forget for race condition 2023-06-08 16:40:13 -04:00
abilan
1093430b78 Fix import in KafkaProducerMessageHandlerTests 2023-06-08 14:59:40 -04:00
Gary Russell
f9f16310af GH-8638: Kafka: Send All Fails to Failure Channel
Resolves https://github.com/spring-projects/spring-integration/issues/8638

Previously, immediate failures (e.g. timeout getting metadata) were
only thrown as exceptions, and not sent to the failure channel, if present.

**cherry-pick to all supported branches**
# Conflicts:
#	spring-integration-kafka/src/main/java/org/springframework/integration/kafka/outbound/KafkaProducerMessageHandler.java
2023-06-08 13:52:04 -04:00
Spring Builds
d641e728d7 [artifactory-release] Next development version 2023-05-16 16:20:41 +00:00
Spring Builds
862615d70a [artifactory-release] Release version 5.5.18 2023-05-16 16:20:38 +00:00
abilan
41de95bcb4 Upgrade dependencies; prepare for release 2023-05-16 11:17:30 -04:00
Artem Bilan
ccd3574dad Fix memory leak in the FluxMessageChannel (#8622)
The `FluxMessageChannel` can subscribe to any volatile `Publisher`.
For example, we can call Reactor Kafka `Sender.send()` for
input data and pass its result to the `FluxMessageChannel`
for on demand subscription.
These publishers are subscribed in the `FluxMessageChannel`
and their `Disposable` is stored in the internal `Disposable.Composite`
which currently only cleared on `destroy()`

* Extract `Disposable` from those internal `subscribe()` calls
into an `AtomicReference`.
* Use this `AtomicReference` in the `doOnTerminate()`
to remove from the `Disposable.Composite` and `dispose()`
when such a volatile `Publisher` is completed

**Cherry-pick to `6.0.x` & `5.5.x`**
# Conflicts:
#	spring-integration-core/src/main/java/org/springframework/integration/channel/FluxMessageChannel.java
2023-05-15 16:43:49 -04:00
Kazuki Shimizu
4ddc52571e GH-8609: Fix TcpConnectorInterceptor chain propagation
Fixes https://github.com/spring-projects/spring-integration/issues/8609

* Changed to passed the self instance to `addNewConnection()` instead of argument's connection
in a `TcpConnectionInterceptorSupport` to compose a chain of interceptors from top to down.
This way the target `Sender` get the last interceptor in a chain as its connection.

**Cherry-pick to `6.0.x` & `5.5.x`**
2023-05-05 09:34:36 -04:00
Artem Bilan
d89badf236 GH-8600: Fix WebSocket removeRegistration (#8601)
* GH-8600: Fix WebSocket `removeRegistration`

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

When we register a dynamic WebSocket endpoint and use a `WebSocketHandlerDecoratorFactory`
such an endpoint is not removed on an `IntegrationFlow` destruction.
The actual `WebSocketHandler` is decorated, however we still use an initial one
for condition.

* Refactor `IntegrationWebSocketContainer` to expose a `protected` setter for the
`WebSocketHandler` which is called from the `ServerWebSocketContainer` after decoration

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

* Fix language in Javadocs

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

---------

Co-authored-by: Gary Russell <grussell@vmware.com>
2023-04-19 13:05:15 -04:00
Artem Bilan
c44c2e6545 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:26:50 -04:00
Spring Builds
fea7a43ac3 [artifactory-release] Next development version 2023-03-22 15:07:07 +00:00
Spring Builds
392b59f793 [artifactory-release] Release version 5.5.17 2023-03-22 15:07:04 +00:00
abilan
08d8844680 Fix mail tests for new Greenmail requirements 2023-03-22 10:37:49 -04:00
abilan
2e682d160f Downgrade to Hibernate 5.5.9.Final 2023-03-22 10:19:32 -04:00
abilan
e19aa99776 Upgrade dependencies; prepare for release 2023-03-22 10:05:21 -04:00
Artem Bilan
dfae1a2e7d 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 11:03:03 -04:00
Anton Gabov
bdce2b9c8f 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`**
# Conflicts:
#	spring-integration-redis/src/test/java/org/springframework/integration/redis/util/RedisLockRegistryTests.java
2023-03-15 11:23:52 -04:00
Artem Bilan
efab65b2fa 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:38:48 -05:00
Artem Bilan
8e27b1ce1b GH-8550: MQTT: Always re-subscribe on re-connect (#8553)
Fixes https://github.com/spring-projects/spring-integration/issues/8550

Turns out the Paho MQTT client does not re-subscribe when connection re-established on automatic reconnection

* Fix `Mqttv5PahoMessageDrivenChannelAdapter` to always subscribe to its topics in the `connectComplete()` independently of the `reconnect` status
* Verify behavior with `MOSQUITTO_CONTAINER` image restart in Docker
2023-02-15 17:34:20 -05:00
Artem Bilan
b088091902 GH-4002: Deprecate ConsumerStopAction in MQTT (#4006)
Fixes https://github.com/spring-projects/spring-integration/issues/4002

Turns out the `ConsumerStopAction` was introduced in a point version to mitigate an unsubscription bug
and let to preserve a previous behaviour.

* Deprecate `ConsumerStopAction` in favor of just `cleanSession` flag in the `MqttConnectOptions`

**Cherry-pick to `5.5.x`**
2023-02-06 12:11:37 -05:00
abilan
070d1868e5 use CompleteToListeFutureAdapter in TcpOutGateway
The `TcpOutboundGateway` deals internally with a `CompletableFuture`.
However, the `AbstractMessageProducingHandler` cannot handle them until `6.0`.

* Use `CompletableToListenableFutureAdapter` to produce a reply from `TcpOutboundGateway`
which can be handled properly in the `AbstractMessageProducingHandler`
2023-01-23 11:35:23 -05:00
Artem Bilan
1aef04171f GH-3993: Fix async race condition in TcpOutGateway (#3995)
* GH-3993: Fix async race condition in TcpOutGateway

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

When `TcpOutboundGateway` is in an `async` mode and `CCF` is configured
not for `singleUse` an `Semaphore` around an obtained `TcpConnection` is involved.
If we fail on `TcpConnection.send()`, resources are not clean up, including the
mentioned `Semaphore`: in async mode this happens only when we receive a reply.

* Catch an exception on the `TcpConnection.send()` and perform `cleanUp()` in async mode.
* Add `cleanUp()` into a scheduled task from the `TcpOutboundGateway.AsyncReply`
when no reply arrives in time.
* Optimize `TcpOutboundGateway.AsyncReply` behavior to cancel no-reply scheduled task
when reply arrives into a `CompletableFuture`

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

* * Call `cleanUp()` from no response scheduled task
only if `future.completeExceptionally()` is `true`
2023-01-23 11:19:24 -05:00
abilan
0cce72a5bc Fix previous imports optimization for XML configs 2023-01-09 17:34:36 -05:00
abilan
aab52048f5 Realign imports code style with main 2023-01-09 17:11:07 -05:00
abilan
4a6e52f3f0 Some tweaks for SimpleMessageGroupTests
**Cherry-pick to `5.5.x`**
2023-01-09 16:28:37 -05:00
abilan
3ed301e99c GH-3986: Integration mock: fix ReactiveMH support
Fixes https://github.com/spring-projects/spring-integration/issues/3986

The `ReactiveStreamsConsumer` in addition to plain `Subscriber` and `MessageHandler`
also supports a `ReactiveMessageHandler`, but `MockIntegrationContext` doesn't
handle a scenario when `ReactiveMessageHandler` is provided for consumer

* Rework the logic in the `MockIntegrationContext` to substitute a `ReactiveMessageHandler`
in the `ReactiveStreamsConsumer` which has a precedence in its logic over plain `Subscriber`.
* Wrap a plain `MessageHandler` mock into a `ReactiveMessageHandler` before substitution
in the `ReactiveStreamsConsumer`
* Reset `ReactiveStreamsConsumer.reactiveMessageHandler` with source `ReactiveMessageHandler`
or `null` respectively to an original `ReactiveStreamsConsumer` configuration
* Mention `ReactiveMessageHandler` use-case in the `testing.adoc`

**Cherry-pick to `5.5.x`**
2023-01-09 15:53:12 -05:00
Spring Builds
6f67441556 [artifactory-release] Next development version 2022-12-20 18:15:50 +00:00
Spring Builds
3691584a48 [artifactory-release] Release version 5.5.16 2022-12-20 18:15:47 +00:00
abilan
567d52e33c Upgrade dependencies; prepare for release 2022-12-20 12:12:05 -05:00
Artem Bilan
626b14edb6 GH-3954: Fix WebFlux XML config for ambiguity (#3973)
* GH-3954: Fix WebFlux XML config for ambiguity

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

When `web-client` attribute is provided for the WebFlux outbound components configuration via XML,
the `encoding-mode` is silently ignored

* Check for `encoding-mode` attribute presence in the `WebFluxOutboundChannelAdapterParser`
when `web-client` is provided and throw respective exception to reject such a config

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

* * Improve error messages in the `WebFluxOutboundChannelAdapterParser`
2022-12-15 13:16:16 -05:00
abilan
e63edde7cb GH-3966: Kafka XML config: Expose more attributes
Fixes https://github.com/spring-projects/spring-integration/issues/3966

Exposed setters in the `KafkaInboundGateway` and `KafkaMessageDrivenChannelAdapter`
as an XML attributes for `kafka` namespace

**Cherry-pick to `5.5.x`**
2022-12-12 16:05:31 -05:00
Artem Bilan
280eb29f62 GH-3959: MqttConFailedEvent for normal disconnect (#3961)
* GH-3959: MqttConFailedEvent for normal disconnect

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

The `MqttCallback.disconnected(MqttDisconnectResponse)` in Paho v5 client is also
called when server initiates a disconnection.
In this case that `MqttDisconnectResponse` does not have a `cause` value

* Modify `MqttConnectionFailedEvent` to make a `cause` property optional
* Fix `Mqttv5PahoMessageDrivenChannelAdapter` & `Mqttv5PahoMessageHandler`
to not check for `cause`, but emit an `MqttConnectionFailedEvent` for any `disconnected()` calls

Unfortunately current Paho v3 client does not call `connectionLost()` for normal disconnections
and we cannot react for this callback with an `MqttConnectionFailedEvent`

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

* Fix language in doc

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

Co-authored-by: Gary Russell <grussell@vmware.com>
2022-12-07 08:58:10 -05:00
abilan
026feeeedf Fix mocks in Mqttv5AdapterTests
The logic in the `Mqttv5PahoMessageDrivenChannelAdapter` of version `5.5.x`
is based on a `subscribe(String[] topics, int[] qos)` API
2022-12-01 14:14:11 -05:00
mths1
36e4fe1fb5 GH-3955: Mqtt adapter unsubscribe when cleanStart
Fixes https://github.com/spring-projects/spring-integration/issues/3955

`Mqttv5PahoMessageDrivenChannelAdapter` unsubscribes from all topics, even if `cleanStart/cleanSession` is set to `false`, thus not receiving offline messages after restart.

* unsubscribe `Mqttv5PahoMessageDrivenChannelAdapter` only when `cleanStart`
* add tests

**Cherry-pick to `5.5.x`**
# Conflicts:
#	spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/inbound/Mqttv5PahoMessageDrivenChannelAdapter.java
2022-12-01 11:41:14 -05:00
Artem Bilan
067de96ab3 GH-3945: Fix not eligible for getting processed (#3947)
* GH-3945: Fix `not eligible for getting processed`

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

The `IntegrationManagementConfiguration` produces an `IntegrationManagementConfigurer` which is a `BeanPostProcessor`.
According to Spring recommendation this kind of infrastructure beans must be declared as `static`.
Due to an `implements ImportAware, EnvironmentAware` nature of the `IntegrationManagementConfiguration`,
we cannot use `static @Bean` method.
But since the `IntegrationManagementConfiguration` is not involved in any bean post-processing,
it is safe to follow recommendation and mark it as a `@Role(BeanDefinition.ROLE_INFRASTRUCTURE)`.

* Fix `MessagePublishingInterceptor` to initialize `MessagingTemplate` and `DestinationResolver` lazily
* Fix `AbstractMethodAnnotationPostProcessor` to initialize `DestinationResolver` lazily

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

* Use `getChannelResolver()` internally in the `AbstractMethodAnnotationPostProcessor`
instead of direct property access which might not be initialized yet
* Use a plain `boolean` for `templateInitialized` in the `MessagePublishingInterceptor`
to avoid skips in other thread where and move on with still not initialized properties

* Remove unused import

* Fix `this.` prefix for `beanFactory` property reference

# Conflicts:
#	spring-integration-core/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java
2022-11-15 15:28:42 -05:00
Artem Bilan
e4e80419c5 GH-3938: Fix HTTP XML configuration for ambiguity (#3939)
* GH-3938: Fix HTTP XML configuration for ambiguity

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

The `encoding-mode` is a property of the `RestTemplate`.
Therefore, it cannot be set on the component configuration together with
an externally injected `rest-template`

Even if `HttpRequestExecutingMessageHandler` has an assertion for such
an ambiguity, the XML parser just ignores this `encoding-mode`
when it encounters the `rest-template`

* Fix `HttpAdapterParsingUtils.verifyNoRestTemplateAttributes()` to check for not allowed
attributes with a `encoding-mode` as well
* Remove a `default` from the `encoding-mode` to not cause an ambiguity in the parser
* Fix some typos in the `spring-integration-http.xsd`
* Rework `OutboundResponseTypeTests` to JUnit 5

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

* * Fix error handling for `encoding-mode` in the `HttpAdapterParsingUtils`
* Cover `encoding-mode` and `rest-template` ambiguity with a test against failing XML configuration

* * Improve error message for ambiguous attributes in the `HttpAdapterParsingUtils`
2022-11-07 15:48:20 -05:00
Kicey
d45801b690 GH-3931: Fix meta-annotation support for @Gateway
Fixes https://github.com/spring-projects/spring-integration/issues/3931

* Update test for @AliasFor support.

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

# Conflicts:
#	spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayProxyFactoryBean.java
2022-11-02 10:26:02 -04:00
Artem Bilan
8f809a7489 Fix double start for AbstractEndpoint (#3928)
* Fix double start for `AbstractEndpoint`

When we use POJO methods in the `IntegrationFlowAdapter`,
the `IntegrationFlowAdapter` is set as a `target` for the `MessagingMethodInvokerHelper`.
When endpoint is started by the application context, such a `start()` is propagated
down to the `MessagingMethodInvokerHelper`.
And in our case back into an `IntegrationFlowAdapter` instance.
This one, in turn, starts its `IntegrationFlow` internally which leads to the
start of the mentioned endpoint in the beginning.
Therefore, we cause a recursive `start()` call on this endpoint from itself.
The `running` flag is set when we are already done with the `doStart()` logic.
Therefore a recursive `start()` call leads to two concurrent polling tasks
in the `AbstractPollingEndpoint`.

* Check also for the `active` flag in the `AbstractEndpoint.start()`
and reset it in case of exception in the `doStart()`

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

* * Change assert for message timestamps to `isCloseTo()` with percentage

* * Change `catch` in the `AbstractEndpoint.start()` to `RuntimeException`:
the `doStart()` cannot throw unchecked exceptions by definition

* * Fix imports in `AbstractEndpoint`
2022-10-27 10:10:44 -04:00
Artem Bilan
56634c94ac GH-3912: Handler: ignore Groovy generated methods
Fixes https://github.com/spring-projects/spring-integration/issues/3912

**Cherry-pick to `5.5.x`**
2022-10-18 13:44:54 -04:00
Spring Builds
3602a0f1a4 [artifactory-release] Next development version 2022-09-20 21:39:56 +00:00
Spring Builds
00ce1ae4a8 [artifactory-release] Release version 5.5.15 2022-09-20 21:39:52 +00:00