Commit Graph

2680 Commits

Author SHA1 Message Date
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
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
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
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
Artem Bilan
799802c0d1 Clean up some JavaDocs; remove deprecated API 2022-04-08 16:05:43 -04:00
Artem Bilan
10ea577549 GH-3615: Make log() as non-terminal in DSL
Fixes https://github.com/spring-projects/spring-integration/issues/3615

The `log()` operator for Java DSL in the end of flow causes a confusion
for its different behavior and, therefore, inconsistency with expectations

* Populate a `bridge()` in the end of flow instead of `nullChannel` when
the current component is `WireTapSpec` (relevant to `wireTap()` and `log()`)
* Deprecate a `logAndReply()` operator since its behavior is now included into the `log()` in the end if flow
* Fix tests to use just `log()` in the end from now on
* Fix `dsl.adoc` for the new `log()` behaviour in the end of flow
2022-04-07 15:07:47 -04:00
Artem Bilan
d5501d8273 GH-3734: Support MessageHistory on Kafka deser
Fixes https://github.com/spring-projects/spring-integration/issues/3734

The `MessageHistory` is not in the trusted packages of the `DefaultKafkaHeaderMapper`
therefore it fails when `MessageHistory.read()` is performed.

* Configure default `DefaultKafkaHeaderMapper` in the `SubscribableKafkaChannel`,
`KafkaInboundGateway`, `KafkaMessageDrivenChannelAdapter` and `KafkaMessageSource`
to also trust packages exposed via `JacksonJsonUtils.DEFAULT_TRUSTED_PACKAGES`
which include a `MessageHistory`, too.

* Verify in some integration Kafka tests to be sure that `MessageHistory` is
deserialized properly in the transferred headers
* Rework some tests to use `@EmbeddedKafka` instead of `@BeforeAll/@AfterAll`

**Cherry-pick to `5.5.x`**
2022-03-22 15:39:00 -04:00
Artem Bilan
bba83c7231 GH-3735: Don't mutate FeedEntryMS metadataKey
Fixes https://github.com/spring-projects/spring-integration/issues/3735

The `FeedEntryMessageSource` adds an url to the provided `metadataKey`
making it incompatible when we provide a `Resource`-based configuration.

* Remove adding of the url to the `metadataKey` making it rely only
on the provided value
* Remove internal `Comparator` for entries in favor of `Comparator.comparing()`
feature
* Improve some internal logic of the `PropertiesPersistingMetadataStore`
when it emits a false warning: cannot create dirs, but they are present
* Improve `feed.adoc`
2022-03-22 15:06:19 -04:00
Artem Bilan
7f501fabcb Remove usage of obsolete NestedIOException
Related to https://github.com/spring-projects/spring-framework/issues/28198

Replaces its usage with the standard `IOException`
which has supported a root cause since Java 6.
2022-03-18 17:00:55 -04:00
Artem Bilan
50cf3b1aa4 Various fixes after upgrades 2022-03-18 12:05:04 -04:00
Artem Bilan
e434a4625c Cancel subscription for MPS.subscribeToPublisher
The `Flux.takeWhile()` only works if there is data in the `Publisher`
to consume.
We still need to be able to cancel subscription and stop producing even if
there is no data at the moment.

* Change `takeWhile()` to the `doOnSubscribe()` and store `subscription`
in the `volatile` property of the `MessageProducerSupport`
* Cancel such a subscription in the `doStop()` impl
* Propagate `doStop()` to super in the `ZeroMqMessageProducer`
which is only one reactive channel adapter overriding `doStop()`
* Verify in the `ReactiveMessageProducerTests` that subscription is cancelled
for delayed data in the `Publisher`

**Cherry-pick to `5.5.x`**
2022-03-16 14:51:47 -04:00
Gary Russell
0550380704 GH-3661: Resolve Spring Apache Kafka Deprecations
Resolves https://github.com/spring-projects/spring-integration/issues/3661

* Don't allow existing listener; remove unnecessary try/catch; add what's new.
* Fix link in whats-new.adoc
2022-03-16 14:46:10 -04:00
Chris Bono
f3d3694836 GH-3506: No array for poller messaging anns attr
Fixes https://github.com/spring-projects/spring-integration/issues/3506

Revise the `@Poller` usage in the messaging annotations from an array value
to a single entry with a `ValueConstants.DEFAULT_NONE` for default value

Code review feedback

- Make annotation utils check for NONE more generic
- Move docs to whats-new.adoc
- Polish javadoc

Code review feedback
- simplify docs
- simplify isProvided checks
2022-03-10 14:07:55 -05:00
Chris Bono
ba8a26f616 GH-3737: Add serialVersionUID to MessageHistory
Fixes https://github.com/spring-projects/spring-integration/issues/3737

* Add an explicit `serialVersionUID` to `MessageHistory` to avoid class version conflicts in the future.

See related GH issue for the workaround

**Cherry-pick to `5.5.x`**
2022-03-08 16:27:20 -05:00
Artem Bilan
70587f5e2f Upgrade some deps; fix compatibility with them
* Upgrade to the latest Spring portfolio stack;
fix tests and effected classes
* The move to the latest Micrometer does not affect code base
2022-03-08 10:08:36 -05:00
Artem Bilan
09ab0af252 Clean up of RMI in the docs 2022-02-04 15:14:49 -05:00
Gary Russell
05e31b9903 Fix @Poller Javadoc
* Fix @Poller Javadoc - `receiveTimeout` was added as a property in 5.1.
* More javadoc polishing.

**cherry-pick to 5.5.x**
2022-02-03 15:29:55 -05:00
Artem Bilan
c7f2c172a6 Fix various sporadic test failures
* Increase a `default-delay="1000"` for `GatewayInterfaceTests`
to test the late reply scenario
* Use a `ConcurrentHashMap` for `JdbcMessageStore.queryCache`
to avoid a possible `ConcurrentModificationException`
2022-02-02 12:36:05 -05:00
Artem Bilan
d6bf681aa4 Upgrade dependencies; prepare for release
* Upgrade to Gradle `7.3.3`
* Upgrade to the latest milestones for releasing
* Upgrade to Kryo-5.2.1 and update source code according breaking changes
* Upgrade to H2-2.1.210 and re-enable respective stored procedure tests
2022-01-18 17:14:33 -05:00
Artem Bilan
c28e251091 Fix ControlBusTests for DefaultHeaderChannelReg
We cannot use a `DFA` to set value to the `record` property:
it is marked as `trustedFinal` and cannot be modified via reflection.
Therefore, rework `ControlBusTests` to do other logic than reflection.
The reflection in the unit test is not a justification to stay away
from the `record` structure
2022-01-18 14:38:54 -05:00
Artem Bilan
8e7a0a0de5 Add checkClasspathForConflicts Gradle task
* The new `checkClasspathForConflicts` will fail if modules has dependencies
containing the same classes.
One of the dependency must be excluded to avoid target classpath pollution
and possible conflicts
* Make the task working as `onlyIf { isCI }`
* Fix warning for illegal access in the `asciidoctorPdf` task add `--add-opens`
to its JVM
* Fix `DefaultHeaderChannelRegistry` for proper `MessageChannelWrapper` access
and change it to `record`
2022-01-18 14:38:54 -05:00
Artem Bilan
b3ae24eac6 Fixes according latest upgrades
* Add `--add-opens` to `asciidoctor` Gradle task to avoid compilation warning
* Upgrade to Kotlin `1.6.10` and modify its Gradle task respective
* Add empty impl for new `AnnotationMetadataAdapter.getDeclaredMethods()`
* Parse HTTP methods to new `String methodNames` property of the `RequestMapping`
since `HttpMethod` is not an `enum` anymore.
* Ignore JDBC tests which rely on a map property resolution: the `[]` placeholder
is not handled in the latest SF anymore.
* Fix `WebFluxInboundEndpoint` for deprecations
2022-01-18 14:38:53 -05:00
Artem Bilan
a80b22638d Start 6.0 version
* Upgrade to Java 17, SF-6.0, Gradle 7.2
* Upgrade to Jakarta dependencies and respective namespaces
* Fix some tests for Java 17 compatibility
* Fix wrong Javadocs
* Add some missed Javadocs
* Fix more `jakarta` namespace
* Fix WS & XML modules to use Jakarta EE
* `--add-opens` in some modules for their reflection-based tests
* Disable Kafka tests which does not work on Windows; see Apache Kafka `3.0.1`
* Upgrade to JUnit `5.8.1`
* Migrate JMS tests to Artemis
* Remove RMI module as it was deprecated before
* Fix `pr-build-workflow.yml` for Java 17
* Fix JavaDocs warnings using `Xdoclint:syntax` per module, not in the top-level `api` task
* Move docs for version `6.0`
2022-01-18 14:38:50 -05:00
Artem Bilan
97a5ea4aca Move IntegrationDsl from .kt to .java
Turns out Eclipse Kotlin plugin is not perfect at the moment,
and it causes some code parsing problems in the editor.

* Move Kotlin annotation to Java to mitigate normal source code flow:
 Java to Kotlin, not opposite
2022-01-03 12:52:05 -05:00
Artem Bilan
5eb95f6cca More Kotlin DSL improvements 2022-01-03 09:49:22 -05:00
Artem Bilan
9759950d35 GH-3699: Fix typos in the IntegrationFlow javadoc
Fixes https://github.com/spring-projects/spring-integration/issues/3699
2021-12-22 10:16:07 -05:00
Artem Bilan
30622b285c Improve Kotlin DSL
* Add missed factories, introduced recently into Java DSL
* Add `@IntegrationDsl` - a Kotlin-specific `@DslMarker` annotation
to mark classes (including Java) which are used in Kotlin DSL as a builder pattern.
This way the scope of the builder is honored and IDE does not suggest functions from
higher lambda for builder
* Fix `element-list` reference for Dokka plugin configuration from the respective module
2021-12-21 17:21:31 -05:00
Artem Bilan
50fa345402 Fix new Sonar smell 2021-12-14 16:46:58 -05:00
Artem Bilan
2a3dac7ff3 GH-3694: Resolve circular dep in PublisherAnnBPP (#3695)
* GH-3694: Resolve circular dep in PublisherAnnBPP

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

* Move check for `PublisherAnnotationBeanPostProcessor` bean into the
`SmartInitializingSingleton.afterSingletonsInstantiated()` to break a circular dependency revealed
in the `InitializingBean.afterPropertiesSet()`

* * Fix unused import
2021-12-14 14:41:58 -05:00
Artem Bilan
8c85fc9957 Add MessageHandlerMethodFactoryCreatingFactoryBean
Rework the logic around `ManagedList` in the `DefaultConfiguringBeanFactoryPostProcessor`
when it registers a `IntegrationContextUtils.MESSAGE_HANDLER_FACTORY_BEAN_NAME` and
`IntegrationContextUtils.LIST_MESSAGE_HANDLER_FACTORY_BEAN_NAME` into a dedicated
`MessageHandlerMethodFactoryCreatingFactoryBean` with pure Java code instead of
`BeanDefinition` burden

* Deprecate `IntegrationContextUtils.DISPOSABLES_BEAN_NAME` constant for
already removed internal bean
* Align JVM args for Gradle with Java 17 on the `6.0` branch
2021-11-29 12:49:29 -05:00
Artem Bilan
a843dae151 Remove Disposables abstraction
* Remove `Disposables` since it is a package protected therefore could not be used outside
* Remove the logic relevant ot the `Disposables` in the `MessagingAnnotationPostProcessor` logic
* Replace a `registerSingleton()` and `initializeBean()` with the proper `registerBeanDefinition()`
and `getBean()` usage.
This way bean are going to be destroyed properly
* Remove `MessagingAnnotationPostProcessorChannelCreationTests` since its mocking logic is too vague
and really covered with many other real tests.
2021-11-22 14:29:43 -05:00
Artem Bilan
d7f925896f Check for Disposables bean before registration
The `MessagingAnnotationPostProcessor` registers a `Disposables` unconditionally.
The `afterPropertiesSet()` maybe called several times, so `IntegrationContextUtils.DISPOSABLES_BEAN_NAME`
registration has to be idempotent.

* Add `if (!this.beanFactory.containsBeanDefinition(IntegrationContextUtils.DISPOSABLES_BEAN_NAME))`
before trying to register `Disposables` bean
2021-11-22 10:20:34 -05:00
Artem Bilan
5452a6fbe6 Fix more Sonar smells 2021-11-11 12:20:25 -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
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
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
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
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
ee8afc5b28 BeanDefinitions: Mix instanceSupplier and props 2021-10-22 15:17:46 -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
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
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
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
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
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