Commit Graph

2508 Commits

Author SHA1 Message Date
Artem Bilan
19e8a65061 GH-3473: Fix dead lock around lifecycleLock
Fixes https://github.com/spring-projects/spring-integration/issues/3473

When `AbstractEndpoint.start()` and `AbstractEndpoint.isRunning()`
are called from different thread on `synchronized` methods,
we may end up with a dead lock: one thread waits for monitor on
`synchronized` and another waits for the `lifecycleLock`

* Change `AbstractEndpoint.isRunning()` to a plain `return this.running;`
- there is no reason in a lock around returning this `volatile` property state

**Cherry-pick to 5.4.x & 5.3.x**
2021-01-27 11:45:43 -05:00
Artem Bilan
af725a841f Fix mngmt dependency for MetricsCaptor
The `IntegrationManagementConfigurer` is a `BeanPostProcessor`
so it must not have direct dependency injection for other beans.
In our case it is a `MetricsCaptor` injected from the
`IntegrationManagementConfiguration`

* Fix `IntegrationManagementConfiguration` and `IntegrationManagementConfigurer`
to rely on the `ObjectProvider<MetricsCaptor>` instead

Tested against latest Spring Boot

**Cherry-pick to `5.3.x` & `5.2.x`**

# Conflicts:
#	spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationManagementConfiguration.java
#	spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationManagementConfigurer.java
2020-11-10 16:08:19 -05:00
Artem Bilan
72232ea026 GH-3425: Remove mngmt gauges from CtxClosedEvent
Fixes https://github.com/spring-projects/spring-integration/issues/3425

It turns out that `IntegrationManagementConfigurer.destroy()` is still too
late to remove `gauges` and Micrometer tries to gather them on application
context close, when many beans are already destroyed

* Catch `ContextClosedEvent` in the `IntegrationManagementConfigurer`
and removed `gauges` from there
* Remove `destroy()` impl since it is out of use already:
the `IntegrationManagementConfigurer` is not supposed to be in the
target application directly, so it looks safe to remove the `DisposableBean`
altogether

**Cherry-pick to `5.3.x` & `5.2.x`**

# Conflicts:
#	spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationManagementConfigurer.java
2020-11-10 15:58:11 -05:00
Artem Bilan
002382e647 Rely on MProducerSupport.active for Flux (#3423)
* Rely on `MProducerSupport.active` for `Flux`

* Fix `MessageProducerSupport` to extract an `active` flag and set it before
`isRunning` - the `Flux` subscription relies on the `takeWhile()`
where in case of `autoStartup = false` we will never start consume because
it is set to `true` already after `doStart()`
* Refactor all the `MessageProducerSupport` implementation with similar
`active` state to use already one from the super class

**Cherry-pick to 5.3.x**

* * Remove `MessageProducerSupport.setActive()`
to not let to mutate it from the implementations
* Set `active` to `false` in the `destroy()`
* Clean up and fix typos in the affected `JmsMessageDrivenEndpoint`

* * Pull `active` flag down to the `AbstractEndpoint`
* Set `active = true` in the `start()` before calling `doStart()`
* Do same for `active = false` in the `stop()`
* Clean up `AbstractEndpoint` impls to not call `doStart/doStop` for nothing
* Refactor endpoints to rely on the `active` state from the `AbstractEndpoint`
not their own
2020-11-06 14:05:35 -05:00
Gary Russell
27b464ad27 GH-3418: Fix Poller Undeclared Checked Exceptions
Resolves https://github.com/spring-projects/spring-integration/issues/3418

`Class.newInstance()` can propagate checked exceptions that are not declared.

**cherry-pick/back-port to 5.3.x, 5.2.x, 4.3.x**
2020-11-02 11:38:36 -05:00
Artem Bilan
9e3b5d9cd5 Fix @InChAdapter for several supplier beans
The `InboundChannelAdapterAnnotationPostProcessor` doesn't use a bean method name
when it parses a `Supplier` bean and only uses a configuration class name + `get`
for method part

* Fix `InboundChannelAdapterAnnotationPostProcessor` to also include a bean method
name into the final bean name for the `MethodInvokingMessageSource` based on
the `Supplier` bean
* Modify `ReactiveInboundChannelAdapterTests` to add one more `Supplier` with the
`@InboundChannelAdapter` to ensure that configuration is still valid after the fix

**Cherry-pick to 5.2.x & 5.1.x**
2020-10-22 12:42:19 -04:00
Artem Bilan
0cd669fee9 Revert "Fix @InChAdapter for several suppliers"
This reverts commit cd9173cd95.
2020-10-22 12:06:07 -04:00
Artem Bilan
cd9173cd95 Fix @InChAdapter for several supplier beans
The `InboundChannelAdapterAnnotationPostProcessor` doesn't use a bean method name
when it parses a `Supplier` bean and only uses a configuration class name + `get`
for method part

* Fix `InboundChannelAdapterAnnotationPostProcessor` to also include a bean method
name into the final bean name for the `MethodInvokingMessageSource` based on
the `Supplier` bean
* Modify `ReactiveInboundChannelAdapterTests` to add one more `Supplier` with the
`@InboundChannelAdapter` to ensure that configuration is still valid after the fix

**Cherry-pick to 5.2.x & 5.1.x**
2020-10-22 12:03:06 -04:00
Artem Bilan
3b60e45679 Gateway: Propagate Error to the errorChannel
See SO for more info:
https://stackoverflow.com/questions/64456946/handle-exceptions-errors-other-than-messagingexception-ie-other-error-excepti

In the versions before `5.2.x` the `Error` was wrapped to the `MessagingException`
in the `AbstractRequestHandlerAdvice` and this one was handled properly
on the gateway level with its `errorChannel` configured

* Fix `MessagingGatewaySupport` to catch all the `Throwable` and try to send them as `ErrorMessage`
to the `errorChannel`.
Otherwise unwrap returned `MessagingException` and re-throw an `Error` as is to keep
the current behavior for non-handled exceptions

* Do not wrap `Error` into a `MessagingException` and re-throw as is if there is no `errorChannel`

**Cherry-pick to 5.3.x & 5.2.x**
2020-10-22 11:42:26 -04:00
Artem Bilan
d60f23549c Fix MeterRegistry eager load
If there is a `MeterRegistry` bean (any) in the application context,
we add a `MicrometerMetricsCaptor` bean which populates meters further
from the components.
In some case we may load a `MicrometerMetricsCaptor` bean too early
so, not all the stuff around `MeterRegistry` maybe ready.
See Spring Boot and its `MetricsAutoConfiguration`

* Fix the `MicrometerMetricsCaptorRegistrar` the way to rely on the
`ObjectProvider<MeterRegistry>` instead
* Add package protected ctor to the `MicrometerMetricsCaptor` to
provide a target `MeterRegistry` on demand

All of that will ensure that we use an already post-processed `MeterRegistry`
including Spring Boot auto-configuration

**Cherry-pick to 5.3.x & 5.2.x**
2020-10-15 15:17:28 -04:00
Artem Bilan
e649480350 Fix IntegrationReactiveUtils
The `Mono.doOnSuccess()` is always called for completed `MonoSink`
even if the value is `null`

* Fix `IntegrationReactiveUtils.messageSourceToFlux()` to check a
message for `null` before calling `AckUtils.autoAck()`
* Add an `logger.error()` message when `doOnError()` is invoked for that `Mono`

**Cherry-pick to 5.3.x**
2020-09-24 09:48:51 -04:00
Artem Bilan
d0cab670eb GH-3376: Remove gauges on application ctx close (#3377)
* GH-3376: Remove gauges on application ctx close

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

The `MeterRegistry` may request meters on application shutdown.
The gauges for channels, handlers and message sources don't make sense
at the moment since all those beans are going to be destroyed.

* Remove gauges for channel, handler and message source numbers from the
`IntegrationManagementConfigurer.destroy()`

**Cherry-pick to 5.3.x & 5.2.x**

* * Add `MicrometerImportSelector` to conditionally load
a  `MicrometerMetricsCaptorConfiguration` when `MeterRegistry`
is on class path.
* Make `MicrometerMetricsCaptorConfiguration.integrationMicrometerMetricsCaptor()`
 bean dependant on the `ObjectProvider<MeterRegistry>`
* Make `IntegrationManagementConfiguration.managementConfigurer()`
dependant on the `ObjectProvider<MetricsCaptor>`.
This way the `IntegrationManagementConfigurer` is destroyed before
`MeterRegistry` when application context is closed
* Deprecate `MicrometerMetricsCaptor.loadCaptor()` in favor of
`@Import(MicrometerImportSelector.class)`

* * Add `MicrometerMetricsCaptorRegistrar` to register a `MICROMETER_CAPTOR_NAME`
bean when `MeterRegistry` is on class path and no `MICROMETER_CAPTOR_NAME` bean yet.
* Make `IntegrationManagementConfiguration.managementConfigurer()`
dependant on the `ObjectProvider<MetricsCaptor>`.
This way the `IntegrationManagementConfigurer` is destroyed before
`MeterRegistry` when application context is closed
* Deprecate `MicrometerMetricsCaptor.loadCaptor()` in favor of
`@Import(MicrometerMetricsCaptorRegistrar.class)`
* Fix test to make a `MeterRegistry` bean as `static` since
`@EnableIntegrationManagement` depends on this bean definition now

# Conflicts:
#	spring-integration-core/src/main/java/org/springframework/integration/config/EnableIntegrationManagement.java
#	spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationManagementConfiguration.java
#	spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationManagementConfigurer.java

* Fix some deprecation warnings
2020-09-16 11:24:44 -04:00
Artem Bilan
5e98f6d7f3 GH-3374: Fix scan for BF propagation (#3378)
* GH-3374: Fix scan for BF propagation

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

An internal `ClassPathScanningCandidateComponentProvider` instance in the `IntegrationComponentScanRegistrar`
does not propagate a provided `registry`.

* Implement `getRegistry()` on the internal `ClassPathScanningCandidateComponentProvider` to propagate
a provided into the `registerBeanDefinitions()` a `BeanDefinitionRegistry`
* Add `@Conditional` on some scanned `@MessagingGateway` in the `EnableIntegrationTests`

**Cherry-pick to 5.3.x & 5.2.x**

* * Remove unused import

* Restore `unused` warning on the unused registry arg
2020-09-11 09:49:06 -04:00
Artem Bilan
b20d27644b Add gauges for queue channel size (#3349)
* Add gauges for queue channel size

The `QueueChannel` provides a current size and remaining capacity metrics

* Add Micrometer gauges into `QueueChannel` to expose the current values
of the size and remaining capacity

**Cherry-pick to 5.3.x, 5.2.x & 5.1.x**

* * Revert `@SuppressWarnings("unchecked")` for test
* Document new gauges for queue channel

* * Fix IntegrationManagementConfigurer for NPE on `metricsCaptor`

* Fix wording in meter descriptions

Co-authored-by: Michel Jung <michel.jung89@gmail.com>

Co-authored-by: Michel Jung <michel.jung89@gmail.com>
2020-07-28 17:00:28 -04:00
Artem Bilan
e3be340bad Improve MessageKryoRegistrar for registrations
(cherry picked from commit 5ec71d4b4a)
2020-07-22 13:36:38 -04:00
Artem Bilan
f6587e29de Fix typo in KryoCodecTests
(cherry picked from commit 5e45b09cd5)
2020-07-22 12:33:42 -04:00
Artem Bilan
23f3482e8f Improve Kryo Codec for registrations 2020-07-22 12:07:45 -04:00
Artem Bilan
dfa6c847f8 GH-3344: Treat kotlin.Unit return as null in MMIH (#3346)
* GH-3344: Treat kotlin.Unit return as null in MMIH

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

When function lambda doesn't return anything (e.g. a `void` method call is the last one),
Kotlin produces a `kotlin.Unit` instance as a return value which is not null and produced
as a reply message payload.

* Fix `MessagingMethodInvokerHelper` to treat a `kotlin.Unit` as `null` for reply
making Kotlin lambdas working the same way as Java lambdas when we don't return anything
from from there

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

* * Introduce `ClassUtils.isKotlinUnit(Class)` API;
use it in the `MessagingMethodInvokerHelper` instead of
`.getName().equals()`

* * Fix since on new `isKotlinUnit()` API
2020-07-20 13:52:41 -04:00
Artem Bilan
ca60db50a3 SO-62761903: Inject BF into Gateway's correlator
Related to https://stackoverflow.com/questions/62761903/spring-integration-reactive-streams-support-exception-in-creating-a-reactive

The `MessagingGatewaySupport` creates an internal endpoint
for consuming messages from the provided `replyChannel`.
The endpoint type depends on the channel type.
The `ReactiveStreamsConsumer` was missing a `BeanFactory` injection
causing an error when `ReactiveStreamsConsumer` tries to extract a default `ErrorHandler`
from `BeanFactory`

* Refactor `MessagingGatewaySupport` to inject a `BeanFactory` to all
the possible correlator endpoints.
Also always call `afterPropertiesSet()` for all of them

**Cherry-pick to 5.3.x & 5.2.x**
2020-07-08 14:59:23 -04:00
Gary Russell
a8c63e2991 Fix CachedSessionFactory Race
Close the pool so that any sessions returned after the factory is
`destroy()`ed are closed.

* Call `removeAllIdleItems()` in `close()`.

* Close sessions in `SftpStreamingMessageSourceTests`.

**cherry-pick to all supported branches**
2020-07-08 14:20:58 -04:00
Alexander Shaklein
3857157ac1 GH-3324. fix NPE in StdIntFlowContext
Fixes https://github.com/spring-projects/spring-integration/issues/3324

The `StandardIntegrationFlowContext.remove()` has a possible NPE

**Cherry-pick to 5.3.x & 5.2.x**

(cherry picked from commit 7424cb215c)
2020-07-04 15:59:32 -04:00
Artem Bilan
9082c12ba1 Fix MessagingGatewaySupport for reactive error (#3319)
* Fix MessagingGatewaySupport for reactive error

The `onErrorResume()` was in a wrong place for the
`doSendAndReceiveMessageReactive()`: we have to catch all the exceptions
from the top level `Mono`, not only a reply one as it was before.

Ensure in HTTP and WebFlux test that behavior is fixed

**Cherry-pick to `5.3.x` & `5.2.x`**

* * Remove unused imports

Co-authored-by: Artem Bilan <abilan@vmware.com>
2020-07-01 15:54:24 -04:00
artembilan
d958e36671 Code clean up for JacksonJsonUtils
* Mention `trustedPackages` in the `redis.adoc`

**Cherry-pick to 5.3.x, 5.2.x, 5.1.x & 4.3.x**
2020-06-09 14:51:32 -04:00
artembilan
d7549a94ae Fix NPE for component name after FactoryBeans
SO: https://stackoverflow.com/questions/62190244/spring-integration-upgrade-from-5-2-x-to-5-3-problem

When the component is populated to the application context via `FactoryBean`,
all its `BeanFactory` callbacks should be propagated from that `FactoryBean` -
only lifecycle control for this component we have through its `FactoryBean`

**Cherry-pick to 5.3.x**
2020-06-09 11:06:05 -04:00
Artem Bilan
e309ebb940 GH-3288: Add Kotlin DSL transform(Transformer)
Fixes https://github.com/spring-projects/spring-integration/issues/3288

* For better end-user experience with Kotlin DSL and get a gain from
existing `Transformer` implementations add a `transform(Transformer)`
EI-method into the `KotlinIntegrationFlowDefinition`
* Also add `filter(MessageSelector)` for any out-of-the-box `MessageSelector`

**Cherry-pick to 5.3.x**
2020-05-27 13:40:35 -04:00
Artem Bilan
bf0260a616 GH-3276: reactive inbound: Fix onErrorResume
Fixes https://github.com/spring-projects/spring-integration/issues/3276

The `onErrorResume` for the `MessagingGatewaySupport.doSendAndReceiveMessageReactive()`
was in wrong place: only for the `buildReplyMono` which works only
when an outbound flow is fully based on reactive channels.
With a regular direct channel we can get an exception from the
`sendMessageForReactiveFlow` which is not covered with the mentioned
`onErrorResume` for the error handling on the configured `errorChannel`

Cherry-pick to `5.2.x & 5.1.x`
2020-05-13 15:24:18 -04:00
Artem Bilan
79056581f0 Fix RESOLVABLE_TYPE header population
* We should not build a RESOLVABLE_TYPE header when we map requests.
Only for replies. See: https://github.com/spring-projects/spring-integration-samples/issues/277
* We should log `ClassNotFoundException` only at debug level - to noise with info or warn

**Cherry-pick to 5.2.x**
2020-05-13 13:06:46 -04:00
Artem Bilan
c264e12deb Fix new Sonar smells 2020-04-29 09:27:54 -04:00
Artem Bilan
dc15910f2c GH-3266: Don't override props in AnnGWProxyFB
Fixes https://github.com/spring-projects/spring-integration/issues/3266

It turns out that `AnnotationGatewayProxyFactoryBean.onInit()` implementation
parses a `@MessagingGateway` attributes ignoring possible properties
population by setters.
This way a Java DSL `GatewayProxySpec` becomes useless since all
its options are overridden by default values from a synthesized
`@MessagingGateway`.
Also it is inconsistency when we declare an `AnnotationGatewayProxyFactoryBean`
as regular bean, but then called setters are ignored

* Add `protected` getters into `GatewayProxyFactoryBean` for all
the properties which can be overridden by annotation attributes
* Fix `AnnotationGatewayProxyFactoryBean` to consult with those getters
before populating a property with value from the annotation

**Cherry-pick to 5.2.x**
2020-04-28 17:27:17 -04:00
Artem Bilan
2d9a5f60f4 Introduce a ReceiveMessageAdvice (#3265)
* Introduce a `ReceiveMessageAdvice`

* Deprecate an `AbstractMessageSourceAdvice` in favor of
`default` method in the `MessageSourceMutator`
* Move a `applyReceiveOnlyAdviceChain()` logic into the `AbstractPollingEndpoint`:
now both `PollingConsumer` and `SourcePollingChannelAdapter` can use
`ReceiveMessageAdvice`
* Introduce a `SimpleActiveIdleReceiveMessageAdvice` based already
on the `ReceiveMessageAdvice` and deprecate a `SimpleActiveIdleMessageSourceAdvice`
which is fully replaceable with newly introduced `SimpleActiveIdleReceiveMessageAdvice`
* Add `@SuppressWarnings("deprecation")` for those out-of-the-box `ReceiveMessageAdvice`
implementation which still use an `AbstractMessageSourceAdvice` for
backward compatibility
* Document a new feature and give the `MessageSourceMutator` a new meaning

* * Fix language in the `polling-consumer.adoc`
2020-04-28 13:03:30 -04:00
Artem Bilan
cfd03f89a0 Use a SimpleJsonSerializer in the FileSplitter (#3262)
* Use a SimpleJsonSerializer in the FileSplitter

* To avoid extra dependency for Jackson when we
serialize `FileSplitter.FileMarker` to JSON, use
a `SimpleJsonSerializer` instead.
* Fix `SimpleJsonSerializer` to escape a `\` symbol from property values
since it is used for quoting string values in the final JSON

* * Document the change
2020-04-27 15:42:45 -04:00
Artem Bilan
6b57e16440 GH-3253: Scan BF hierarchy for BeanDefinition
Fixes https://github.com/spring-projects/spring-integration/issues/3253

The `IntegrationFlowBeanPostProcessor` uses a `containsBean()`
and then `getBeanDefinition()` to be sure that we don't override already
existing bean even if it is created in the parent(s) context.
The problem that `containsBean()` check the hierarchy, but `getBeanDefinition()`
doesn't.
So, we fail with `NoSuchBeanDefinitionException` if bean exists in the parent ctx

* Introduce an utility `IntegrationContextUtils.getBeanDefinition()` to
scan `BeanFactory` recursively for `BeanDefinition` for the requested `name`
* Use this tool in the `IntegrationFlowBeanPostProcessor` logic

**Cherry-pick to 5.2.x & 5.1.x**
2020-04-24 14:01:03 -04:00
Artem Bilan
02407f7dff Add ReactiveMessageSourceProducer (#3254)
* Add `ReactiveMessageSourceProducer`

The `ReactiveMessageSourceProducer` wraps a provided `MessageSource`
into a `Flux` for subscription in the `subscribeToPublisher(Publisher<? extends Message<?>>)`
to make a source polling feature fully based on a reactive, on demand solution

* Introduce a `IntegrationReactiveUtils` replacing existing `MessageChannelReactiveUtils`
with more functionality
* Replace a deprecated `MessageChannelReactiveUtils` with a new `IntegrationReactiveUtils`
* Test and document the feature

* * Fix Docs typos

* * Remove unused imports from `MessageChannelReactiveUtils`

* * Fix JavaDoc copy/paste artifact
2020-04-23 15:28:16 -04:00
Gary Russell
9414765b28 Fix Sonar issue 2020-04-23 12:14:02 -04:00
Gary Russell
c2babe4ba2 Add remaining deprecations for legacy metrics
- add a module to suppress legacy metrics from the Integration Graph
- move graph tests package to match src/main

Fix missed deprecation and checkstyle.

More deprecations and remove GraphLegacyStatsNullModule.

* Revert GRAPH_VERSION.
* Fix JavaDocs warnings
* Fix `MBeanExporterParserTests`
2020-04-22 17:29:36 -04:00
Artem Bilan
8505da163d Increase a block timeout in Gateway Mono test
* It turns out that 1 seconds is not enough on CI machine under the stress
2020-04-18 11:13:53 -04:00
Artem Bilan
97702ae712 Fix some Sonar smells 2020-04-08 13:01:49 -04:00
Artem Bilan
d8c378bd28 GH-2788: Add MongoDbChangeStreamMessageProducer
Fixes https://github.com/spring-projects/spring-integration/issues/2788

* Introduce a `MessageProducerSupport.subscribeToPublisher(Publisher<Message<?>>)`
for components which produces `Flux` for data from their source
* Such a component is auto-stopped when subscription to that `Publisher` is canceled
* Implement a `MongoDbChangeStreamMessageProducer` based on the reactive support for
in Spring Data MongoDb
* Implement a Java DSL for `MongoDbChangeStreamMessageProducer`
* Disable a test for change stream since it requires server of version 4.x started with 'replSet' option
* Add `MongoHeaders` for change stream events

* Change `MessageProducerSupport` to use a `takeWhile((message) -> isRunning())`
instead of storing a `subscription` from a callback
* Document new features

* Remove trailing whitespaces

* Doc Polishing.
2020-04-07 16:51:55 -04:00
Artem Bilan
d24c2c8431 Fix Checkstyle violations & RMI tests
* Increase latch timeouts for `RedisLockRegistryLeaderInitiatorTests`
* Some RMI tests fail with different outcome because an RMI registry might be
available on default `1099` port.
Fix them to not rely on that port
2020-04-07 13:21:46 -04:00
Artem Bilan
3a846bad29 Fix some Sonar smells 2020-04-07 11:26:13 -04:00
Gary Russell
cc0c2fd2fe GH-3241: Fix Sonar issue 2020-04-07 10:32:01 -04:00
Gary Russell
7d7c273515 GH-3241: MetadataStoreSelector - compare old/new (#3242)
Resolves: https://github.com/spring-projects/spring-integration/issues/3241

 * Docs and XML namespace support.
2020-04-06 18:12:36 -04:00
Gary Russell
fcca7a7b26 GH-3230: MMIH: Fix Pausable/Lifecycle Methods
Resolves https://github.com/spring-projects/spring-integration/issues/3230

Previously, methods with the same name as `Lifecycle` methods were unconditionally ignored.

- Use logic similar to `ControlBusMethodFilter` to explicitly compare the candidate Method
  to those on `Paused` and `Lifecycle` and only ignore those.
- Explicitly disallow these methods when named - previously the check was only performed
  if no method name was supplied.

* - reinstate `Pausable/Lifecycle` methods if explicitly requested.
- log `Pausable` methods that are not candidates.

* - Fix typo in test method.

**Cherry-pick to 5.2.x**
2020-04-01 12:17:26 -04:00
Artem Bilan
76e79012fe GH-3219: Add HandleMessageAdviceAdapter (#3234)
* GH-3219: Add `HandleMessageAdviceAdapter`

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

* * Fix language in doc

Co-Authored-By: Gary Russell <grussell@pivotal.io>

Co-authored-by: Gary Russell <grussell@pivotal.io>
2020-04-01 11:10:33 -04:00
Artem Bilan
7433e41036 Add more Kotlin DSL for sub-flows (#3233)
* Add more Kotlin DSL for sub-flows

* Introduce `KotlinSplitterEndpointSpec`, `KotlinEnricherSpec` &
`KotlinFilterEndpointSpec` to avoid an explicit use of `IntegrationFlow` usage
from Kotlin DSL
* Fix `AbstractKotlinRouterSpec` to extend `ConsumerEndpointSpec` for access
to more endpoint options as it is with Java DSL for similar specs
* Introduce a `KotlinIntegrationFlowDefinition.publishSubscribe()`
for a `BroadcastCapableChannel` and `vararg` of `KotlinIntegrationFlowDefinition` builders.
This allows us to not introduce a `BroadcastPublishSubscribeSpec` wrapper for Kotlin
and let us to remove `publishSubscribeChannel()` DSL methods for `PublishSubscribeSpec`
since it is covered with the `publishSubscribe(PublishSubscribeChannel())` and
respective set of sub-flows in Kotlin DSL as subscribers
* Use new Kotlin specs in the `KotlinIntegrationFlowDefinition` instead of their
Java variants

* * Mention `kotlin-dsl.adoc` in the ToC
2020-04-01 11:06:54 -04:00
Artem Bilan
9c46b3420e Fix JsonToObjectTransformer for ClassNotFoundEx (#3228)
* Fix JsonToObjectTransformer for ClassNotFoundEx

Related to https://github.com/spring-projects/spring-integration/issues/3223

The `JsonToObjectTransformer` consults `JsonHeaders` first and tries to build
a `ResolvableType` from other type headers which may be just a string identifications.
In this case a `ClassNotFoundException` could be thrown if a `ResolvableType` cannot
be build against non-class identificators

* Add `valueTypeExpression` option to the `JsonToObjectTransformer` to let to
build a `ResolvableType` using any possible custom logic, e.g. resolving
target classes from some registry using their ids from the mentioned headers

**Cherry-pick to 5.2.x**

* * Fix English language mistakes
2020-03-27 15:42:24 -04:00
Artem Bilan
bff891b7a9 Fix new Sonar smells 2020-03-26 10:31:32 -04:00
Artem Bilan
b6bd83d548 Fix deprecation for TX; fix JMS tests; Moore-SR6
* Upgrade to Spring Data Moore-SR6
* Fix `TransactionHandleMessageAdvice` and `TransactionInterceptorBuilder`
for deprecations in the `TransactionInterceptor`
* Fix `TransactionHandleMessageAdvice` and `TransactionInterceptorBuilder`
consumers to expose new `TransactionManager`-based options and
deprecate `PlatformTransactionManager`-based
* Fix failing JMS tests to reuse an ActiveMQ Connection Factory with a
`trustedPackaged(*)`

**Cherry-pick to master**

# Conflicts:
#	build.gradle
#	spring-integration-core/src/main/java/org/springframework/integration/dsl/ConsumerEndpointSpec.java
#	spring-integration-core/src/main/java/org/springframework/integration/dsl/PollerSpec.java
#	spring-integration-core/src/main/java/org/springframework/integration/transaction/TransactionHandleMessageAdvice.java
#	spring-integration-core/src/main/java/org/springframework/integration/transaction/TransactionInterceptorBuilder.java
2020-03-25 13:56:37 -04:00
Gary Russell
fbf06e8bb5 GH-3181: MQTT: Support MANUAL Acks
Resolves https://github.com/spring-projects/spring-integration/issues/3181

* Doc polishing

* Rework acknowledgment into the existing `AcknowledgmentCallback`.

* Fix javadocs and doc linFix javadocs and doc linkk

* Doc polishing; explain uses of `ACKNOWLEDGMENT_CALLBACK` header.
2020-03-19 15:20:13 -04:00
Artem Bilan
3eedda6c9d GH- 3223: Build ResolvableType after mapping
Fixes https://github.com/spring-projects/spring-integration/issues/3223

The `json__TypeId__` header may have a value which cannot be resolved to the `Class` in the current classpath
So, skip `ResolvableType` building logic until we really sure that end-user wants to map JSON headers
* WARN a build exception that we can't load a class for the `json__TypeId__` when we try to build a `ResolvableType`
in the  `DefaultAmqpHeaderMapper`
* Document the negation feature for JSON headers

**Cherry-pick to 5.2.x**
2020-03-19 14:51:32 -04:00