Commit Graph

2443 Commits

Author SHA1 Message Date
Artem Bilan
ede9528c19 Fix some tests for not closed application context 2020-02-11 12:43:33 -05:00
Artem Bilan
a8c471c061 Fix ReactiveStreamsConsumer for error handling
To support `onErrorContinue()` logic for the plain `Subscriber`
we need to wrap its `onNext()` into a `try..catch` and respective
`errorHandler` in the `ReactiveStreamsConsumer`
2020-02-10 16:27:59 -05:00
Artem Bilan
6591ce90f6 Fix ReactiveStreamsConsumer for plain subscriber
https://build.spring.io/browse/INT-MASTERSPRING40-978

Investigate a behaviour for `ReactiveStreamsConsumer`
when we use a plain `Subscriber` directly instead of `doOn...` callbacks.
It looks like there is some race condition when the data can be consumed
upstream, but there is no consumer downstream ready yet
2020-02-10 16:00:14 -05:00
Artem Bilan
867a8cf108 GH-3155: Add support for Java DSL extensions (#3167)
* GH-3155: Add support for Java DSL extensions

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

Provide an `IntegrationFlowExtension` for possible custom EI-operators
in the target project use-cases.

* * Move `IntegrationFlowExtension` tests ot its own test class
* Make all the `IntegrationComponentSpec` ctors as `protected` for possible custom extensions
* Make some `BaseIntegrationFlowDefinition` methods and properties as `protected` to get them
access from the `IntegrationFlowExtension` implementations
* Document the feature

* * Fix language and typos in docs

* * Add `protected` to one more `GatewayEndpointSpec` ctor
* Add JavaDocs to `GatewayEndpointSpec` methods

* * Add `protected` to one more `JmsPollableMessageChannelSpec` ctor
2020-02-07 13:40:39 -05:00
Jayadev Sirimamilla
1d9a818efe GH-3157: pop sequence for message as well
Fixes https://github.com/spring-projects/spring-integration/issues/3157

* Fixed issue with sequences not being popped when Output processor returns a message.

* Updated documents and added additional Checks to the testcase to ensure proper `popSequence` is done.

* Updated documents and added corrected code formatting

* Updated documents and used headerAccessor Constants for matching headers
* Clean up code style
* Improve docs for the feature on the matter
2020-02-04 11:37:19 -05:00
Artem Bilan
e5740f253c Upgrade dependencies
* Gradle 6.1.1
* MongoDb 4.0
* Other Spring dependencies to `BUILD-SNAPSHOT`
* Fix MongoDb tests according latest Spring Data
* State in the docs that both MongoDb driver are `optional` now in the dependencies
2020-02-03 13:12:50 -05:00
Artem Bilan
d792915be6 Add debug log for ReactiveStreamsConsumerTests
https://build.spring.io/browse/INT-MASTER-1883/
2020-01-31 15:16:57 -05:00
Artem Bilan
2f4394d8b5 Populate a JsonHeaders.RESOLVABLE_TYPE on reply (#3163)
* Populate a JsonHeaders.RESOLVABLE_TYPE on reply

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

In the `AbstractAmqpOutboundEndpoint` the `JsonHeaders.RESOLVABLE_TYPE`
from request message is copied to reply message making inconsistency downstream.
The `JsonToObjectTransformer` consults first a `JsonHeaders.RESOLVABLE_TYPE`
and deserialize payload to wrong type

* Fix `DefaultAmqpHeaderMapper` to populate a `JsonHeaders.RESOLVABLE_TYPE`
alongside with other `JsonHeaders` populated from the reply AMQP message.
This way a `JsonHeaders.RESOLVABLE_TYPE` from request message won't have effect
* To get access to classes, supply `AbstractHeaderMapper` with a bean factory `ClassLoader`
* Introduce a couple utility methods into `JsonHeaders` for building a `ResolvableType`

**Cherry-pick to 5.2.x**

* * Fix code formatting for arguments wrapping
2020-01-31 14:17:19 -05:00
Artem Bilan
34bc8116df Add @LogLevels to ReactiveStreamsConsumerTests
https://build.spring.io/browse/INT-MASTERSPRING40-967/
2020-01-30 17:58:40 -05:00
Jayadev Sirimamilla
9f07803abf GH-3152: Fix for nested Scatter Gather
Fixes https://github.com/spring-projects/spring-integration/issues/3152

The upstream `gatherResultChannel` header has been missed when we produced a reply from nested scatter-gather

Added Test Case for Nested Scatter Gather test

Simplified the the test cases and added author in changed cases

Corrected codestyle issue in Travis CI

Removed additional OriginalReplyChannel and originalErrorChannel in Headers.
Added additional not to be executed line of code in test case.

Restored OriginalErrorChannel Header and removed error handling related fixes

* Clean up code style and improve readability

**Cherry-pick to 5.1.x & master**

* Migrate `RouterTests` to JUnit 5
2020-01-27 15:12:15 -05:00
Artem Bilan
290c803f85 Fix new Sonar smell 2020-01-27 11:25:41 -05:00
Artem Bilan
e70fd0d227 Fix new Sonar smells 2020-01-26 10:38:27 -05:00
Artem Bilan
a9cb80afae Fix some Sonar smells 2020-01-25 19:23:04 -05:00
Artem Bilan
bfe28dba9a Revert NPE check in the AbstMappingMessageRouter 2020-01-25 09:19:59 -05:00
Artem Bilan
990294b048 Fix AbstractMappingMessageRouter for NPE 2020-01-24 19:17:08 -05:00
Artem Bilan
d2df9dde9f Fix Checkstyle violations 2020-01-24 16:53:11 -05:00
Artem Bilan
ad5496fa4b Fix some Sonar smells 2020-01-24 16:46:32 -05:00
Artem Bilan
c7c7422fa3 Fix unused imports violation 2020-01-22 15:57:20 -05:00
Artem Bilan
8bd9464b74 Use Overflow.BUFFER for PollableChPublisherAdapter
The `ReactiveStreamsConsumerTests.testReactiveStreamsConsumerPollableChannel()`
fails periodically.

Change the logic to rely on the `FluxSink.OverflowStrategy.BUFFER` for
possible future subscribers, meanwhile with `IGNORE` we just lose a message
altogether
2020-01-22 15:47:00 -05:00
Artem Bilan
9b7b0d91ac FluxMessageChannel: try.catch not onErrorContinue
It turns out that some upstream fluxes may come with the
`onErrorResume()` logic.
The `onErrorContinue()` here downstream in the `FluxMessageChannel.java`
eliminates an `onErrorResume()` purpose.

* Change the logic to `try..catch` in the `doOnNext()` instead and let
that upstream `onErrorResume()` to do its job
2020-01-22 13:15:56 -05:00
Artem Bilan
4b051684ef Stop endpoints in the end of tests
https://build.spring.io/browse/INT-MASTERSPRING40-954/

The `ReactiveStreamsConsumerTests` fails with some race condition from time to time.
Possible reason that no one endpoint is stopped in the end of test.
Even if we step out from the test method, background threads are still active
2020-01-17 09:55:11 -05:00
sergebg
dba307adf6 GH-3143: Fix simple pool resizing
Resolves https://github.com/spring-projects/spring-amqp/issues/1142

Resize down does not work when not enough already allocated to match the reduction.

Improved SimplePool test cases and fixed code style

Fixed code style

GH-3143: Test Polishing

- use preferred assertJ expected exception checking
- add a test for reducing a partially allocated pool
- check active counts
2020-01-16 13:03:25 -05:00
Artem Bilan
7a3a8a4bee Restore IntegrationFlowDefinition from previous
It turns out that some downstream projects are going to
support both Spring Boot 2.2 and 2.3 versions (Spring Cloud).
This way they are going to compile against Spring Integration 5.2,
but possible have a runtime against Spring Integration 5.3.

* Restore `IntegrationFlowDefinition` from the previous version
to keep binary compatibility at runtime
2020-01-16 12:49:58 -05:00
Artem Bilan
5cd36c7af9 Fix new Sonar smells 2020-01-16 09:05:23 -05:00
Artem Bilan
442c4fa4d5 GH-3111: Document @Lazy for messaging annotations (#3142)
* GH-3111: Document @Lazy for messaging annotations

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

* Fix some typos in docs
* Ensure in tests that announced `@Lazy` works as expected

* Doc Polishing

Co-authored-by: Gary Russell <grussell@pivotal.io>
2020-01-15 10:16:25 -05:00
Artem Bilan
f93a740065 Messaging Annotations: process ReactiveMH (#3141)
* Messaging Annotations: process ReactiveMH

* Add support for `ReactiveMessageHandler` as a `@ServiceActivator` bean
* Wrap `ReactiveMessageHandler` in the `ReactiveMessageHandlerAdapter`
in the `ServiceActivatorAnnotationPostProcessor`
* Unwrap `ReactiveMessageHandlerAdapter` in the `AbstractMethodAnnotationPostProcessor`
for `ReactiveStreamsConsumer`

* * Add documentation for the `ReactiveMessageHandler`
& Reactive MongoDb channel adapters
2020-01-14 16:17:40 -05:00
Artem Bilan
d13752b40b Infrastructure for ReactiveMessageHandler (#3137)
* Infrastructure for ReactiveMessageHandler

We have now a `ReactiveMongoDbStoringMessageHandler` which implements
a `ReactiveMessageHandler`, but not a `MessageHandler` for possible
deferred subscriptions to the returned Reactor type

We don't have a proper application context processing for this
new type of message handlers

* Change a  `ConsumerEndpointFactoryBean` to apply an `MH` and `RMH`
as possible types for handler
* Introduce a `ReactiveMessageHandlerAdapter` to wrap an `RMH`
into a `MH` for synchronous calls in the regular consumer endpoints
* Wrap an `RMH` into a `ReactiveMessageHandlerAdapter` for regular
endpoints and unwrap for `ReactiveStreamsConsumer`
* Add `RMH`-based ctor into `ReactiveStreamsConsumer` for target
reactive streams composition (`flatMap()` on the `RMH`)
* Remove a `DelegatingSubscriber` from the `ReactiveStreamsConsumer`
in favor of direct calls from the `doOnSubscribe()`, `doOnComplete()`
& `doOnNext()`
* Add an `onErrorContinue()` to handle per-message errors, but don't
cancel the whole source `Publisher`
* Use `Disposable` from the `subscribe()` to cancel in the `stop()`
- recommended way in Reactor
* Use `onErrorContinue()` in the `FluxMessageChannel` instead of
`try..catch` in the `doOnNext()` - for possible `onErrorStop()`
in the provided upstream `Publisher`
* Handle `RMH` in the `ServiceActivatorFactoryBean` as a direct handler
as well with wrapping into `ReactiveMessageHandlerAdapter` for return.
The `ConsumerEndpointFactoryBean` extracts an `RMH` from the adapter
for the `ReactiveStreamsConsumer` anyway
* Add XML parsing test for `ReactiveMongoDbStoringMessageHandler`
* Add `log4j-slf4j-impl` for all the test runtime since `slf4j-api`
comes as a transitive dependency from many places

* * Fix conflicts after rebasing to master

* * Fix typo in warn message
* Change `Assert.state()` to `Assert.isTrue()`
for `ConsumerEndpointFactoryBean.setHandler()`

* * Fix `ConsumerEndpointFactoryBean` when reactive and no advice-chain
* Fix race condition in the
`ReactiveMongoDbStoringMessageHandlerTests.testReactiveMongoMessageHandlerFromApplicationContext()`

* * Handle `ReactiveMessageHandler` in Java DSL.
Essentially request a wrapping into `ReactiveMessageHandlerAdapter`.
Describe such a requirements in the `ReactiveMessageHandlerAdapter` JavaDocs
* Some Java DSL test polishing
* Add Java DSL for `ReactiveMongoDbStoringMessageHandler`
* Propagate missed `ApplicationContext` population into an internally
created `ReactiveMongoTemplate` in the `ReactiveMongoDbStoringMessageHandler`
2020-01-13 08:41:41 -05:00
Artem Bilan
e0509cc339 Fix new Sonar smell 2020-01-10 10:16:50 -05:00
Artem Bilan
d74f9e8b86 Fix new Sonar smell 2020-01-09 16:46:53 -05:00
Artem Bilan
370e943428 Remove deprecations from previous versions
* Remove Boon dependency and its usage
* Remove overloaded methods from the `IntegrationFlowDefinition`
- we can simply rely now on the super class
* Remove (or rework) deprecated entities in the docs
* Fix tests for removed deprecated APIs
* Rework affected tests to JUnit 5
2020-01-09 15:54:04 -05:00
Artem Bilan
13bd3e5255 Fix some Sonar smells 2020-01-06 09:55:25 -05:00
Jonathan Pearlin
4ab7c3979b Handle possible null management overrides 2019-12-29 12:38:44 -05:00
Artem Bilan
a6b99dba35 Fix new Sonar smells 2019-12-27 22:32:38 -05:00
Artem Bilan
5ac262f866 GH-3132: Remove usage of super();
Fixes https://github.com/spring-projects/spring-integration/issues/3132

It turns out that Checkstyle EmptyBlock doesn't complain about
empty default ctor.
Plus a new check for `super();` call treats it as a violation

* Remove `super();` from all the no-arg ctors
* Code style clean up in the affected classes according
IDEA suggestions

* Fix new Sonar smells
2019-12-27 15:13:00 -05:00
Artem Bilan
9c68ae4a7d Upgrade dependencies, including Gradle
* Alongside with existing `springAmqpVersion` & `springVersion`
also expose `springDataVersion` & `springSecurityVersion`
project properties.
These can be used in external CI plans for compatibility builds
* Fix `IntegrationGraphServerTests` for the current state of graph -
The node name is now based on the endpoint id, not a `MH` bean name
* Fix MongoDB tests for compatibility with the latest driver
2019-12-27 10:00:36 -05:00
Artem Bilan
fab7741368 Shorten internal component names for graph (#3128)
* Shorten internal component names for graph

The long `IntegrationContextUtils.ERROR_LOGGER_BEAN_NAME` name
is used for `errorChannel` `LoggingHandler`'s endpoint.
It is too long for endpoint node in the graph meanwhile the
`errorChannel` is good everywhere

* Change an `IntegrationGraphServer` logic to shorten internal
component names before drawing a graph
* Introduce `IntegrationUtils.obtainComponentName()` for
shortening an internal name if any
* Use `IntegrationConfigUtils.BASE_PACKAGE` in the `IntegrationMBeanExporter`
instead of its own static property
* Remove `IntegrationConfigUtils.FACTORY_BEAN_OBJECT_TYPE` in favor
of introduced in SF `FactoryBean.OBJECT_TYPE_ATTRIBUTE`
* Rework affected test classes to JUnit 5
* Remove usage of deprecated options in the `@EnableIntegrationManagement`
* Document names shortening feature for graph

* * Improve `obtainComponentName()` function
2019-12-26 15:41:19 -05:00
Artem Bilan
c08f4ec5c6 GH-3118: MessagingGW: Don't proxy default methods (#3119)
* GH-3118: MessagingGW: Don't proxy default methods

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

The `GatewayProxyFactoryBean` proxies all the methods in the provided interface,
including `default` and `static`.
This is not what is expected from end-users.

* Proxy only `abstract` methods from the provided interface
* Introduce a `DefaultMethodInvokingMethodInterceptor` to call `default`
method on the interface using a `MethodHandle` approach for those methods
calling

* * Introduce a `proxyDefaultMethods` option to let to
restore a previous behavior
* Handle a new property from XML, annotations & DSL configurations
* Ensure that the property works in various tests
* Document the feature

* * Fix typo in the `build.gradle`
2019-12-26 15:41:19 -05:00
Artem Bilan
b4fcf9ec87 GH-3120: Identify polling MG as outbound-CA
Fixes https://github.com/spring-projects/spring-integration/issues/3120

The messaging gateway method without arguments works as a
polling channel adapter.
In this case a Messaging Gateway component is present in the end of flow.
Therefore we treat it as an `outbound_channel_adapter`
2019-12-26 15:41:19 -05:00
Artem Bilan
07f0aa95d6 Remove IntegrationPatternType.gateway
The `GatewayProxyFactoryBean` really produces an Inbound Gateway
for downstream flow and its proxy becomes a start of the flow

* Determine a return type of the gateway method to indicate
that `void` one leads to the `IntegrationPatternType.inbound_channel_adapter`
instead of regular `IntegrationPatternType.inbound_gateway`
2019-12-26 15:41:19 -05:00
Artem Bilan
2263827b3f INT-4568: Add reactive MongoDbMH
JIRA: https://jira.spring.io/browse/INT-4568

* Refactor `AbstractMessageHandler` and implement `MongodbReactiveMessageHandler`

* Rename `AbstractBaseMessageHandler` to `MessageHandlerSupport`

* Clean up code style and resolve possible Sonar smells
2019-12-26 15:41:19 -05:00
Artem Bilan
ebadfde609 Fix IP type for ClaimCheckOutTransformer
The `ClaimCheckOutTransformer` contains an `IntegrationPatternType.claim_check_in`
value for its `getIntegrationPatternType()`.

* Use correct `IntegrationPatternType.claim_check_out` instead
2019-12-26 15:41:19 -05:00
Artem Bilan
c0a32622ea Introduce IntegrationPattern abstraction
* Add `IntegrationPattern` contract to implement on the target components
which represent particular EIP
* Add `IntegrationPatternType` with an internal `IntegrationPatternCategory`
to return from the component implementing `IntegrationPattern`
* Parse `IntegrationPatternType` in the `IntegrationNode` for potential
use on the UI for drawing a particular icon

* More pattern representations

* Clean up Checkstyle
* Fix JavaDocs
* Add `integrationPatternCategory` assertion into the `IntegrationGraphServerTests`

* Add more IntegrationPattern implementations
* Provide some delegation and overriding logic whenever we have
components wrapping

* Fix unused imports

* Add `inbound_gateway` pattern indicator
* Add conditional on `expectReply` to indicate a component as an
`IntegrationPatternType.outbound_channel_adapter` or
`IntegrationPatternType.outbound_gateway`
* Make some code clean up in affected classes

* Add a `gateway` type for `@MessagingGateway`

* Comment the reason for `outbound_gateway` type in the `AbstractReplyProducingMessageHandler`
* Bump `IntegrationGraphServer.GRAPH_VERSION`
* Add new attributes into graph sample in the `graph.adoc`
* Document an `IntegrationPattern`

* Apply changes for version 5.3

* Rebased into `5.3-WIP`
* Add a `whats-new.adoc` note about an `IntegrationPattern`
2019-12-26 15:41:19 -05:00
Artem Bilan
9dc3519f20 Start version 5.3
* Move `What's New` into `changes-5.1-5.2.adoc`
* Remove version from the `XSD` files:
 1. Align with SF
 2. The version for XSD doesn't matter for the current jar version,
 since only the version is available in classpath is from the current
 jar version
 3. Modify `spring.schemas` to map all the possible versions for XSD
 into the current one in a jar.
 This way target applications can upgrade without changing the version
 for XSD location and we don't need to require `versionless` variant
 any more
 4. The jar in classpath can handle only its own XSD, so independently
 of version or no-version variants we still may fail because the current
 jar may not support end-user code any more - need some fix over there
 anyway.
* Remove `checkTestConfigs` Gradle task since we don't worry about XSD
version any more
* Modify `schemaZip` Gradle task to populate XSDs into a distribution
still with a version to avoid overriding on-line XSDs for version `1.0.x`.
We may consider not do that since SF doesn't and just bite a bullet
for always overriding those on-line XSDs to the actual one from the latest
release.
2019-12-26 15:41:19 -05:00
Artem Bilan
1334c75147 Fix new Sonar smell 2019-12-20 11:55:26 -05:00
Artem Bilan
5455ccb8dc Fix AbstractMethodAnnPP.postProcess() complexity 2019-12-19 10:55:17 -05:00
Artem Bilan
a9ab4827a9 Fix tests for the previous commit - new behavior 2019-12-18 17:06:59 -05:00
Artem Bilan
887a0896ef Fix Messaging Annotations for ReplyProdMHWrapper
To ensure advice-chain applicability the provided plain
`MessageHandler` is wrapped into a `ReplyProducingMessageHandlerWrapper`
with its particular `.wrapper` bean name.
When we build a graph for integration components, we use a
`componentName` from the `IntegrationObjectSupport` to represent a
node for endpoint in the graph.
In most cases the component name is an endpoint id around a `MessageHandler`

* Populate the missed component name in a `ReplyProducingMessageHandlerWrapper`
in the `AbstractMethodAnnotationPostProcessor` so nodes in the graph has
a proper name for their endpoint in the application context
2019-12-18 16:14:51 -05:00
Artem Bilan
aa895e7365 Upgrade dependencies; prepare for release
* Fix MongoDB tests for changed return type from Spring Data MongoDB
2019-12-04 13:07:56 -05:00
Artem Bilan
94e08169a5 Use EmitterProcessor in the FluxMessageChannel (#3104)
* Use EmitterProcessor in the FluxMessageChannel

The `EmitterProcessor` has a good logic to block upstream producer
when its downstream subscriber cannot keep up with overproducing.

* Rework `FluxMessageChannel` logic to rely on the `EmitterProcessor`
instead of `Flux.create()`
* Cancel `FluxMessageChannel` internal subscriptions in the `destroy()`
* Fix `ReactiveStreamsTests.testFluxTransform()` for the splitter's
delimiter
* Ensure in the `FluxMessageChannelTests.testFluxMessageChannel`
that we can have several concurrent subscribers to the
`FluxMessageChannel`

* * Use `flux.onComplete()` instead of iteration over subscribers
* Change `subscribers` list into just `AtomicInteger` count marker
* fix `DefaultSplitterTests` according a new logic in the `FluxMessageChannel`

* GH-3107: Add errorOnTimeout for TcpInboundGateway

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

The `MessagingGatewaySupport` has an `errorOnTimeout` option to throw
a `MessageTimeoutException` when downstream reply doesn't come back in
time for configured reply timeout

* Expose an `errorOnTimeout` option as a `TcpInboundGateway` ctor
property
* Add new factory methods into a `Tcp` factory for Java DSL
* Ensure a property works as expected in the `IpIntegrationTests`
* Document a new option

* * Use `delaySubscription()` for subscribing publishers in the `FluxMessageChannel`
to wait until this one subscribed.
* Use an `EmitterProcessor` to catch subscriptions and pass them as a
signal to delayed upstream publishers
* Fix  `FluxMessageChannelTests.testFluxMessageChannelCleanUp` to
verify an actual property instead of removed.
* Fix `RSocketOutboundGatewayIntegrationTests` for the proper subscription
into a `FluxMessageChannel` before actual interaction with an RSocket
gateway.
This should help us also to avoid some race conditions in the future

* Revert "GH-3107: Add errorOnTimeout for TcpInboundGateway"

This reverts commit fa6119ddc4e423e8b15ca3fdc9fc4c79ea9d56af.

* * Refactor `FluxMessageChannel` to use `ReplayProcessor` for `subscribedSignal`.
This one is used `delaySubscription` for the upstream publishers
* Use a `AtomicBoolean` for subscription state since `doOnSubscribe()`
is called before `EmitterProcessor` adds subscribers for its `downstreams`
* Use `publishOn(Schedulers.boundedElastic())` for upstream publishers
to avoid blocking over there when our `EmitterProcessor` doesn't have
enough demand
* Refactor reactive tests to have a subscription into the `FluxMessageChannel`
earlier than emission happens for it

* * Use `Flux.subscribe(Consumer)` instead of `doOnNext(Consumer).subscribe()`

* * Emit `subscribedSignal` value after `.subscribe(subscriber)`
instead of `doOnSubscribe`
* Check for `this.processor.hasDownstreams()` before emitting such an event

* * Use `this.processor.hasDownstreams()` as a value to emit for `subscribedSignal`.
This way we are less vulnerable race conditions when subscribers are changed
actively
2019-12-03 12:19:14 -05:00
Artem Bilan
8e7c1067f3 Fix pub/sub race conditions in Reactive tests 2019-12-02 14:03:12 -05:00