Commit Graph

9623 Commits

Author SHA1 Message Date
Gary Russell
dffaf08510 Upgrade to Spring Framework 5.0 RC1 2017-05-08 14:44:30 -04:00
Artem Bilan
47433754b8 INT-4258: Redis: Make ZADD INCR False by Default
JIRA: https://jira.spring.io/browse/INT-4258

Since Redis `ZADD` command doesn't perform incrementation by default,
it should be consistent in the `RedisStoreWritingMessageHandler` as well

* Make a default behavior of the `RedisStoreWritingMessageHandler`
regarding `INCR` option as `false`
* Provide some performance refactoring for the
`RedisStoreWritingMessageHandler`  moving the code to Java 8 style
and using `FunctionExpression`
* Fix tests according to the changed default behavior

* Add `setZsetIncrementExpression` and String-based setters for other
expressions on the `RedisStoreWritingMessageHandler`
* Add `zset-increment-expression` option for XML configuration
* Add `What's New` note on the matter

Polishing
2017-05-08 14:43:43 -04:00
Artem Bilan
2dfb0808b3 Upgrade to Spring AMQP 2.0.0.M4 2017-05-08 14:39:56 -04:00
Artem Bilan
d1c39dff10 Fix race condition in the AMQP ChannelTests
https://build.spring.io/browse/INT-AT42SIO-502

There is a small time window when we remove the current consumer
from the local store, but there is no a new one yet.
So, we have to check the `Set`(`Map`) size before calling its `iterator`

**Cherry-pick to 4.3.x**
2017-05-08 13:10:35 -04:00
Gary Russell
07891ed9a3 Fix Sonar False Positive 2017-05-08 12:52:30 -04:00
Gary Russell
2b4c343eaa INT-4270: CGLib Compatibility
JIRA: https://jira.spring.io/browse/INT-4270

Initial Commit

Remove `final` modifier from certain critical framework methods that prevent CGLib proxies working.

Since Spring Boot 2.0 now uses proxyTargetClass=true by default (and has done that for
transactional proxies since 1.4), we must relax these restrictions so that CGLib can
proxy channels (which is often done to make subflows run in a transaction).

When CGLib can't override a `final` method, the fields used within those methods are uninitialized.
In the case of `AbstractMessageChannel` this causes an NPE on the unitiallized `dataTypes` field.
With `MessageHandler`, fields like `shouldTrack` are always false.

Further, methods on `IntegrationObjectSupport` - such as `getComponentName()` return null.

I have left setters and `afterPropertiesSet` (on IOS) `final` since these will typically be called
before the object is proxied.

I suspect there will be other methods we need to open up, but perhaps we should only do them on-demand.

__cherry-pick to 4.3.x__
2017-05-05 09:37:18 -04:00
Gary Russell
168f372dd4 Make DefaultHttpHeaderMapper Easier to Subclass
It's difficult to subclass this mapper (e.g. to extend `toHeaders` to tweak the map)
because the factory methods for inbound and outbound mappers use private static fields
to set up the standard header mapping.

Extract that logic so that subclasses can create similar static methods and invoke the
setup code to set the standard header mapping.

Polishing: make more `DefaultHttpHeaderMapper` members available for inheritors
2017-05-04 17:27:26 -04:00
Gary Russell
747b59e078 Update to Stable Reactor Versions 2017-05-04 11:00:18 -04:00
Gary Russell
572467b1c4 INT-4260: MessagePublishingErrorHandler Orig. Msg
JIRA: https://jira.spring.io/browse/INT-4260

MPEH: Populate the `ErrorMessage.originalMessage`,
if available and not the same as the `failedMessage`.

Polishing - rename exception to `MessagingExceptionWrapper`;
 make `MPEH` a subclass of `ErrorMessagePublisher`

PR Comments

Polishing - PR Comments
2017-05-03 16:32:49 -04:00
Artem Bilan
18f9fcbb59 INT-4259: ACorrelationMH: WARN group reschedule
JIRA: https://jira.spring.io/browse/INT-4259

Since DEBUG can switched off for the application, it becomes difficult
to determine the wrong configuration for the discard flow from
the scheduler thread.

* Change logging level to the `WARN` and log the full stack-trace as well
to give more information about the reason of rescheduling group for
`forceComplete`

**Cherry-pick to 4.3.x**
2017-05-03 10:04:52 -04:00
Artem Bilan
9de2856ae6 Groovy test: Fix format for MM instead of mm
https://build.spring.io/browse/INT-AT42SIO-498/

**Cherry-pick to 4.3.x and 4.2.x**
2017-05-02 17:31:20 -04:00
Artem Bilan
f03356ccbc INT-4265: Add Java DSL .routeByError() EIP-Method
JIRA: https://jira.spring.io/browse/INT-4265

* Add `.routeByError()` EIP-method to the `IntegrationFlowDefinition`
based on the `ErrorMessageExceptionTypeRouter`
* Add missed `dynamicChannelLimit()` option to the `RouterSpec`
* Rework `RouterSpec#RouterMappingProvider` into the `ContextRefreshedEvent`
phase initialization to be sure that dependent `MappingMessageRouterManagement`
is fully initialized before applying mapping conversions

* Rename `routeByError()` to `routeByException()` to more reflect reality
of the `ErrorMessageExceptionTypeRouter` and don't mislead about
Java's `Error`
* Polish `ErrorMessageExceptionTypeRouter` JavaDocs a bit and some Java 8
code style
* Add `ApplicationContext` assertion into the
`RouterMappingProvider.onApplicationEvent()` do not trigger delegate
initialization if `ContextRefreshedEvent` is from the different app context
2017-05-02 14:26:04 -04:00
Gary Russell
ca231763a3 Rename ReactiveChannel
- as discussed last week

TODO:
- should we take the channel outside of the `AbstractMessageChannel` hierarchy?
  - avoid blocking interceptors
  - we would lose channel metrics though
- rename `ReactiveConsumer` ?

Polishing some missed renaming
2017-05-01 13:45:35 -04:00
Artem Bilan
cd4964eb7f INT-4262: Fix SQL scripts for IF EXISTS clause
JIRA: https://jira.spring.io/browse/INT-4262

Since MySQL doesn't have `IF EXISTS` for `DROP INDEX`.
And on the other hand the entire `DROP TABLE` takes care about indexes as well,
we don't need the `DROP INDEX` command for mysql.properties
* Add `NODROPINDEX` variable to the `mysql.properties`
* Tweak `destroy.sql.vpp` to leverage `NODROPINDEX`
2017-04-28 14:58:05 -04:00
Artem Bilan
b869666021 INT-4261: Do not Register Resource to TX Twice
JIRA: https://jira.spring.io/browse/INT-4261

When we have some `Advice` withing TX Advice which may perform `doPoll()`
several times, we unconditionally call
`transactionSynchronizationFactory.create(resource)`.
With the out-of-the-box implementations
`DefaultTransactionSynchronizationFactory` and
`PassThroughTransactionSynchronizationFactory`
we preform `TransactionSynchronizationManager.bindResource()`.
If resource is already there, an `IllegalStateException` is thrown

* Check that resource isn't bound already to the TX and don't create a new
`TransactionalResourceSynchronization` - just return `null`
* Check in the target users for the `null` before registering synchronization

Move resource registration to TX outside of out-of-the-box factories

* Fix condition in the `AbstractPollingEndpoint` for the resource
* Increase responsiveness of TX test to decreasing `fixed-delay`
and using `receive-timeout="-1"`
2017-04-28 12:56:03 -04:00
Gary Russell
1282cb522a Align With Spring Boot Dependencies
- Various deps and update to commons dbcp2
- Fix a couple of DOS EOL files
2017-04-27 10:11:49 -04:00
Artem Bilan
1557e3de21 Fix unused imports 2017-04-26 11:36:51 -04:00
Artem Bilan
026484c382 Compatibility with the latest dependencies
* Upgrade to Gradle 3.5, SS-5.0, Hibernate-5.2.10, Mockito-2.7.22, Pah-1.1.1
And some other minor upgrades
* Fix deprecations for Mockito compatibility
* Fix `ServletWebSocketHandlerRegistry` deprecations
* Fix SD-Mongo deprecations
* Tweak JMX tests to avoid dangling threads after tests exist
* Increase timeouts in some polling tests
2017-04-26 11:29:18 -04:00
Artem Bilan
3c047c5076 INT-4264: .publishSubscribeChannel(): fix order
JIRA: https://jira.spring.io/browse/INT-4264

When we use Java DSL `.publishSubscribeChannel()`, we expect that subscribers
will be called in the order they are defined in the flow.
But actually everything is depend on the populated `MessageHandler` implementation.
The `AbstractMessageHandler` implements `Ordered` and according the
`OrderedAwareCopyOnWriteArraySet` logic they are placed in the beginning of the
handlers set, meanwhile all others (un-ordered) are moved to the end.

* Add implicit `.bridge()` to all the subFlows added to the `PublishSubscribeSpec`.
This way all the subFlow subscribers will be ordered the same way (because of
`BridgeHandler`) and, therefore, will be preformed in the expected (as declared) order
2017-04-25 14:28:11 -04:00
Artem Bilan
a9aeff3ae1 Fix HTTP Reactive support according latest SF 2017-04-25 11:51:24 -04:00
Gary Russell
c66540593c INT-4257 Polishing - Subclasses: buildErrorMessage
JIRA: https://jira.spring.io/browse/INT-4257

So that subclasses can also generate error message for conditions such
as message conversion errors.

Polishing - PR Comments

Fix JMS buildErrorMessage Override

Update Copyrights
2017-04-24 13:35:13 -04:00
Vedran Pavic
1dc3726e7d Make LockRegistry#obtain Java 8 based
This commit harmonizes `LockRegistry#obtain` logic in Zookeeper and JDBC
implementations with Redis implementation
by using Java 8 `ConcurrentMap#computeIfAbsent`

* Remove `synchronized (this.locks)` from the `expireUnusedOlderThan`
implementations because `iterator()` is thread-safe from `ConcurrentHashMap`
* Fix deprecation in the `IntegrationGraphControllerRegistrar`
* Revert Spring Security version to `4.2.2`, since `5.0 B-S` is broken
2017-04-21 20:00:34 -04:00
Artem Bilan
7f2c1d6ecd Fix a couple null typos in the Reference Manual 2017-04-20 13:46:39 -04:00
Artem Bilan
71b93987d7 INT-4257-2: Document ErrorMessagePublisher
JIRA: https://jira.spring.io/browse/INT-4257

* Remove deprecated `EnhancedErrorMessage`
* Document `ErrorMessagePublisher` and `ErrorMessageStrategy`
* Fix Reactor version to `3.1` in Doc
* Fix sample about Reactive Streams in the `router.adoc`
2017-04-20 11:52:40 -04:00
Vedran Pavic
f7f7bdd067 INT-4248: Refactor RedisLockRegistry
JIRA: https://jira.spring.io/browse/INT-4248

To avoid unexpected double locking behavior in the cluster,
remove the local cache functionality.

Now with the new `clientId` property, the `expire` for the record in
store is always update on each lock operation
2017-04-19 18:18:52 -04:00
Artem Bilan
28058884f4 INT-4257: Introduce ErrorMessagePublisher
JIRA: https://jira.spring.io/browse/INT-4257

To make a target `ErrorMessage` customizable introduce
`ErrorMessagePublishingRecoveryCallback` and
`ErrorMessageStrategy` to inject

**Cherry-pick to 4.3.x**

Fix `ErrorMessagePublishingRecoveryCallback` generic type for
`RequestHandlerRetryAdvice` compatibility

Polishing

- Support publishing when no retry context is available
- Use a constant for the message context key

Add EnhancedErrorMessage

- contains input message at time of error message generation
- make the default RecovererErrorMessageStrategy public and extensible

Fix `RetryAdviceParserTests` for new `RecoveryCallback` architecture

Rename to `ErrorMessagePublisher`
Decouple ErrorMessagePublisher from Retry

Refactoring for better purpose reflection and JavaDocs

Use `ErrorMessageStrategy` in message producers.

Add JavaDocs to the `DefaultErrorMessageStrategy`

Deprecate EnhancedErrorMessage

Minor Polish for Subclass Use

- make setters final
- allow subclasses to supply the AttributeAccessor

Fix Tests
2017-04-19 17:54:32 -04:00
Artem Bilan
5224779a04 INT-4050: Refactoring for JDBC Schema Scripts
JIRA: https://jira.spring.io/browse/INT-2625,
https://jira.spring.io/browse/INT-4050,
https://jira.spring.io/browse/INT-4052

Make some refactoring for consistency:

- Move `JdbcMessageStore` to the `store` package
- Make `JdbcMessageStore` only ctor-based configuration for the `JdbcOperations`
- Remove `/channel/` SQL scripts in favor of combined in the `/jdbc/` directory
- Make scripts for the `INT_CHANNEL_MESSAGE` table and indexes generated via VPP

Fix drop script generation

Fix `schema-derby.sql` for suspicious `[]`

Looks like `foundrylogic.vpp` tool generates somehow wrong SQL

Further fix for the `drop` scripts generation

Address PR comments:

* Remove deprecated code in the `JdbcMessageStore`
* Remove separate MySQL script in favor of only one for latest version
* Remove the note in the `jdbc.adoc` about recommendation to use new MySQL version
2017-04-18 17:34:01 -04:00
Artem Bilan
34db64c832 INT-4254: LockRegLInit: Fix unconditional unlock
JIRA: https://jira.spring.io/browse/INT-4254

The `LockRegistryLeaderInitiator#LeaderSelector` unconditional calls
`unlock()` in the `finally` block when the `Lock` might not be locked.

Another problem that `running = true` is set after submitting `LeaderSelector` task.
That might bring the problem that `LeaderSelector` won't be selected because of
`this.running` race condition

* Move `this.running = true` before submitting `LeaderSelector` task
* Move `unlock()` into the `if (this.locked)` condition

**Cherry-pick to 4.3.x**
2017-04-18 15:22:40 -04:00
Gary Russell
c5e66ec65c Fix Promise->Mono Test Name and Beans 2017-04-16 13:33:31 -04:00
Gary Russell
effca79f3f Upgrade to Reactor 3.1
Polishing

- remove catch from test
- update netty for stomp

Add reactiveErrorHandler to AbstractMessageHandler
2017-04-14 22:14:21 -04:00
Gary Russell
da1b635d99 Fix Javadoc for HttpHeaderMapper 2017-04-14 18:42:23 -04:00
Artem Bilan
5e628b3692 Fix ErrorMessages typo in the configuration.adoc
The `ErrorMessages` may confuse people since there is no such a class.

http://stackoverflow.com/questions/43318551/error-message-was-not-delivered-headers-null

* Fix `ErrorMessages` code to the `ErrorMessage` s
2017-04-10 09:17:25 -04:00
Artem Bilan
9e175054d0 Upgrade to the SF and SA BUILD-SNAPSHOTs
* Upgrade to Jackson-2.9.0 to align with SF
* Fix `ReactiveHttpRequestExecutingMessageHandler` to use latest `WebClient`
* Introduce `Supplier<URI> uriSupplier` to evaluate the `realUri` on demand.
In case of `WebClient` use `.uri(Function)` to perform `uriSupplier`
* Move `doNext()` for the `WebClientException` out of `one-way` block.
According the `RestTemplate` logic the erroneous response is handled
before returning from the `exchange()`.
Therefore both request/reply and one-way scenarios must have the same
error handling logic
* Some refactoring to the `AbstractHttpRequestExecutingMessageHandler`
and `AbstractHttpRequestExecutingMessageHandler` according a new `uriSupplier`
2017-04-08 08:46:13 -04:00
Gary Russell
f751398cfe ARFOGateway: Directory LiteralExpression->Value...
Using a `LiteralExpression` in the `AbstractRemoteFileOutboundGateway` (when the
user provides a `File` for the directory) causes us to create a new `File` object
each time, instead of using the user-supplied `File`.

Use a `ValueExpression` instead.

Move the `FileWritingMessageHandler` logic to `ExpressionUtils` and use it from both places.

Also add a String setter variant for convenient Java Configuration.
2017-04-06 11:42:22 -04:00
Artem Bilan
d5c633d703 Fix LockRegLeaderInitiatorTests race condition
https://build.spring.io/browse/INT-FATS5IC-129/

Since leader selection is done on background thread in the
`LockRegistryLeaderInitiatorTests`, there is no guarantee that
after `Thread.sleep(100)` the lock will be obtained and leader state is
changed.

* Waiting for the `granted` `CountDownLatch` is much robust condition
2017-04-06 10:47:22 -04:00
Spring Buildmaster
903aca1e7b [artifactory-release] Next development version 2017-04-05 19:32:18 +00:00
Spring Buildmaster
03d441c65b [artifactory-release] Release version 5.0.0.M3 2017-04-05 19:32:12 +00:00
Artem Bilan
f13b253c2f Fix Reference Manual for wrong format and links 2017-04-05 14:41:32 -04:00
Artem Bilan
19c5402079 INT-4208: Add WebFlux-Based HttpMessageHandler
JIRA: https://jira.spring.io/browse/INT-4208

Since `AsyncRestTemplate` is deprecated in Spring 5.0, it doesn't make
sense to promote that feature via our new `AsyncHttpRequestExecutingMessageHandler`
component

* Rework (and rename) `AsyncHttpRequestExecutingMessageHandler` to
`ReactiveHttpRequestExecutingMessageHandler` and make it based on the
WebFlux `WebClient`
* Fix Java DSL (`ReactiveHttpMessageHandlerSpec`) and all tests according a new
logic in the `ReactiveHttpRequestExecutingMessageHandler`
* Fix XML namespace support to use new `ReactiveHttpRequestExecutingMessageHandler`
and don't expose unused options like `converters` and `request-factory`
* Fix `What's New` and `http.adoc`
* To remain with `async` mode for the `ReactiveHttpRequestExecutingMessageHandler`
behavior support fix `AbstractMessageProducingHandler` to adapt reply `Mono`
to the `SettableListenableFuture`
* Introduce new `reactive` behavior for the `AbstractMessageProducingHandler`
when `outputChannel` is `ReactiveSubscribableChannel` and perform
`.subscribeTo(Publisher)` for `Publisher` reply
* Upgrade to Spring AMQP `2.0 M3`
* Downgrade to Spring Security `4.2.2`

Address PR comments

Add async error handling to the one-way case

Minor polishing and checkstyle fix
2017-04-05 13:00:50 -04:00
Gary Russell
d954e6a66f Upgrade to Spring Data Kay 2.0.0.M2 2017-04-04 16:51:40 -04:00
Artem Bilan
499e1167d1 Upgrade to Reactor-3.0.6
According to some rework and deprecations in the latest Reactor,
fix Reactor-based components to follow with the latest paradigmas

* Use `Flux` wrapper in the `ReactiveChannel` to track cancellation
instead of deprecated `Operators.SubscriberAdapter`
* Do similar `Flux.from(publisher)` in the `doSubscribeTo()`
to avoid subscribers delegation and, therefore, unnecessary call stack
* Rework `ReactiveConsumer` to wrap to a new `BaseSubscriber`
on each `ReactiveConsumer.start()`.
We need this wrapping to prevent subscriber cancellation from the
upstream `Publisher` on error.
We can't rely here on the `Flux.retry()` because upstream
`DirectProcessor` is marked as terminated on any error

Apply Reactor-3.0.6.RELEASE
2017-04-04 10:06:08 -04:00
Artem Bilan
8902fb9489 Fix DisposableBean omission for Java DSL
http://stackoverflow.com/questions/43193858/tomcat-hangs-shutting-down-with-spring-integration-java-dsl

Using manual singleton registration doesn't provide automatic
`DisposableBean` registration

* Improve `IntegrationFlowBeanPostProcessor` to register `DisposableBean`  as well
* Improve `IntegrationFlowContext` to register `DisposableBean`  as well
2017-04-03 19:36:01 -04:00
Gary Russell
80d22cb46d INT-4086: Fix Array Argument Copy
Don't keep a reference to caller's array.
2017-04-03 15:55:45 -04:00
Artem Bilan
96ca9647a4 INT-4086: (S)FTP: Add Local File Tree Support
JIRA: https://jira.spring.io/browse/INT-4086

The remote files may be carried with sub-path, not just file name.
The same sub-dirs logic can be achieve with the `localFilenameGeneratorExpression`

* Add the logic into `AbstractInboundFileSynchronizer` to build sub-dirs for local files
* Switch on `WatchService` for the internal `FileReadingMessageSource` in the `AbstractInboundFileSynchronizingMessageSource` to react for all the changes in the `localDirectory`

Introduce `RecursiveDirectoryScanner` and use it for `AbstractInboundFileSynchronizingMessageSource` by default

* Add `maxDepth` and `fileVisitOptions` options to the `RecursiveDirectoryScanner`
* Polishing JavaDocs, tests and docs
2017-04-03 15:48:13 -04:00
Gary Russell
6dbc721d73 INT-4249: AMQP: Configurable Header Mapping Order
JIRA: https://jira.spring.io/browse/INT-4249

Add `headersMappedLast` to outbound endpoints and channels.

* Fix typos in JavaDocs and `amqp.adoc`
2017-04-03 15:38:22 -04:00
Artem Bilan
2862c449c5 INT-4251: Add Initial Testing Framwork and Docs
JIRA: https://jira.spring.io/browse/INT-4251

MockIntegration PoC

Demonstrate how `MockIntegration.mockMessageSource()` can be used.
Even from the XML Config!
The same semantics can be applied for any other our mocking features we will add to the `MockIntegration`

Add `testMockMessageSourceDynamicFlow()`

Improve `MockIntegration.Context.instead()` for target bean type assertion

Some refactoring, improvements and JavaDocs

* Move `MockIntegration.Context` to its own `MockIntegrationContext` class
* Rename `@MockIntegrationTest` to `@SpringIntegrationTest` since we talk there not only about mocks, but any other possible testing feature for integration
* Add `@SpringIntegrationTest#stopEndpoints()` attribute for endpoints bean names patterns
* Add `IntegrationEndpointsInitializer` to customize `AbstractEndpoint`s according options from the `@SpringIntegrationTest`
Right now it is only about making them `autoStartup = false`

* Rename `SI-test` to `SI-test-support`
* Rename `SI-mock` to `SI-test`
* Rename `@SpringIntegrationTest#stopEndpoints()` to `noAutoStartup()`
* Fix JavaDocs according PR comments
* Increase timeouts in some sporadically failed tests
* Draft for the `testing.adoc`

Fixes spring-projects/spring-integration-java-dsl#23

Fix `testing.adoc` a bit

* Document Testing Support
* Fix a couple typos in the `xml.adoc`
* Add `package-info.java` files to `/test/` sub-packages

Improve docs according PR comments

Fix typos in `TestUtils` JavaDocs

Add `What's New` note about Java DSL and Testing support

Doc Polishing
2017-03-31 14:39:08 -04:00
Gary Russell
610ad7e0e1 JavaConfig/DSL Docs for Routers (Part 2) (#2104)
* JavaConfig/DSL Docs for Routers (Part 2)

Add String Expression ctor to `ExpressionEvaluatingRouter`.

* Polishing - PR Comments
2017-03-30 15:18:22 -04:00
Gary Russell
fac04aeece INT-4250: Fix Statistics Mean Decay with Time
JIRA: https://jira.spring.io/browse/INT-4250

When retrieving the mean from `ExponentialMovingAverageRate` or
`ExponentialMovingAverageRatio` via `getStatistics()` the mean did not
decay over time.

The mean did decay when using `getMean()`.

This was caused by the statistics performance refactoring.
2017-03-29 13:52:54 -04:00
Gary Russell
b06db72652 Http Java/DSL Configuration Docs
http://stackoverflow.com/questions/33295750/spring-integration-http-outbound-gateway-header-mapper/33305880#comment73265510_33305880
2017-03-29 09:47:45 -04:00
Artem Bilan
75fe5d0f72 Fix HTTP out DSL for uri variables propagation
Since `AbstractHttpRequestExecutingMessageHandler` does a copy of
the provided `uriVariableExpressions`, we lose a coupling propagating
from the ctor.

* Move `uriVariableExpressions` propagation from the ctor to the
`getComponentsToRegister()`
2017-03-28 11:33:00 -04:00