Commit Graph

338 Commits

Author SHA1 Message Date
Gary Russell
648760bb43 GH-2776: Fix Streaming Remote File MessageSource
Fixes https://github.com/spring-projects/spring-integration/issues/2776
Also see https://github.com/spring-projects/spring-integration/issues/2777

- reset the filter for the current file if the fetch fails
- implement `Lifecycle` and clear the `toBeReceived` queue and corresponding
  filter entries

* Polishing - PR Comments **cherry-pick to all supported**

* Polishing

# Conflicts:
#	spring-integration-file/src/test/java/org/springframework/integration/file/remote/StreamingInboundTests.java
#	spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/FtpStreamingMessageSourceTests.java
#	spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcJavaConfigTests.java
2019-03-01 14:44:53 -05:00
Artem Bilan
04875b72b4 GH-2727: Ensure JDBC queries are logged (#2730)
* GH-2727: Ensure JDBC queries are logged

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

The `JdbcTemplate` logs a message for the sql to execute when it is
supplied by the `QueryProvider`.

* Refactor `JdbcPollingChannelAdapter` to use new introduced internal
`PreparedStatementCreatorWithMaxRows` with the `QueryProvider`
* Refactor `JdbcMessageHandler` to instantiate a `generatedKeysStatementCreator`
based on the `PreparedStatementCreatorFactory`
* Verify in the `JdbcOutboundGatewayParserTests` that both fixes logs
sql queries properly

* * Implement all the delegate interfaces for the `PreparedStatementCreatorWithMaxRows`
2019-02-08 14:27:03 -05:00
Artem Bilan
63684e2012 INT-4574: JDBC: Add NOT NULL for primary keys
JIRA: https://jira.spring.io/browse/INT-4574

Some RDBMS don't allow have nullable columns for primary keys

* Add NOT NULL for all the columns involved in primary keys
2019-01-14 17:33:27 -05:00
Gary Russell
e40cfe101e Sonar fixes
Hidden fields, `o.s.i.a*` through `o.s.i.j*`.
2019-01-09 10:02:19 -05:00
Gary Russell
e8df546b04 Sonar Fixes - Javadoc-only imports 2019-01-02 12:26:22 -05:00
Gary Russell
113a371f2c Remove Exception from IOS.onInit() 2018-12-22 17:25:56 -05:00
Artem Bilan
93d7c58b64 Enable ModifierOrderCheck Checkstyle rule (#2673)
* Enable ModifierOrderCheck Checkstyle rule

* Fix violations for `static` and `abstract` modifier
* Remove redundant code in the `TcpNioConnection`
* Mark `connectionFactoryName` as `@Nullable` in the `TcpConnectionSupport`
ctor and its inheritors
* Fix some smells according IDEA suggestions in the affected classes
* This should fix some Sonar smells as well

* * Fix `HeaderMapperTests`

* * Polishing `TcpConnection` code style and fix Javdocs
2018-12-20 19:19:47 -05:00
Gary Russell
7790f9e550 Sonar fixes
Critical issues `o.s.i.t*`, `o.s.i.u*`.

* Polishing - PR Comments.
2018-12-19 14:49:27 -05:00
Gary Russell
ca2e70f236 Sonar Fixes
Critical smells for `o.s.i.jdbc`.

Fix new smell in TCP.
2018-12-10 14:31:17 -05:00
Gary Russell
7135d0603c INT-4553: Store-backed QueueChannel improvements
JIRA: https://jira.spring.io/browse/INT-4553
Fixes https://github.com/spring-projects/spring-integration/issues/2628
Fixes https://github.com/spring-projects/spring-integration/issues/2629

- Avoid `size()` calls on the MGS, use `poll()` instead.
- Optimize the indexes for the `INT_CHANNEL_MESSAGE` table.

Avoid size call when no timeout too.

Polishing - PR Comments

Missed a doc fix

Another missed %PREFIX%

Fix underscores

Polishing; PR comments; make MGQ extendable.

Fix version in doc.

* Polishing `@since`
* Use diamonds whenever it is possible

**Cherry-pick to 5.0.x**
2018-11-30 13:07:59 -05:00
Gary Russell
852ec1ee25 INT-4557 Improve query cache in JDBC channel store
JIRA: https://jira.spring.io/browse/INT-4557

- Avoid hashing the query String on each call.
- Use a concurrent map.

* Polishing - PR Comments
2018-11-19 14:17:37 -05:00
Artem Bilan
648aeb8e96 Unable ImportOrder Checkstyle rule for tests
* Fix wrong import order in tests
* Polishing for not closed application contexts
* Use diamonds
* Use proper assertion operators
* Remove redundant classes
* Improve performance in JPA tests
* Fix typos
2018-11-07 15:32:31 -05:00
Gary Russell
2b9ba714e6 JDBC, JMS, JPA Sonar fixes 2018-10-26 14:26:43 -04:00
Artem Bilan
e3ce37ca36 INT-4544: Allow runtime MBeans (un)registered (#2601)
* INT-4544: Allow runtime MBeans (un)registered

JIRA: https://jira.spring.io/browse/INT-4544

* Fix `SourcePollingChannelAdapterFactoryBean` to register an
`outputChannelName` into the `SourcePollingChannelAdapter` for late
binding, especially in case of dynamic `IntegrationFlow` registrations.
This must be back-ported to `5.0.x`
* Implement `DestructionAwareBeanPostProcessor` in the
`IntegrationMBeanExporter` for the runtime beans tracking, e.g. via
dynamic `IntegrationFlow` registrations
* Refactor `IntegrationMBeanExporter` for static and dynamic beans
registration and destruction
* Remove unused properties; introduce some new for tracking beans and
their relationship

* * Move `IntegrationMBeanExporter.registerProducer()` after
`postProcessAfterInitialization()`
* Refactor JMX test configurations to reuse MBeanServer as much as
possible and destroy the server whenever it is necessary

* * More JMX tests polishing

* * And more JMX tests polishing

* * `try...catch` in the `IntegrationMBeanExporter.postProcessAfterInitialization()`
to avoid breaking changes for the current GA phase
* Do not unregister those MBeans explicitly which weren't created at
runtime

* * Log ObjectNames in the `MBeanExporterIntegrationTests`

* * Fix `MessageMetricsAdviceTests` to rely on the application context
* Do not use a cst in the `StandardIntegrationFlowContext` for
`BeanFactory`, but an explicit `BeanDefinitionRegistry`
* Extract targets from proxies in the
`IntegrationMBeanExporter.postProcessAfterInitialization()`
* Remove logging in the `MBeanExporterIntegrationTests`

* * Fix `NotificationListeningMessageProducerTests` to reuse existing `MBeanServer`

* * Change JMX `domain` in the `DslMBeanTests` to `dsl` do not clash with
similar in the `foo` in the `MessageSourceTests`
* Use `MBeanServer` bean in the `Int2307Tests`
* Use JUnit 5ctor injection injection in the `MessageMetricsAdviceTests`

* * Fix JMX tests do not reuse existing `MBeanServer` and make them rely
on the server provided by the managed `MBeanServerFactoryBean` which
destroys a server on application context close
* Fix `StoredProcJmxManagedBeanTests-context.xml` to use `MBeanServer`
from the `<context:mbean-server>`
2018-10-19 09:51:25 -04:00
Artem Bilan
4a85849bcc INT-3364: Add batchUpdate into JdbcMessageHandler (#2534)
* INT-3364: Add batchUpdate into JdbcMessageHandler

JIRA: https://jira.spring.io/browse/INT-3364

* * Optimize items mapping with an internal `Message` implementation
* Polishing Docs and Javadocs
2018-08-02 17:41:25 -04:00
Artem Bilan
0d0605be78 INT-4381: MessageSources refactoring (#2517)
* INT-4381: MessageSources refactoring

JIRA: https://jira.spring.io/browse/INT-4381

* Make all the out-of-the-box `MessageSource` implementations based
on the `AbstractMessageSource`
* Fix `JdbcPollingChannelAdapterIntegrationTests` for sporadic failure
because of `fixed-rate` for the poller

* Fix HeaderEnricherTests race condition

The `errorChannel()` expect an error in the `testErrorChannel` after
`1000` ms, but at the same time the `poller` in configured for the
`3000` ms.

* Increase all the timeouts for replies
* Decrease a `fixed-delay` on the `poller`
* Some other code style polishing for the `HeaderEnricherTests`
2018-07-25 13:01:22 -04:00
Artem Bilan
76877b9440 INT-4499: Add JdbcMetadataStore.setLockHint()
JIRA https://jira.spring.io/browse/INT-4499
Fixes https://github.com/spring-projects/spring-integration/issues/2483

To allow to reconfigure a `SELECT ... FOR UPDATE` for particular RDBMS
vendor, we need an option to specify possible hint for the target data base.

**Cherry-pick to 5.0.x**
2018-07-11 17:52:44 -04:00
Artem Bilan
0d11c7e0ed INT-4490: DefaultLockRepo: no uppercase format
JIRA https://jira.spring.io/browse/INT-4490

The `DefaultLockRepository.prefix` can be configured with the schema name.
And this one can be case-sensitive.

* Change format hint from the `%S` to `%s` to avoid upper-casing.

**Cherry-pick to 5.0.x and 4.3.x**
2018-07-11 17:38:54 -04:00
Sundara Balaji J K
01461720da Add Query Provider for SQL Server
* updated copyright year

* indentation issue fixed

* white space - build issue fixed

* Trailing whitespace - removed

* fixed pull request comments

* Rename `SqlChannelMessageStoreQueryProvider` to `SqlServerChannelMessageStoreQueryProvider`
2018-07-10 10:49:07 -04:00
Artem Bilan
32030c3233 INT-2260: JdbcPollingChA: rename prop to maxRows
JIRA: https://jira.spring.io/browse/INT-2260

Having a feedback about confusing with the `max-rows-per-poll` property
name and its responsibility it would be better do not mention `per-poll`
at all

* Deprecate `max-rows-per-poll` in favor of new `max-rows`
* Some code style polishing, tests improvements
* Docs polishing on the matter

* Add `What's New` bullet

* Optimize `maxRows` logic
* Document vendor-specific native SELECT limiting options
* Raise warning in the parsers about deprecated `max-rows-per-poll`

Doc polishing
2018-06-19 12:13:39 -04:00
brempusz
4bb1a619a9 GH-2467: JdbcLockReg: retry on TransDataAccessExc
* GH-2467: JdbcLockRegistry should retry on DeadlockLoserDataAccessException

Fixes #2467

MySQL 5.7.15 introduced setting `innodb_deadlock_detect` (enabled by
default). As a result MySQL JDBC driver throws
`DeadlockLoserDataAccessException` when deadlock is detected.
`JdbcLockRegistry` doesn't handle it causing lock to be lost.

* Retry `doLock()` on data access deadlock instead of loosing the lock

* Use TransientDataAccessException instead of derived exceptions
2018-06-07 12:56:33 -04:00
Gary Russell
73dbdb80be INT-4477: Add getRole() to LeaderInitiator Context
JIRA: https://jira.spring.io/browse/INT-4477

When running multiple roles, it is useful to be able to determine the
role for a particular context, e.g. in an event.

* Docs

**cherry-pick to 5.0.x**
2018-05-31 10:54:35 -04:00
Artem Bilan
664d67f9bb Add small sleep between adding message to group
https://build.spring.io/browse/INT-FATS5IC-497

Fixes `JdbcMessageStoreTests` sporadic failure where there is no
guarantee that message are going to be polled from the group the same
order they've been inserted

Cherry-pick to `5.0.x`
2018-05-04 13:06:09 -04:00
Artem Bilan
f970bf0332 Remove SQL scripts generation
We don't change JDBC scripts too often and even if we do that, it's not
so hard to copy/paste the script throughout all the supported platforms
instead of rely on the pretty old VPP tool and suffer from performance
degradation during regular day-to-day development.
Plus there is some bug in the VPP when it generates a script for the
Derby, so we end up with erroneous braces in the sentence:
```
MESSAGE_SEQUENCE BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
```
I have to remove them manually each time I switch between Gradle versions
2018-04-27 17:49:19 -04:00
Artem Bilan
6dfe96d220 Fix JdbcMessageStoreTests to use H2, not Derby
Looks like Derby is much slower than H2, plus it doesn't look so stable
having so much sporadic failures.

Looks like moving to H2 here saves for us `500 ms` test working time

**Cherry-pick to 5.0.x**
2018-04-23 12:54:32 -04:00
Artem Bilan
2f1b55f48c Upgrade to Gradle 4.7 and others, polishing build (#2423)
* Upgrade to Gradle 4.7 and others, polishing build

* Fix `MqttAdapterTests` according requirement of the latest Mockito
* Move `int-derby.properties` to the `/resources` from `/java`

* Fix Checkstyle violations
2018-04-20 11:11:05 -04:00
Artem Bilan
e4e4ee092d Fix JdbcMessageStoreChannelTests race condition
The message in the `QueueChannel` appears for consuming a bit earlier
than TX is committed

* Introduce `afterCommitLatch` into the test verify the state
when TX is really committed and data is removed from DB

**Cherry-pick to 5.0.x and 4.3.x**
2018-04-20 09:40:25 -04:00
Artem Bilan
82cbafaaa4 Downgrade to Derby-10.13.1.1
Looks like we have started to fail much often
since upgrade to the `Derby-10.14.1.0`:
cb0d43db6b

That is also related to this https://jira.spring.io/browse/INT-4445

* Remove all the `drop` mentioning for Derby scripts -
it just doesn't support `IF EXISTS`.
More over we don't need to worry about drops since each test now starts
its own fresh embedded DB

**Cherry-pick to 5.0.x**
2018-04-19 15:00:55 -04:00
Artem Bilan
15fc23c2fa INT-4447: LockRegLeaderInit: Catch unlock errors
JIRA: https://jira.spring.io/browse/INT-4447

When we get an exception during `this.lock.unlock()`, we don't revoke
leadership.
In case of external resource (e.g. JDBC) this may cause a race condition
when the second candidate is selected as leader when connection comes back

* Catch `this.lock.unlock()` exceptions and log them under DEBUG.
This way we proceed to the `handleRevoked()` logic

**Cherry-pick to 5.0.x and 4.3.x**
2018-04-18 17:07:07 -04:00
Gary Russell
b940e3872b Upgrade to SF 5.1; Remove Deprecated Code
Polishing - PR Comments

Remove direct log4j usage in tests

- hazelcast depends on it; retain the dependency just in jmx

Fix hazelcast logger type
2018-04-10 18:49:42 -04:00
Artem Bilan
27318c7ee5 INT-4445: Fix JDBC tests for Derby
JIRA: https://jira.spring.io/browse/INT-4445

Looks like `/dataSource` temporary directory is busy in between different
tests.
The thought is like a high-frequently polling endpoint keeps DB resource
from removing.

* Explicitly `stop()` endpoint in the `JdbcMessageStoreChannelTests`
* Optimize
`JdbcMessageStoreChannelTests.testSendAndActivateTransactionalSend()`
to rely on the short `1` millisecond TX timeout.
This safes for us 10 seconds of the tests executions.
* Configure all the embedded DB beans for the `ignore-failures="ALL"`
as a fallback option if polling endpoint is not a cause of the concurrent
resource access.

**Cherry-pick to 5.0.x**
2018-04-09 14:41:53 -04:00
Artem Bilan
7b86ca7bc8 Upgrade to H2 1.4.197
https://build.spring.io/browse/INT-FATS5IC-457

The H2 `1.4.197` has fixed some issues
(in particular https://github.com/h2database/h2database/issues/178)
and introduced some breaking changes for us, although they are
reasonably good.

* Fix `JdbcOutboundGatewayParserTests` to use correct identifiers
for returned generated keys instead of previously used `SCOPE_IDENTITY()`

**Cherry-pick to 5.0.x and 4.3.x**
2018-03-26 12:24:48 -04:00
Artem Bilan
da6f47cf40 Reorder beans in JdbcPollingChAParserTests cofigs
https://build.spring.io/browse/INT-AT42SIO-820/

The test configs use `fixed-rate="100"`.
This way when Inbound Channel Adapter is declared earlier in the
config than `<jdbc:embedded-database>`, there is a chance that we start
to poll DB before it is really initialized.

* Reorder config so embedded DB is initialized before an
Inbound Channel Adapter

**Cherry-pick to 5.0.x, 4.3.x and 4.2.x**
2018-03-26 11:07:36 -04:00
Artem Bilan
027021d6e4 Move XSDs to version 5.1
* Upgrade to Spring AMQP-2.1 and fix compatibility
2018-03-17 09:58:40 -04:00
Artem Bilan
cb0d43db6b Fix JDBC tests and some upgrades
https://build.spring.io/browse/INT-FATS5IC-430

Looks like there is a race condition when our polling rate around
data base is too fast and we have access to the DB files even during
application context close.

* Stop polling channel adapter in the tests explicitly after test methods
* Increase some tests performance decreasing timeouts to wait
* Upgrade to Reactor-3.1.5, AssertJ-3.9.1, Derby-10.14.1.0 and some
Gradle plugins

* Upgrade to `reactor-netty-0.7.5`
* Remove workaround from the `StompServerIntegrationTests`

* Upgrade to Spring Data Kay SR5

* Upgrade to Spring Security 5.0.3
* Increase timeouts and performance in the `StreamTransformerParserTests`
2018-02-28 11:57:21 -05:00
Artem Bilan
09aeaac4da INT-4396: Add retrying lock in case of exception
JIRA: https://jira.spring.io/browse/INT-4396

When target distributed `Lock` implementation throws an exception, e.g.
in case of no connection to the service, the `LockRegistryLeaderInitiator`
exists the loop and can come back to the elections only after restart

* Catch all the exception on `this.lock.tryLock()` and resubmit
`LeaderSelector` for a new locking cycle if
`LockRegistryLeaderInitiator.isRunning()` and `InterruptedException`

* Remove diagnostics from the `JdbcLockRegistryLeaderInitiatorTests`
since this fix confirms that we just didn't have a reconnect logic before
when this test failed sporadically

**Cherry-pick to 4.3.x**
2018-02-09 16:09:22 -05:00
Artem Bilan
2fbb6fbaf4 Fix JdbcLockRegDiffClientTests race condition
https://build.spring.io/browse/INT-MJATS41-1242

When different `DefaultLockRepository` instances use the same client id,
there is a possibility that they will update the same row in the table.
This way we have a chance that not only one obtains a lock and try to
add a value to the collection.

* Remove the test-case for the same client id as non-stable and even
dangerous by the the distributed lock purpose
* Use `tryLock(Long.MAX_VALUE)` to really ensure the wait behavior
during the concurrent loop
* Use `20` for thread pool to align with the tasks amount

**Cherry-picked to 4.3.x**
2018-01-24 17:26:33 -05:00
Artem Bilan
2736de99de Fix JdbcLockRegistry tests
https://build.spring.io/browse/INT-MASTER-901

The `JdbcLockRegistryDifferentClientTests.testOnlyOneLock()` relies
on the `ArrayList.isEmpty()` state to proceed with the logic.
But since the `ArrayList.size` property is not `volatile`, there is no
guarantee for the proper state in the multi-threaded environment like
we have in this test-case.

* Replace `ArrayList` in the test with the `LinkedBlockingQueue` which
already rely on the `AtomicInteger` for the `size` property
* Fix `JdbcLockRegistry` tests to shutdown used `ExecutorService` s
to ensure set free threads after test suite execution.

**Cherry-pick to 4.3.x**
2018-01-22 12:52:49 -05:00
Artem Bilan
30450c48be INT-4376: Upgage to Log4J 2 (#2321)
* INT-4376: Upgage to Log4J 2

JIRA: https://jira.spring.io/browse/INT-4376

* Deprecate Log4J 1.x components in favor of newly added
a `Log4j2LevelAdjuster` JUnit `@Rule`
* Update all the logging configuration to Log4J 2

* Polishing after testing
2018-01-11 10:59:55 -05:00
Artem Bilan
7c701ca5e6 INT-2576: Optimize JdbcMS.removeMessageGroup
JIRA: https://jira.spring.io/browse/INT-2576

* Do not fetch message ids and then iterate over them to remove
one by one - just use an appropriate `DELETE` query for all messages
2017-11-27 16:12:13 -05:00
Artem Bilan
098e8bc58f INT-4291: Post-merge polishing
JIRA: https://jira.spring.io/browse/INT-4291

* Fix code style in the `ExpressionEvaluatingSqlParameterSourceFactory`
* Remove redundant
`ExpressionEvaluatingSqlParameterSourceFactory.registerSqlTypes` in
favor of the direct access to the `sqlParametersTypes` from the
`ExpressionEvaluatingSqlParameterSource` ctor
* Reformat code style in the `pollingWithSelectParameterSourceJdbcInboundChannelAdapterTest.xml`
* Fix code style in the `ExpressionEvaluatingSqlParameterSourceFactoryTests`
* Polishing `whats-new.adoc` for proper formatting and single link from
the section to the particular chapter
* Fix formatting and wording in the `jdbc.adoc`
2017-11-06 11:33:05 -05:00
Meherzad Lahewala
854dba1366 INT-4291 Add ExprEvalSqlPSF.setSqlParameterTypes
JIRA: https://jira.spring.io/browse/INT-4291

* Fix checkstyle trailing space
*Use correct way to constants in spring xml and fix test case

* Polishing - Update javadoc and rename method name to relate more to the behavior
2017-11-06 11:19:01 -05:00
Artem Bilan
efb8f04465 Some upgrades and fixes
* Upgrade to SF-5.0.1, Reactor-3.1.1, some other minor upgrades
* Fix `HttpDslTests` and `WebFluxDslTests` for the latest SS compatibility
* Fix JavaDoc in the `ChannelMessageStorePreparedStatementSetter`
2017-10-25 10:52:47 -04:00
Artem Bilan
d7d56a0444 INT-4081: Post-merge polishing and improvements
JIRA: https://jira.spring.io/browse/INT-4081

* Rename `MessageGroupPreparedStatementSetter` to `ChannelMessageStorePreparedStatementSetter`
* Add JavaDocs to the `ChannelMessageStorePreparedStatementSetter`
* Polishing `JdbcChannelMessageStore` JavaDocs; remove unused `BeanFactory`
* Polishing Docs for typos and proper text flow
2017-10-23 11:48:35 -04:00
Meherzad Lahewala
34d0859515 INT-4081: Custom PreparedStSetter for JdbcMChStore
JIRA: https://jira.spring.io/browse/INT-4081

* Add `MessageGroupPreparedStatementSetter` to let end-user to override
the message insertion logic
* Add tests and Docs
2017-10-23 11:48:34 -04:00
Glenn Renfro
1979f91cf5 INT-4357: LeaderInit: Add failed to lock event
JIRA: https://jira.spring.io/browse/INT-4357

Updated based on code review.

Updated adocs

*Polishing code style, typos
* Add protection from NPE when `LockRegistryLeaderInitiator` isn't
supplied with the `leaderEventPublisher`
* Add `What's New` note
2017-10-13 13:15:12 -04:00
Glenn Renfro
e515a0d643 INT-4353: Let to set id for DefaultLockRepository
JIRA: https://jira.spring.io/browse/INT-4353

Updated based on code review

* Polishing according PR comments

**Cherry-pick to 4.3.x**
2017-09-29 09:57:59 -04:00
Gary Russell
0d495294ed INT-4342: White List for Payload Deserializer
JIRA: https://jira.spring.io/browse/INT-4342

Use similar code to Spring AMQP to add white list support for Integration's
use of the `DeserializingMessageConverter`; introduce the `WhiteListDeserializingMessageConverter`.

Polishing

Missed this change in PR.

Fix XSD attribute
2017-09-08 15:31:47 -04:00
Artem Bilan
4fd32d2bd4 Document max-rows-per-poll for the JDBC Gateway
StackOverflow https://stackoverflow.com/questions/45611037
2017-08-10 16:52:44 -04:00
Artem Bilan
0f78d4b2ec Some JDBC tests polishing and optimization
**Cherry-pick to master**

Conflicts:
	build.gradle
	spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/DataSource-derby-context.xml
2017-07-26 16:16:07 -04:00