Commit Graph

2387 Commits

Author SHA1 Message Date
Artem Bilan
dd1d65bb23 Refinement for ResolvableType JSON header
Fix a logic in the `JsonToObjectTransformer.obtainResolvableTypeFromHeadersIfAny`
when we have both `JsonHeaders.RESOLVABLE_TYPE` and `JsonHeaders.TYPE_ID`
and `JsonHeaders.RESOLVABLE_TYPE` header is valid `ResolvableType`, so
`JsonHeaders.TYPE_ID` doesn't override its value to return
2019-11-01 15:54:12 -04:00
Artem Bilan
ad97f818cf GH-3096: Skip RESOLVABLE_TYPE header in mapping (#3098)
* GH-3096: Skip RESOLVABLE_TYPE header in mapping

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

When we sent an AMQP message we should not map a
`JsonHeaders.RESOLVABLE_TYPE` header which is a `ResolvableType` and
isn not compatible after converting to string

Also improve `JsonToObjectTransformer` to ignore a
`JsonHeaders.RESOLVABLE_TYPE` when it is type of String

* * Fix `obtainResolvableTypeFromHeadersIfAny()` logic
2019-11-01 15:28:06 -04:00
Artem Bilan
845a39653e Revert testReactiveStreamsConsumerPollableChannel
https://build.spring.io/browse/INT-MASTER-1776/

Looks like there is a race condition between subscribers
2019-11-01 15:03:06 -04:00
Artem Bilan
36c9f72a9d Use EmitterProcessor for Channels adaptation (#3100)
* Use `EmitterProcessor` for Channels adaptation

Related https://github.com/spring-cloud/spring-cloud-stream/issues/1835

To honor a back-pressure after `MessageChannel` adaptation it is better
to use an `EmitterProcessor.create(1)` instead of `Flux.create()`.
This way whenever an emitter buffer is full, we block upstream producer
and don't allow it to produce more messages

**Cherry-pick to 5.1.x**

* * Wrap every new subscription into a `Flux.defer()`
* Fix `ReactiveStreamsConsumerTests` to use a new `Subscription` after
each `stop()/start()` on the `ReactiveStreamsConsumer`

* * Remove unused imports
2019-11-01 14:49:29 -04:00
Sergei Egorov
69401c263c Back-pressure tests for SubscribableChPubAdapter
* Add back-pressure tests for SubscribableChannelPublisherAdapter
2019-11-01 12:13:11 -04:00
Artem Bilan
66c3eff2ba Fix new Sonar smells 2019-10-29 08:11:31 -04:00
Artem Bilan
ca56a0eb80 Extract BaseIntegrationFlowDefinition (#3087)
* Extract `BaseIntegrationFlowDefinition`

Kotlin inline reified functions cannot override as syntax sugar generic
Java methods.

* Extract a `BaseIntegrationFlowDefinition` with strong typed methods,
plus those which doesn't have a syntax sugar variants
* Leave in the `IntegrationFlowDefinition` only those generic methods
which are just a syntax sugar without any types requirements

This way we can write Kotlin inline reified functions as an extension
 with the same names to make a Kotlin DSL much cleaner

* * Override methods in the IntegrationFlowDefinition for bytecode compatibility
* Extract `protected` getters and setters for `BaseIntegrationFlowDefinition`
properties to allow a proper extension
* Use those getters and setters in the code

* * Add // NOSONAR for overridden methods
2019-10-28 10:11:15 -04:00
Artem Bilan
1a2907eeb3 Upgrade dependencies; fix deprecations 2019-10-25 15:25:14 -04:00
Artem Bilan
375f3c1317 Ensure that dynamic routes are included into graph (#3085)
* Ensure that dynamic routes are included into graph

Modify an `IntegrationGraphServerTests` to be sure that dynamic routes
are included into the graph (with links) after sending a message to the
router and rebuilding a graph

* * Fix test for the actual numbers to expect
2019-10-21 15:19:17 -04:00
Artem Bilan
1e50707370 Fix new Sonar smells 2019-10-17 10:09:55 -04:00
Artem Bilan
33667884a7 GH-3079: Use getMostSpecificMethod for SpEL calls (#3082)
* GH-3079: Use getMostSpecificMethod for SpEL calls

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

It turns out that we need to use a *most specific* method for the target
to be called reflectively from the SpEL

NOTE: We drop a *Method not found* error in case of wrong method source
since now we find a right source via `ClassUtils.getMostSpecificMethod()`

**Cherry-pick to 5.1.x**

* * `@Ignore` `MethodInvokingMessageProcessorTests.testProcessMessageMethodNotFound()`
instead of removal
2019-10-16 15:57:33 -04:00
Gary Russell
87af95ee7a GH-3083: Support @Header with dotted literals
Fixes https://github.com/spring-projects/spring-integration/issues/3083

`@Header("foo.bar")` means extract property `bar` from header `foo`.

Support `@Header("'foo.bar'")`, meaning get the value of header `foo.bar`.

**cherry-pick to 5.1.x, 4.3.x**
2019-10-16 11:13:19 -04:00
Artem Bilan
911cdc86b5 Refinement for gateway Mono processing (#3075)
* Refinement for gateway Mono processing

* Introduce a `MessagingGatewaySupport.MonoReplyChannel` instead of
`FutureReplyChannel` for better on demand handling and reusing a
`Mono` returned from the target handler
* Refactor `GatewayProxyFactoryBean` to identify a target return type
(including generics for `Function`) during initialization
* Handle a `Mono` return type via
`MessagingGatewaySupport.sendAndReceiveMessageReactive()`
* Some `@Nullable` in the `GatewayProxyFactoryBean` and `ExpressionUtils`
* Add `MonoFunction` test-case into the `FunctionsTests.kt`

* * Deprecate `GatewayProxyFactoryBean.setServiceInterface()` in favor of
ctor initialization
* Fix `GatewayProxyFactoryBean.setServiceInterface()` usage in tests
2019-10-14 15:31:04 -04:00
Artem Bilan
2a8615539f Deprecate IntFlows.from(service, methodName)
The method reference together with a `IntegrationFlows.frm(Supplier<?>)`
do the trick to avoid a method name resolution and also gives us a code
navigation in the IDE
2019-10-02 10:58:03 -04:00
Artem Bilan
007e1a0924 Improve in generics for some Publisher API 2019-09-30 15:17:36 -04:00
Artem Bilan
ad96ca49f1 Add Reactive Stream chapter into docs
* Improve `channel.adoc`: polishing, new channels, java config
* Make `LoadBalancingStrategy` in the `DirectChannel` ctor as
`@Nullable` to reflect the real logic behind

* More Dos and polishing according PR comments
* Mention WebFlux and RSocket endpoints in the `endpoint-summary.adoc`
table

* More reactive streams docs
* `SourcePollingChannelAdapter` polishing
* Wrap multi-value publisher into `Mono.just()` in the `AbstractMessageProducingHandler`
instead of emitting just only a first item for the standard reply

Doc polishing
2019-09-30 14:36:33 -04:00
Artem Bilan
eeb951b0da Fix new Sonar Smells
* Change `whats-new.adoc#x5.2-behavior` to point for the whole
`5.1-to-5.2-Migration-Guide`
2019-09-29 10:28:09 -04:00
Gary Russell
9994997917 GH-3067: Use default NullChannel instance if poss.
Resolves https://github.com/spring-projects/spring-integration/issues/3067

Also add missing receive counter.

* Late binding of null discard channel; checkstyle

* Fix test; fall back to new NullChannel(); always evaluate tx expressions
2019-09-27 17:14:51 -04:00
Gary Russell
0c7cae15da Upgrade to Jackson 2.10
* Remove extraneous code

* Realign white listing with similar implementation in Spring Security: c0b48338f4

* 2.10 GA
2019-09-27 12:25:41 -04:00
Artem Bilan
c4aceb6bb5 Hide toReactivePublisher() from lambdas (#3065)
* Hide `toReactivePublisher()` from lambdas

When an `IntegrationFlow` is declared via lambda, it is impossible
to materialize it as a `Publisher` since we lose a Lambda context and
finish with a `NoSuchBeanException` when we would like to inject that
`Publisher`

* Make `IntegrationFlowDefinition.toReactivePublisher()` as `protected`
and expose it on the `IntegrationFlowBuilder` level
* Use `Channels` as a singleton: no reason in overhead for its instances
* Some code style polishing for `IntegrationFlowDefinition`

* Restore `Channels.super()` call
2019-09-26 15:08:58 -04:00
Artem Bilan
b12657c599 Document RSocket support
* Fix some typos in `webflux.adoc` and `dsl.adoc`
* Make `FunctionsTests.kt` more Kotlin friendly
* Improve RSocket components and tests for them,
especially rely on the default `RSocketStrategies` in the
target SF RSocket components
* Rework `ServerRSocketConnector.setClientRSocketKeyStrategy` to use the whole `MessageHeaders` for consultation.
It turns out that just destination is not enough since it can be used from different clients
* Make the key based on the provided `setupData` by default
* Include all the `MessageHeaders` into the `RSocketConnectedEvent`

* Improve Docs according review feedback and Docs in SF

Doc polishing
2019-09-24 14:55:04 -04:00
Artem Bilan
21335812a3 Remove IntegrationNode.Stats.deprecated const 2019-09-22 09:34:48 -04:00
Gary Russell
a550ebfaad Fix test after previous commit
- the deprecated field is now last instead of first
2019-09-21 11:34:47 -04:00
Gary Russell
7d949f7f8a Fix Sonar issues 2019-09-21 09:40:25 -04:00
Gary Russell
58c0b9885b Add failure counter to AbstractMessageSource
* Clear timers in AMH.destroy()
2019-09-20 10:53:18 -04:00
Artem Bilan
aa29bb15e3 Guard Micrometer stats for NPE: no Micrometer
If there is no Micrometer in classpath, the `timers` and `counters`
are not populated into Graph

* Check for `null` before calling `Supplier`
2019-09-20 09:45:04 -04:00
Artem Bilan
c4ec73f9a0 Fix Checkstyle violation 2019-09-20 09:30:22 -04:00
Gary Russell
87840bcfe4 GH-3056: Add Micrometer Metrics to Runtime Graph
Resolves https://github.com/spring-projects/spring-integration/issues/3056

* Retrieve meters each time the graph is rendered, not just when it is built.
2019-09-20 09:15:55 -04:00
Artem Bilan
9272782a48 GH-3052: Fix custom converters for lambdas
Fixes https://github.com/spring-projects/spring-integration/issues/3052

Starting with version `5.1`, a `LambdaMessageProcessor` is based on the
`MessageConverter` instead of plain `ConversionService`.
(A `ConfigurableCompositeMessageConverter` is used from the application
context.)
However a type conversion based on the `@IntegrationConverter` is lost
in the `GenericMessageConverter`  because it doesn't use an
`integrationConversionService` from the application context

* Change `ConfigurableCompositeMessageConverter` to configure a
 `GenericMessageConverter`  with an  `integrationConversionService`
 if any
* Fix `MessagingMethodInvokerHelper` to populate a `BeanFactory` into
its internal `ConfigurableCompositeMessageConverter`
* Ensure in the `LambdaMessageProcessorTests` that
`@IntegrationConverter` is applied for ``LambdaMessageProcessor` as well

**Cherry-pick to 5.1.x**
2019-09-13 18:37:33 +01:00
Artem Bilan
87f5409677 Fix more Sonar smells for GatewayProxyFactoryBean 2019-09-09 08:54:20 -04:00
Artem Bilan
f68cf28de7 Fix new Sonar smells for GatewayProxyFactoryBean 2019-09-07 10:58:21 -04:00
Artem Bilan
29bebdba97 GH-3047: Add GatewayProxySpec for Java DSL
Fixes https://github.com/spring-projects/spring-integration/issues/3047

* Improve `GatewayProxyFactoryBean` to determine the return type of the
method call from the interface generic types, when the `serviceInterface`
is a `java.util.function.Function`
* Propagate `MethodArgsHolder` as a `rootObject` for SpEL evaluations
* Deprecate `#gatewayMethod` and `#args` evaluation context variables
in favor of `MethodArgsHolder` as root object.
They will be removed in the future release and a single
`EvaluationContext` will be used for all the gateway expressions
* Introduce an
`IntegrationFlows.from(Class<?> serviceInterface, Consumer<GatewayProxySpec> endpointConfigurer)`
to allow to configure any valid gateway proxy options similar to what
we have with the `<gateway>` and `@MessagingGateway`.
This way we are very close to consistency between different approaches

* * Remove `default` prefix from `GatewayProxySpec` options
* Document the change
2019-09-06 13:46:16 -04:00
Frank Fiorante
5073da8a1b Fix Typo in Flow Validation 2019-08-22 15:47:32 -04:00
Gary Russell
69dd180d0c JUnit 5 Log Level Adjuster
* Fix copyright, javadoc.
2019-08-16 10:36:23 -04:00
Gary Russell
bf1d562c3b Fix MergedAnnotations.SearchStrategy deprecations
a6021cc968
2019-07-31 11:35:03 -04:00
Gary Russell
fc827e1f92 GH-3004: Revert scope of handler factories
See https://github.com/spring-projects/spring-integration/issues/3004

https://github.com/spring-projects/spring-framework/issues/23352
is now resolved so the `DefaultMessageHandlerMethodFactory` can be
singletons.
2019-07-31 10:14:02 -04:00
Gary Russell
f7fc3360cd Fix Sonar issues 2019-07-31 09:40:54 -04:00
Gary Russell
884db2c609 Checkstyle fix 2019-07-30 17:50:05 -04:00
Gary Russell
580ca865fe Test fixes for AssertJ changes 2019-07-30 17:38:29 -04:00
Gary Russell
cd0f56bc87 Add Apache MINA SftpEventListener
- republish certain events as `ApplicationEvent`s.

* * Add ApacheMinaFtplet to provide the same functionality with FTP
* Fix typo

* * Polishing javadocs and event toString() methods
2019-07-30 10:31:23 -04:00
Gary Russell
b1dfb7bfa3 INT-1926: Option to disallow arbitrary routing
JIRA: https://jira.spring.io/browse/INT-1926

Add an option to mapping routers to disable falling back to the
channel key as the channel name.
2019-07-30 09:44:35 -04:00
Denis Kilchichakov
ef1d7be020 Fix nullability issue in queuechannel (#3012)
* Added inherited @Nullable to QueueChannel.doReceive

* Minor refactoring
2019-07-29 16:27:16 -04:00
Gary Russell
5a8be5dc56 GH-3004: Fix MMIH argument resolution
Fixes https://github.com/spring-projects/spring-integration/issues/3004

Change the `DefaultMessageHandlerMethodFactory` beans to prototype scope.

See https://github.com/spring-projects/spring-framework/issues/23352
2019-07-27 08:51:27 -04:00
Gary Russell
aaefe51909 GH-3003: Fix pub/sub with dynamic DSL flows
Fixes https://github.com/spring-projects/spring-integration/issues/3003

Statically defined flows with a publish/subscribe channel invoke the
subscriptions in natural (declared) order.

The components in the flow are started by the application context in
phases (consumers, then producers) and bean declaration order within
each phase.

When a dynamically declared flow is started, the components are started
by the `StandardIntegrationFlow` in reverse order (last to first) so that
we don't start producing messages before the flow is fully wired.

This has the side-effect that pub/sub subscribers are invoked in an
unnatural (last to first) order.

All subscription sub-flows start with a bridge from the pub/sub channel
to the first component's input channel.

The `BroadcastingDispatcher` honors the `Ordered` interface.

Change the `PublishSubscribeSpec` to set the `order` property so that
subscribers are always invoked in the natural order, regardless of whether
the flow is statically or dynamically defined.
2019-07-27 08:49:16 -04:00
Gary Russell
38b64543fb Fix New Sonar Issues 2019-07-24 09:08:43 -04:00
Artem Bilan
80d679a9b0 GH-2748: More bean definitions into exceptions
Fixes https://github.com/spring-projects/spring-integration/issues/2748

* Refactor more `MessageHandlingException`s to include `this` into an
exception message
* Revert using `MessagingException` in some places which really are not
about messaging.
This helps to wrap them into `MessageHandlingException` later in the
`MessageHandler` for the `BeanDefinition` reference
* Remove `volatile` from configuration properties in the affected
classes
* Remove already deprecated `JmsOutboundGateway.setPriority()`
* Add `resource` and `source` for `BeanDefinition` in the
`AbstractChannelAdapterParser` & `AbstractInboundGatewayParser`
* Document the feature
2019-07-23 15:19:56 -04:00
Peter Uhlenbruck
89e1eb35b9 GH-2999: Fix TimeoutCountSeqSizeReleaseStrategy
Fixes https://github.com/spring-projects/spring-integration/issues/2999

Remove `else` block from `findEarliestTimestamp` causing
the method to return with `Long.MAX_VALUE` if the condition was ever
`false`.

**Cherry-pick to 5.1.x**
2019-07-23 12:33:11 -04:00
Artem Bilan
42d8faf11e Upgrade dependencies, including Gradle (#2997)
* `exclude group: 'org.springframework'` from all non-core Spring
dependencies to avoid CLASSPATH conflicts
* Remove suppress from from some modules which don't report compilation
warnings any more
* Fix deprecation warnings reported after upgrades
2019-07-22 15:12:28 -04:00
Artem Bilan
084aaf7e57 GH-2988: Use @Config(proxyBeanMethods=false) (#2989)
* GH-2988: Use `@Config(proxyBeanMethods=false)`

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

For faster startup (and possibility to compile to native code with GraalVM)
use a `proxyBeanMethods = false` on all the `@Configuration` classes
in the Framework
* Provide some other code style polishing

* * Fix Checkstyle violation
2019-07-22 13:59:23 -04:00
Gary Russell
989d31716d Add type mapping to SimpleToAvroTransformer
* Fix setter names for expression Strings
2019-07-18 16:40:06 -04:00