Commit Graph

9623 Commits

Author SHA1 Message Date
Artem Bilan
16be9fc47d INT-3502: filters for @IntegrationComponentScan
JIRA: https://jira.spring.io/browse/INT-3502

For some use-cases it is really useful to filter `@MessagingGateway` components as any other `@ComponentScan` capable.

* Add `useDefaultFilters()`, `includeFilters()` and `excludeFilters()` to the `@IntegrationComponentScan`
* Modify `GatewayInterfaceTests` to reflect changes and be sure that logic is applied properly
2016-10-28 15:26:21 -04:00
Gary Russell
49638fdea2 INT-4148: Don't Wrap AMQP Listener Exceptions
JIRA: https://jira.spring.io/browse/INT-4148

The subscribable channel incorrectly wrapped exceptions such as `MessageConversionException`
preventing the error handler from properly handling them.
2016-10-28 11:31:13 -04:00
Gary Russell
c5fbd93787 Mockito Polishing
`$ find spring-integration-* | grep '\.java$' | xargs sed -E -i '' -e 's/(\(?)\(([^<()]*)\) *invocation.getArguments\(\)\[([0-9]*)\]/\1invocation.getArgumentAt(\3, \2.class)/'`
2016-10-28 11:06:05 -04:00
Gary Russell
9225c514fe Core Lambdas - Phase 1 src/main
Also package-protect private inner class ctors.

Core Lambdas - Phase 2 src/test
2016-10-26 18:02:38 -04:00
Artem Bilan
c6026ce8fe Remove Java 7 restriction in FileWritingMH
Since SI-5.0 is based on Java 8 no reason to have condition for the `java.nio.Files` class in the `FileWritingMessageHandler`
Also add package protected ctors to the inner private classes in the `FileWritingMessageHandler` to avoid generated synthetic classes in case of default ctor

Address PR comments

Remove redundant log for `IOException` on `Files.move()`
2016-10-26 14:38:49 -04:00
Gary Russell
c865d38576 More Lambdas
Also, make inner ctors package rather than private to avoid the synthetic class and method
the compiler has to create.

See: http://stackoverflow.com/questions/921025/eclipse-warning-about-synthetic-accessor-for-private-static-nested-classes-in-jav

JMX Lambdas

Polishing - clean up

More
2016-10-26 09:54:49 -04:00
Gary Russell
7b1d43a6dc INT-4147: Remove Unnecessary null Check
JIRA: https://jira.spring.io/browse/INT-4147

instanceof returns false for null.
2016-10-25 11:55:20 -04:00
Artem Bilan
8c95f001da INT-4147: Fix NPE in the FileReadingMessageSource
JIRA: https://jira.spring.io/browse/INT-4147

By default `FileReadingMessageSource` is created without `filter`, at the same time internal `WatchServiceDirectoryScanner` is supplied with default `filter` by its `DefaultDirectoryScanner` super class.
A `DELETE` watch event condition around `FileReadingMessageSource.this.filter` is wrong, because it is `null` by default. Therefore `DELETE` events never succeed

* Modify `FileInboundTransactionTests` to accept `DELETE` watch event as well and verify that `ResettableFileListFilter.remove(File)` is performed
* Call newly created getter for `DefaultDirectoryScanner.filter` in the `WatchServiceDirectoryScanner` to assert against supplied `filter`

Polishing

**Cherry-pick to 4.3.x**
2016-10-25 11:43:36 -04:00
Andriy Kryvtsun
ee848e9ecf INT-4144: Prevent NPE in the LoggingHandler
JIRA: https://jira.spring.io/browse/INT-4144
Fixes GH-1936 (https://github.com/spring-projects/spring-integration/issues/1936)

Previously `LoggingHandler` could be used as a standalone object, without any Spring Container initialization.
Even if that doesn't sound reasonable, we should reinstate the logic to avoid breaking changes

* Initialize `expression` and `evaluationContext` during object `<init>` phase
* Some code reformatting to avoid duplicate blocks and cyclomatic complexity

* Simple code formatting
* Additional JavaDocs for `LoggingHandler`

**Cherry-pick to 4.3.x**
2016-10-25 10:52:30 -04:00
Artem Bilan
a1a3c2a1ac INT-4146: FileWriteMH: protect for OutStr errors
JIRA: https://jira.spring.io/browse/INT-4146
Fixes GH-1942 (https://github.com/spring-projects/spring-integration/issues/1942)

Previously the `FileWritingMessageHandler` didn't wrap `new OutputStream()` to the `try...catch...finally` block, therefore any errors on that (e.g. `FileNotFoundException` because of permissions) cause an early exist without `inputStream.close()`

* Move a `new OutputStream()` to the `try...catch`
* Change `destinationDirectory.canWrite()` to the `Files.isWritable(destinationDirectory.toPath())` because the first one doesn't work on Windows

**Cherry-pick to 4.3.x and 4.2.x but without Files.isWritable() change**
2016-10-24 13:38:38 -04:00
Gary Russell
e6c70b5cc6 File Streaming Doc Polishing
http://stackoverflow.com/questions/40135591/get-string-from-spring-ftp-streaming-inbound-channel-adapter/40136021#40136021

Show an example for removing the remote file after processing.
2016-10-23 10:16:40 -04:00
Artem Bilan
93d932c095 SftpOutboundGateway: DFA -> Method Invocation
**Cherry-pick to 4.3.x**

Polishing - Make Method Accessible
2016-10-23 09:59:48 -04:00
Gary Russell
2ad0a44083 INT-4145: Fix Mocking Issue
JIRA: https://jira.spring.io/browse/INT-4145

Strange stubbing failure on spied template.

Perhaps some JIT interaction since the method is used normally before stubbing.

Change the spy to a mock for the last part of the test.

Remove comment before the mock since it isn't relevant any more
2016-10-20 15:02:33 -04:00
Gary Russell
0c1a7658d7 INT-4141: (S)FTP Streaming - throw Exception
JIRA: https://jira.spring.io/browse/INT-4141

MessageSource incorrectly returned the exception instead of throwing it.
2016-10-18 15:58:42 -04:00
Gary Russell
5d04e31e42 4.0.0 amqp-client compatibility (test channel) 2016-10-18 15:58:23 -04:00
Gary Russell
5a44216201 INT-4140: File Streaming Adapter: Add maxFetchSize
JIRA: https://jira.spring.io/browse/INT-4140
2016-10-18 10:32:23 -04:00
Gary Russell
3c284871c3 INT-4139: Add CORS Config to Graph Annotation
JIRA: https://jira.spring.io/browse/INT-4139

Doc Polishing

Polishing - Fix CORS Test and Revert XML

- Use standard CORS configuration with XML.
2016-10-17 14:49:30 -04:00
Gary Russell
8d70463c7a Update spring-retry to 1.2.0.RC1 2016-10-14 10:44:45 -04:00
Artem Bilan
a1f554c04d INT-2460: Remove Message Modification Logic in MS
JIRA: https://jira.spring.io/browse/INT-2460,
https://jira.spring.io/browse/INT-4122

Since the main purpose of the `MessageStore` to persist message for durability and only,
it doesn't make sense to modify `Message` for additional headers like `SAVED` and `CREATED_DATE`.
Such a logic should be a part of metadata stored together with the message.
And it is provided by the out-of-the-box `MessageStore` implementation.
In addition we free ourselves from the reflection operations to retain `ID` and `TIMESTAMP` headers when we add `SAVED` and `CREATED_DATE`

* Control "already saved" logic in the `JdbcMessageStore`s via `DuplicateKeyException` on the `INSERT`.
This is much effective then additional `SELECT` in case of `SAVED` before
* Control "already saved" logic in the  `AbstractConfigurableMongoDbMessageStore` via `DuplicateKeyException` on the `INSERT`.
Since `MongoDbMessageStore` doesn't provide extra `messageId` field, perform extra `SELECT` before store document.
Anyway the `MongoDbMessageStore` isn't recommended for use.
We may consider to deprecate it
* Control "already saved" logic  in the `AbstractKeyValueMessageStore` via `putIfAbsent` operation

With this fix we persist message in the store as is without any modifications when we perform standard serialization procedure.
Any custom serializers should consider to use `MutableMessageBuilder` if there is a requirement to retain `ID` and `TIMESTAMP`

Rework `MongoDbMetadataStore.putIfAbsent()` to normal `findAndModify()` with particular `$setOnInsert`.
Technically the MongoDB query looks like:
```
db.collection.findAndModify({
  query: { _id: $key },
  update: {
    $setOnInsert: { value: $value } // perform modification only on upsert
  },
  new: false,   // don't return new doc if one is upserted
  upsert: true // insert the document if it does not exist
})
```

Move single import to the appropriate JavaDoc

Polishing after rebase
DEBUG messages in `doStoreIfAbsent()` implementations

* To keep track of the extra message information in the `MessageStore`, without `Message` modification, introduce `MessageMetadata` and `MessageHolder`
* Add `MessageStore#getMessageMetadata()`
* Modify MongoDb `MessageStore` to add extra `timestamp` for individual message
* Fix `ConcurrentAggregatorTests` race condition.
Since currently the default release strategy is `SimpleSequenceSizeReleaseStrategy` which is just based on the `MessageGroup` size, there is no guaranty which messages will complete the group in concurrent environment.
The test is really based on the `SequenceAwareMessageGroup` logic to discard the message with the same `correlationId`

Fix `@Copyright` format

Move cast to `MessageHolder` after `Assert.isInstanceOf(MessageHolder.class, messageHolder)`

Retain backward compatibility in the `AbstractKeyValueMessageStore`

Polishing
2016-10-13 13:19:37 -04:00
Gary Russell
7c12288d2e GH-1928: Roles: Doc Polishing
Fixes #1928 https://github.com/spring-projects/spring-integration/issues/1928
2016-10-12 11:58:33 -04:00
Gary Russell
890ad63584 INT-4137: Improve Aggregator Performance
JIRA: https://jira.spring.io/browse/INT-4137

Aggregators with `SequenceSizeReleaseStrategy` do not perform well with large groups
because of an O(n) linear search to reject (discard) duplicate sequences.

Change the aggregator to use a `SimpleSequenceSizeReleaseStrategy` by default, unless
`setReleasePartialSequences(true)`.

This avoids the linear search, which is not needed for most splitter -> ... -> aggregator
flows.

Log a warning if SSRS is used.

Polishing - PR Comments

* Remove `this.logger.isWarnEnabled()` since it is redundant when our log message is just string constant
2016-10-11 17:14:55 -04:00
Artem Bilan
8d94bd5e3e INT-3825: Messaging Ann. on Non-public Methods
JIRA: https://jira.spring.io/browse/INT-3825

Rework `MessagingMethodInvokerHelper` logic to accept non-public methods with Messaging annotations as candidates for invocation
Adjust SpEL configuration in the `MessagingMethodInvokerHelper` to deal with `declaredMethods()`, not only `public`

Honor caching in the `MethodReference`
2016-10-11 14:21:40 -04:00
Artem Bilan
8f0fa3468f INT-832: Add File Relative Path to Message Headers
JIRA: https://jira.spring.io/browse/INT-832

When we scan directory recursively for files (e.g. `WatchServiceDirectoryScanner`), it can be useful to get access to the relative path from the `Message`, e.g. on the `FileWritingMessageHandler` side to restore the original structure

* Add a `FileHeaders.FILENAME` into the outbound `Message` from the `FileReadingMessageSource`
* The result of that header is like a removal of leading `this.directory.getAbsolutePath()` in the target `File.getAbsolutePath()`.
In case of not recursion we get just only regular file name.

* Introduce `FileHeaders.RELATIVE_PATH`
* Populated `FileHeaders.RELATIVE_PATH`, `FileHeaders.FILENAME`, `FileHeaders.ORIGINAL_FILE` in the `FileReadingMessageSource`
* File `FileTailingMessageProducerSupport` to populate `FileHeaders` properly
* Introduce ctor for the `LastModifiedFileListFilter` for better Java configuration experience
* Add docs for changes

Doc Polishing
2016-10-11 13:04:21 -04:00
Artem Bilan
7d9c65a108 INT-4119: PROPERTY access for MessageDocument
JIRA: https://jira.spring.io/browse/INT-4119

* Mark `MessageDocument` with the `@AccessType(AccessType.Type.PROPERTY)` for better performance via bean accessors
* Add more getters for `MessageDocument` properties
* Leave `MessageWrapper` as is since it has a complex internal logic which may be broker via accessors
2016-10-11 11:54:42 -04:00
Gary Russell
2edf766e49 INT-4136: Support DirectMessageListenerContainer
JIRA: https://jira.spring.io/browse/INT-4136

Fix a couple typos
2016-10-11 10:46:30 -04:00
Artem Bilan
53d80b5694 INT-3903: user prefix as "" for HTTP headers
JIRA: https://jira.spring.io/browse/INT-3903

According to RFC-6648, the "X-" prefix has been deprecated and now any use-specific headers can be mapped without any prefix

* Fix `DefaultHttpHeaderMapper` for the `""` as a `userDefinedHeaderPrefix` by default

Document `X-` changes
2016-10-10 16:58:12 -04:00
Artem Bilan
f9e93e0a72 INT-4135: Ignore case check for HTTP Content-Type
JIRA: https://jira.spring.io/browse/INT-4135

The incoming `Content-Type` HTTP header can be in any arbitrary case.

Fix `DefaultHttpHeaderMapper` `Content-Type` header re-mapping to the `MessageHeaders.CONTENT_TYPE` via `equalsIgnoreCase()` comparison

**Cherry-pick to 4.3.x**
2016-10-10 11:30:15 -04:00
Piotr Zygielo
b6aed111f4 Update bean id to reflect direction
Obvious Fix
2016-10-08 16:51:29 -04:00
Gary Russell
9673a02c7d INT-4131: Add delayExpression to AMQP Outbounds
JIRA: https://jira.spring.io/browse/INT-4131

Specify an expression on the outbound endpoints to set the `x-delay` header when
using the RabbitMQ Delayed Message Exchange plugin.

Polishing

- PR Comments
- Add `setDelay`
- Port `FunctionExpression` from DSL
- Add `SupplierExpression`

Javadoc Fixes

Use ValueExpression for delay

* Simple polishing for `SupplierExpression`
* Mention plain `delay` property in the `amqp.adoc`
2016-10-07 11:42:01 -04:00
Artem Bilan
c31a96d4cb INT-4132: Start MS Before Scheduling Polling Task
JIRA: https://jira.spring.io/browse/INT-4132

The race condition is present when polling task may be ran before `MessageSource<?>` has been started.

* Swap the order of `start()` in the `SourcePollingChannelAdapter`.
Since proxying is now applied only for the `MessageSource.receive()` it doesn't hurt to start it before actual proxying.
Just because it is really should be started before performing its `receive()`
* Prove the proper order with the mock test and protect ourselves for the future similar changes
* Also swap the `stop()` order in the `SourcePollingChannelAdapter.
We have to stop/cancel the polling task before discarding internal `MessageSource` lifecycle.
 For example with the current state we may close an underlying resource already, but still have the last polling tick.
 That may cause any unexpected behaviour

 **Cherry-pick to 4.3.x**

Polishing
2016-10-06 17:43:34 -04:00
Gary Russell
9e3156ae7d INT-4129: Add Discard Channel to Barrier Handler
JIRA: https://jira.spring.io/browse/INT-4129

Discard late arriving triggers.

* Minor code style polishing
2016-10-06 11:47:22 -04:00
Gary Russell
f9ddefec2c INT-4118: Detect EOF on stdin
JIRA: https://jira.spring.io/browse/INT-4118

Add an option to the `CharacterStreamReadingMessageSource` to detect EOF
on the stream and close the context.

Publish event instead of closing context.

Polishing - PR Comments

Polishing

Docs about stopping the poller.

* Fix typos in the docs
2016-10-05 19:31:29 -04:00
Artem Bilan
a7171c4db9 INT-4127: Fix ZkLock.tryLock() timing issue
JIRA: https://jira.spring.io/browse/INT-4127
Fixes GH-1913 (https://github.com/spring-projects/spring-integration/issues/1913)

The current `tryLock()` implementation with the `0` timeout to wait for underlying `InterProcessMutex` answer makes this function almost fully impossible

* Fix `ZkLock.tryLock()` to delegate with the `tryLock(1, TimeUnit.SECONDS)` to give some time window chance for network communication.
It isn't ideal for the `tryLock()` contract, but at least it is better then don't let the feature to work at all.

**Cherry-pick to 4.3.x & 4.2.x**
2016-09-30 10:01:26 -04:00
Artem Bilan
86a079c1cc Fix for previous commit with unfinished change 2016-09-29 22:10:13 -04:00
Artem Bilan
9bc2b6f62b Fix DefaultAmqpHeaderMapper for latest SA
The `correlationId` is `String` now, not `byte[]`
2016-09-29 21:36:11 -04:00
Gary Russell
fc3088d77d INT-4128: FTP ControlEncoding Fix
JIRA: https://jira.spring.io/browse/INT-4128
2016-09-29 10:00:25 -04:00
Gary Russell
56b9b2401e HTTP Inbound Javadoc Improvements
http://stackoverflow.com/questions/39741251/spring-integration-immediate-response-to-be-sent-with-asynchronous-processing/39750349#39750349
2016-09-28 12:26:35 -04:00
Artem Bilan
8aa9befef6 INT-4126: Fix Redis lock to use SET NX EX
JIRA: https://jira.spring.io/browse/INT-4126

Looks like `WATCH` doesn't provide good isolation when the call is performed concurrently at the same time from different Threads.

* Change locking algorithm as it is recommended by Redis `SET` command: http://redis.io/commands/set:
```
SET resource-name anystring NX EX max-lock-time
```

* Add `@Repeat(10)` to the `AggregatorWithRedisLocksTests#testDistributedAggregator()` since that helped to reproduce the issue

**Cherry-pick to 4.3.x & 4.2.x**
2016-09-27 21:47:38 -04:00
Artem Bilan
129984ec0a INT-4113: Add @Poller.errorChannel() Attribute
JIRA: https://jira.spring.io/browse/INT-4113

* To simplify `MessagePublishingErrorHandler` and avoid extra `PollerMetadata` beans, added the `errorChannel()` attribute to the `@Poller` annotation
* The `MessagePublishingErrorHandler` now supports the late-binding via new `defaultErrorChannelName`
* Docs about new `errorChannel()` attribute
* Some other docs polishing

Polishing

**Cherry-pick to 4.3.x**

Polishing docs according PR comments
2016-09-27 17:57:37 -04:00
Gary Russell
93989a0c9b INT-4124: ByteBuffer.array() with Direct Buffers
JIRA: https://jira.spring.io/browse/INT-4124

`ByteBuffer.array()` returns null when Direct.

Change `ChannelInputStream` to use the `ByteBuffer` directly instead of
the underlying `byte[]`.
2016-09-26 22:25:38 -04:00
Gary Russell
e5ae7d886d (S)FTP Lambdas
AMQP Lambdas

Event Lambdas

Feed/File Lambdas

Gemfile/Groovy Lambdas

* Ensure that JavaDocs are checked via `	check.dependsOn javadoc`
* Add `@return` tag to the `MessageBuilder.readOnlyHeaders()`
2016-09-26 16:50:01 -04:00
Gary Russell
3402a86fb5 INT-4120: Poller Advice Chain Regression
JIRA: https://jira.spring.io/browse/INT-4120

INT-3899 moved creating the pollingTask to start() to allow modification
of the advice chain between starts.

Since a new pollingTask is created on each start, this was fine for general advices.

However, for `AbstractMessageSourceAdvice`s, which only advise the `receive()` operation,
the advices are re-applied on every start.

When starting, first remove any advices we added on the previous start.

This handles the case when the source is a naked object, or already a proxy when supplied
to the SPCA.

Remove uneeded cast

Polishing - PR Comments

Honor some Java 8 code practice
2016-09-26 11:53:07 -04:00
Artem Bilan
1f728cc515 Fix the build and gitter badges
* Move the Gitter badge to the line with the Build badge
* Make Build badge as a link to the build
* Fix Build badge to pointing to the correct build
2016-09-23 10:18:30 -04:00
The Gitter Badger
6c01ce1926 Add Gitter badge 2016-09-23 13:45:27 +00:00
Artem Bilan
12fb590b95 Mainly Checkstyle Violation Fixes
* Upgrade to Checkstyle `7.1`
* Relax `RequireThis` rule a bit. Right now it does the effort only in case of overlapping. See https://github.com/checkstyle/checkstyle/issues/2362 for more info
* Enable some annotation rules and provide fixes for violations
* Enable `tabs indents` rule. This was the biggest fix in this PR
* Resolve `TODO` in the `MessagingMethodInvokerHelper` and fix tests to meet `IllegalStateException` now

Remain Checkstyle version `6.16.1` and reinstate `RequireThis` rule

The latest Checkstyle has a bug with local scope variables if they have the same names as property.

Revert some literals splitting

Fix some line length exceeding and code style
2016-09-22 13:23:51 -04:00
Artem Bilan
22b7187784 Some polishing according Sonar violations 2016-09-19 16:52:26 -04:00
Artem Bilan
c0f1c9ece8 INT-4106: Add JPA Java-based configuration docs
JIRA: https://jira.spring.io/browse/INT-4106

Also fix some typos in the `jpa.adoc` and remove mentioning of OpenJPA, since it doesn't support JPA 2.1
2016-09-16 12:25:36 -04:00
Artem Bilan
dbcebebf38 INT-4096: Allow Configuration of ReadOnly Headers
JIRA: https://jira.spring.io/browse/INT-4096

* Introduce `spring.integration.readOnly.headers` Integration property
* Introduce `IntegrationMessageHeaderAccessor.setReadOnlyHeaders()` and use it from the overridden `IntegrationMessageHeaderAccessor.isReadOnly()`
* Add `DefaultMessageBuilderFactory.setReadOnlyHeaders()` and delegate the value to the new `MessageBuilder.readOnlyHeaders()`
* Modify `spring.integration.properties` for the `contentType` as a `readOnly` header for testing
* Ensure that provided logic works via an appropriate modification to the `ObjectToJsonTransformerParserTests`

Increase receive timeouts in the `OutboundGatewayFunctionTests`

Fix `FileInboundTransactionTests` for slow `WatchService` issue on Linux/OS X

Also redo the `tmp` dir logic to the `TemporaryFolder` `@ClassRule`

Fix unused `import` in the `FileInboundTransactionTests`

Polishing

Conflicts:
	spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationProperties.java
	spring-integration-core/src/main/resources/META-INF/spring.integration.default.properties

Some polishing and documentation

Localize `readOnly.headers` customization only in the `ObjectToJsonTransformerParserTests-context.xml`

Otherwise ti might affect many other tests and the search for the reason of failure would be enough complicated

Doc Polish
2016-09-15 15:32:20 -04:00
Artem Bilan
450ac7f18d INT-4105: RedisLock: Unlock Local in obtain()
JIRA: https://jira.spring.io/browse/INT-4105
Fixes GH-1888

The lock in Redis can be expired in between `obtain()` calls.
So, even if we return a new lock instance, the old one must clear properly.

* Add `lock.unlock()` to the `obtain()` if the case of expiration in Redis.
* Add `warn` for the exception on the `lock.unlock()`. We don't care about error here and just proceed to a new instance.

**Chery-pick to 4.3.x**

Remove the lock reference from `weakThreadLocks` as well
Add `registry.setUseWeakReferences(true);` to test-case

* Add assert for `lock.unlock()` in case of expiration

* Add `UUID.randomUUID()` for the registry key to avoid cross-talking during concurrent builds, e.g. on the CI server
https://build.spring.io/browse/INT-MASTER-352

This is actually a fix for the

JIRA: https://jira.spring.io/browse/INT-4083
2016-09-15 12:44:54 -04:00
Frank Sigalas
763547562c INT-4110: TestMailServer.ImapServer improve reply to FETCH ENVELOPE
JIRA: https://jira.spring.io/browse/INT-4110
2016-09-15 13:17:42 +03:00