Commit Graph

10843 Commits

Author SHA1 Message Date
Artem Bilan
85efb5f53c Take Docker registry from the DOCKER_REGISTRY_URL
Add a logic into the `TestUtils` to take a Docker registry URL
from the `DOCKER_REGISTRY_URL` ENV variable.
Use the value in the `GenericContainer` for image to pull.
Fallback to an official registry if no value
2021-11-10 17:19:41 -05:00
Artem Bilan
7f83f5f74a Revert AnnotationGatewayProxyFactoryBean logic
The `AnnotationGatewayProxyFactoryBean` can be configured via setters
and via annotation in the provided interface.

* Override `setProxyDefaultMethods()` to `true` only if annotation explicitly
provides `true`
2021-11-10 16:35:04 -05:00
Artem Bilan
5de072b666 Fix WebFluxMH for proper response handling
The `WebFluxRequestExecutingMessageHandler` does direct `ClientResponse.create(entity.getStatusCode())`
which comes with a `ExchangeStrategies.withDefaults()`.
Even if end-user configures a `WebClient` properly, the response is created with default strategies.

* Rework `WebFluxRequestExecutingMessageHandler` internal logic to call `ResponseSpec.toEntityFlux(BodyExtractor)`
instead of manual `ClientResponse.create()`
* Add unit test to the `WebFluxRequestExecutingMessageHandlerTests` to ensure that configured `maxInMemorySize`
on the `WebClient` strategies has an effect when response body is bigger than expected size

**Cherry-pick to `5.4.x`**
2021-11-10 16:06:06 -05:00
Artem Bilan
a27b1ec28f Revert method references back to lambdas
Turns out Java does cast for the method reference argument before really calling
a delegating method.

* Revert cast method references (`((ApplicationContextAware) this.handler)::setApplicationContext`)
back to lambdas - `context -> ((ApplicationContextAware) this.handler).setApplicationContext(this.applicationContext)`
This way the cast is deferred until the lambda is called.
2021-11-10 16:03:50 -05:00
Artem Bilan
0aac4c0a86 Fix new Sonar smells 2021-11-10 14:55:48 -05:00
unseok kim
e51513230a GH-3655: Add automatically delete for Redis Locks
Fixes https://github.com/spring-projects/spring-integration/issues/3655

* support automatically clean up cache
* RedisLockRegistry.capacity desc
2021-11-10 14:24:53 -05:00
Artem Bilan
25100d1ac7 Fix unused import in the IntegrationRegistrar 2021-11-05 10:31:51 -04:00
Artem Bilan
a899b37ac3 DefaultConfiguringBFPP to BDRegistryPP
* Make a `DefaultConfiguringBeanFactoryPostProcessor` as a `BeanDefinitionRegistryPostProcessor`
to let it be processed properly in Spring AOT
* Register `DefaultConfiguringBeanFactoryPostProcessor` as a `BeanDefinition.ROLE_INFRASTRUCTURE`,
so it is removed in Spring AOT after processing and writing target bean definitions
2021-11-05 10:24:18 -04:00
StandCN
e80a42d394 Fix typo in the MqttMessageSentEvent Javadoc 2021-11-05 09:45:45 -04:00
Artem Bilan
d86647807e Use ReflectionUtils.makeAccessible() - not direct
The `LambdaMessageProcessor` and `MethodInvokingMessageSource`
 call `method.setAccessible(true)` unconditionally.

* Use `ReflectionUtils.makeAccessible()` for some optimization
* Remove `Content is not allowed in prolog` from the `JaxbMarshallingIntegrationTests`
since it is locale dependant and not relevant for the unit test logic
2021-11-03 10:54:24 -04:00
Mauro Molinari
15520e120c GH-3652: File gateway: don't try delete no file
Fixes spring-projects/spring-integration#3652

Do not try to delete non-existing file in `FileExistMode.REPLACE` in the `AbstractRemoteFileOutboundGateway`

**Cherry-pick to `5.4.x` & `5.3.x`**
2021-11-03 10:06:31 -04:00
Artem Bilan
eb4d583a17 Add toReactivePublisher(autoStartOnSubscribe) (#3657)
* Add `toReactivePublisher(autoStartOnSubscribe)`

The `IntegrationFlowBuilder.toReactivePublisher()` returns a `Publisher<Message<?>>`
which may be subscribed somewhere late in the application logic, e.g.
when WebSocket (or RSocket) subscription is initiated by the external client.
In between application context startup and that subscription moment, the `IntegrationFlow`
must not try to produce messages since there is nothing to consumer them from the
`Publisher<Message<?>>` side.
One of the way is to have a source endpoint not started automatically and control its
lifecycle from the point fo reactive subscription

* Introduce an `IntegrationFlowBuilder.toReactivePublisher(boolean autoStartOnSubscribe)`
to let the framework do a job for an `IntegrationFlow` lifecycle control.
This way end-user doesn't need to know autowire a starting endpoint and use `doOnSubscribe()`
and similar callbacks
* Change `ConsumerEndpointFactoryBean` log message about a `FixedSubscriberChannel`
to `INFO` since an `autoStartup = false` really does not have any effect and there is nothing
for end-user to worry about.
The `IntegrationFlow` knows nothing about each endpoint internals and cannot control which
mark as `autoStartup = false` and which not

* Fix languge in JavaDocs

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

Co-authored-by: Gary Russell <grussell@vmware.com>
2021-11-01 16:49:59 -04:00
Artem Bilan
fc7d338302 GH-3656: Fix package tangles
Fixes https://github.com/spring-projects/spring-integration/issues/3656

* Move `JavaUtils` from `util` package to the root one to break any possible
tangling to/from other packages.
* Deprecate an existing `JavaUtils` for backward compatibility
* Remove `@IntegrationConverter` from the `JsonNodeWrapperToJsonNodeConverter`
and register it manually in the `ConverterRegistrar`.
The bean registration for the `JsonNodeWrapperToJsonNodeConverter` must be removed
in the next `6.0`
* Remove usage of `IntegrationContextUtils` from the `support` package
2021-11-01 15:06:01 -04:00
Artem Bilan
f520156053 GH-3653: Improve DSL parsing performance (#3654)
* GH-3653: Improve DSL parsing performance

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

* Refactor `IntegrationFlowBeanPostProcessor` to perform `beanFactory.getBeansOfType()`
as less as possible
* Implement a `NamedComponent` on the `StandardIntegrationFlow` for better
bean scanning performance in the `IntegrationFlowBeanPostProcessor`

* * Skip `NamedComponent` from bean scanning if `beanName == null`
2021-11-01 10:25:38 -04:00
Artem Bilan
ff3b4d34a1 Fix Checkstyle violation in the XML config 2021-10-22 15:51:14 -04:00
Artem Bilan
ffdc992f2e Rework JpaOutboundGatewayParserTests to JUnit 5 2021-10-22 15:28:26 -04:00
Artem Bilan
ee8afc5b28 BeanDefinitions: Mix instanceSupplier and props 2021-10-22 15:17:46 -04:00
Artem Bilan
7d29cf7f02 Fix double the typo in docs 2021-10-21 14:17:35 -04:00
Artem Bilan
78366e7b00 GH-3647: Use remoteDirExpression in MV command (#3651)
* GH-3647: Use remoteDirExpression in MV command

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

To simplify a source and renameTo remote file expressions, the `remoteDirectoryExpression`
is consulted now, when they are not full paths.
This is useful when we want just to rename a remote file in some dir

* * Add JavaDoc for `getDirectoryExpressionProcessor()`
* Fix language in docs
2021-10-21 14:12:50 -04:00
Gary Russell
e84bab6e0a GH-3648: Fix @Gateway.payloadExpression
Resolves https://github.com/spring-projects/spring-integration/issues/3648

When configuring a gateway proxy with XML, but specifying the payload expression
on the method `@Gateway` annotation, the expression was ignored, even though it
had been parsed.

`@Payload` worked.

With this change, if both `@Payload` and `@Gateway` are defined on a gateway method,
`@Gateway.payloadExpression` wins.

* Fix doc links.
2021-10-20 15:09:29 -04:00
Spring Builds
035581b421 [artifactory-release] Next development version 2021-10-19 19:00:50 +00:00
Spring Builds
c822eb2204 [artifactory-release] Release version 5.5.5 2021-10-19 19:00:47 +00:00
Artem Bilan
d61df01acf Fix DSL sample in the doc
* Improve JavaDocs for `BaseIntegrationFlowDefinition` with renaming `payloadType`
param to `expectedType` since it can also be as a `Message.class`, not only type
for the payload.
* Add JavaDoc for `LambdaMessageProcessor` ctor
2021-10-19 14:19:58 -04:00
Anthony Schweigard
7e5fef9e45 GH-3641: Handle duplicate cookies properly
Fixes https://github.com/spring-projects/spring-integration/issues/3641

When a duplicate cookie name appears in a request, an `IllegalStateException` is thrown.
The default `Collectors.toMap()` does not allow a duplicated keys.

* Handle `servletRequest.getCookies()` as a `MultiValueMap`
* Call `toSingleValueMap()` for the evaluation context variable to restore previous behavior.
The next major version must expose the `MultiValueMap` as is to give access to all cookies from end-user expressions
* Rework some HTTP tests to JUnit 5

**Cherry-pick to `5.4.x` & `5.3.x`**
2021-10-19 13:26:22 -04:00
Artem Bilan
6c47593aef Fix ExpressionUtilsTests according SF changes
Related to: https://github.com/spring-projects/spring-framework/issues/27446
2021-10-19 09:46:35 -04:00
Artem Bilan
1341a457f0 Upgrade dependencies 2021-10-18 17:30:12 -04:00
Artem Bilan
72b9e7001e GH-3643: Defer MeterRegistry bean dependency
Fixes https://github.com/spring-projects/spring-integration/issues/3643

The `ImportBeanDefinitionRegistrar` register its bean definition in the early phase.
It causes a problem with Spring Boot when an explicit `@EnableIntegrationManagement`
is declared: the `MeterRegistry` is provided later on via auto-configuration
and `MicrometerMetricsCaptor` has no knowledge about `MeterRegistry` at the
`ImportBeanDefinitionRegistrar` phase.

* Reworks `MicrometerMetricsCaptorRegistrar` to the `MicrometerMetricsCaptorConfiguration`
and use special conditional `MicrometerMetricsCaptorImportSelector` for that
`@EnableIntegrationManagement`.
This way a `MicrometerMetricsCaptor` `@Bean` consults `ObjectProvider<MeterRegistry>`
on its creating time and returns `null` if no `MeterRegistry` beans at all.
2021-10-18 17:15:45 -04:00
Artem Bilan
a03af081af Upgrade to Gradle 6.9.1; fork JavaCompile
Attempt to rely on the forked process for compilation
according these docs: https://docs.gradle.org/current/userguide/performance.html#compiler_daemon
2021-10-18 11:24:31 -04:00
Artem Bilan
34d2b0904f Fix new Sonar smells 2021-10-07 10:59:43 -04:00
Gary Russell
e2557a42c2 GH-3617: KPMH - Option To Use Template's Converter
Resolves https://github.com/spring-projects/spring-integration/issues/3617

Optionally use the `KafkaTemplate` message converter instead of the default
(or supplied) `ProducerRecordCreator`.
2021-10-06 16:10:57 -04:00
Artem Bilan
0410343f7f Rework all the MQTT tests to JUnit 5
* Use `MosquittoContainerTest` for all the MQTT integration tests
* Remove MQTT `BrokerRunning` JUnit 4 rule
* Mark `BackToBackAdapterTests` with `@LongRunningTest` as it is really too slow
2021-10-06 13:30:12 -04:00
Artem Bilan
e7c0d8dafa GH-3432: Add MQTT v5 channel adapters (#3639)
* GH-3432: Add MQTT v5 channel adapters

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

* Add `optional` dependency for `org.eclipse.paho:org.eclipse.paho.mqttv5.client`
* Add `MqttProtocolErrorEvent` and emit it from the `mqttErrorOccurred()` callback of the MQTT v5 client
* Add `MqttHeaderMapper` since MQTT v5 has introduced user properties pair to transfer over the protocol
* Add `Mqttv5PahoMessageHandler` as one more extension of the `AbstractMqttMessageHandler`
* Add more convenient `MqttHeaders` constants for easier headers mapping configuration
* Ensure via `Mqttv5BackToBackTests` that MQTT v5 is supported by the provided components
* Change `pr-build-workflow.yml` to use `eclipse-mosquitto` container for testing all the MQTT interactions
* Change `cyrilix/rabbitmq-mqtt` service to the `rabbitmq:management` since RabbitMQ does not support MQTT v5

* * Handle manual acks
* Add `Mqttv5PahoMessageDrivenChannelAdapter.persistence` property

* * Add documentation
* Add `MosquittoContainerTest` for TestContainers support with Mosquitto image

* Fix language in the docs after review

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

Co-authored-by: Gary Russell <grussell@vmware.com>
2021-10-06 11:38:52 -04:00
Gary Russell
b8e414d4f6 GH-3637: Fix KafkaMessageSource First Poll
Resolves https://github.com/spring-projects/spring-integration/issues/3637

If there are no records to receive, the poll blocked for `20*pollTimeout`.

Wake the consumer during partition assignment; however, this changes the behavior
when there are records present - the first poll always returns no records.

Detect that the wakeup was due to assignment and perform another poll.

Also add some debug logging, and don't create a new consumer if the source was
stopped.

**cherry-pick to 5.4.x**
2021-09-30 16:34:33 -04:00
Artem Bilan
fe57fd281c Checkstyle changes
* Upgrade to Checkstyle 9.0
* apply some JavaDocs rules
* Fix JavaDocs rules violations
* Some other minor clean up in the affected classes
2021-09-28 11:55:25 -04:00
Spring Builds
d2e23c5f03 [artifactory-release] Next development version 2021-09-21 17:44:21 +00:00
Spring Builds
6268917239 [artifactory-release] Release version 5.5.4 2021-09-21 17:44:17 +00:00
Artem Bilan
3bfabb92ee Upgrade dependencies; prepare for release 2021-09-21 12:41:00 -04:00
Artem Bilan
726b216f07 Disable TcpNioConnectionTests.testCleanup()
The timeout is too short for CI server and there is
a high chance fo race condition with such a short `nioHarvestInterval`

* Use `@DisabledIfEnvironmentVariable(named = "bamboo_buildKey")`
to exclude the test from CI server, but still run it locally or in GH Actions
2021-09-20 11:36:23 -04:00
Artem Bilan
3f6d205615 Fix link in the channel-adapter.adoc 2021-09-20 11:10:50 -04:00
Artem Bilan
b92d52fe74 Improve docs for global default poller
* Fix Kotlin deprecation warning in the test
* Replace wrong `IntervalTrigger` mentioning in the docs to the proper `PeriodicTrigger`
* Fix code snippet in the `channel-adapter.adoc`
2021-09-20 10:35:16 -04:00
Artem Bilan
0fb64f1762 Upgrade to Kotlin 1.5
* To align with the rest of Spring portfolio, based on Spring Framework 5.3.x generation,
it is better to upgrade to the Kotlin version supported by SF
* Fix  `ClassUtils.isLambda()` to treat `$inlined$` classes as Kotlin lambdas and let
Java DSL to delegate to the `LambdaMessageProcessor` for better expected type handling.
Looks like Kotlin does not carry type info in its lambdas anymore (at least for functions).
* Add `-parameters` to the compiler args for possible method argument names discovery.
Essentially realign with the rest of portfolio
* Fix Kotlin tests for deprecated API
2021-09-13 16:46:05 -04:00
Artem Bilan
0f2285d5a3 Fix reply producing to not block reactive thread
When `DirectChannel` is used for reply producing, the data is
handled on the same thread which has produced it (normally), so
if we have a request-reply afterwards (e.g. `gateway()`), this thread
is blocked waiting for reply.
When the thread is assumed to be non-blocked (e.g. Netty event loop),
the request-reply withing such a thread for the same non-blocking client
causes a deadlock: the thread waits for reply, but at the same time it
supposes to fulfil a synchronization barrier with that reply

* Fix `AbstractMessageProducingHandler.asyncNonReactiveReply()` to use
a `publishOn(Schedulers.boundedElastic())` for reply `Mono` to free
producing thread from potential downstream blocking
* Demonstrate deadlock with a new test in the `RSocketDslTests`;
the original report was against WebFlux, but conditions are really
the same: `reactor-netty` is used as a low-level client

**Cherry-pick to `5.4.x`**
2021-09-13 10:42:04 -04:00
Artem Bilan
fe300ebc38 GH-3614: JPA outbound components delete in batch (#3629)
* GH-3614: JPA outbound components delete in batch

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

Add an `Iterable` payload support for the
`JpaExecutor.executeOutboundJpaOperationOnPersistentMode(Message<?>)`
and `DELETE` persist mode

* Fix language in the docs after review

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

Co-authored-by: Gary Russell <grussell@vmware.com>
2021-09-10 16:34:10 -04:00
Artem Bilan
25ac230be8 GH-3627: Fix race condition NPE in MqttPahoMDCA
Fixes https://github.com/spring-projects/spring-integration/issues/3627

The `destroy()`, and therefore `stop()` could be called from the `MqttConnectionFailedEvent` handling
in the same thread resetting the `client` property to `null`.

* Check for `this.client != null` in the next block of the `connectAndSubscribe()` to avoid NPE
* Check for `isActive()` in the `scheduleReconnect()` to be sure do not reconnect if channel adapter
has been stopped already

**Cherry-pick to `5.4.x`**
2021-09-09 14:37:41 -04:00
Artem Bilan
4456caffa1 Introduce high-level API for flows composition (#3624)
* Introduce high-level API for flows composition

For better end-user experience and more smooth integration logic
decomposition and distribution introduce an `IntegrationFlows.from(IntegrationFlow)`
to let to start the current flow from existing one.
On the other hand introduce an `BaseIntegrationFlowDefinition.to(IntegrationFlow)`
to let to continue the flow logic in the other existing one.
This way we can extract some templating logic into separate `IntegrationFlow` definitions
allowing at the same time to decompose a complex flow definition into logical reusable parts

* * Add more tests

* * Fix Checkstyle violation
* Add `@SuppressWarnings("overloads")` to new `from(IntegrationFlow)` and existing `from(Publisher)`.
Technically it does not make sense since `PublisherIntegrationFlow` is not a `public` class

* * Add docs
* Fix language in JavaDocs according review

* Fix language in the docs after review

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

Co-authored-by: Gary Russell <grussell@vmware.com>
2021-09-08 17:14:29 -04:00
wangYX657211334
b8785e5f9c GH-3619: Fix Mail Receiver fetch redundant Messages
Fixes https://github.com/spring-projects/spring-integration/issues/3619

The `AbstractMailReceiver` fetche redundant messages, causing performance problems

* Use correct, already filtered, array of message to fetch

**Cherry-pick to `main` & `5.3.x`**
2021-09-02 10:49:43 -04:00
Gary Russell
55876e0e42 GH-3620: Fix Shared SFTP Session
Resolves https://github.com/spring-projects/spring-integration/issues/3620

Shared session field was captured outside of the lock, causing multiple sessions
in a multi-threaded environment.

**cherry-pick to 5.4.x, 5.3.x**
2021-08-30 10:50:37 -04:00
Spring Builds
590fb01743 [artifactory-release] Next development version 2021-08-17 19:13:21 +00:00
Spring Builds
1c554a9583 [artifactory-release] Release version 5.5.3 2021-08-17 19:13:17 +00:00
Artem Bilan
39599f82db Update dependencies; prepare for release 2021-08-17 12:11:29 -04:00