Commit Graph

413 Commits

Author SHA1 Message Date
Marcin Pilaczynski
8bf8caa22e INT-3883: UDP: destination and socket expressions
JIRA: https://jira.spring.io/browse/INT-3883

UDP Outbound Channel Adapter is able to use given UDP Inbound Adapters
server socket (outgoing packets will have source port same as incoming
packets destination port).

* Introduce `destinationExpression` instead of hard-coded `host/port` logic in the `DatagramPacketMessageMapper`
* Make `UnicastSendingMessageHandler.destinationExpression` mutually exclusive with `host/port` pair
* Move `socketExpression` to the setter as it is absolutely different option from the `destination`
* Make `UnicastSendingMessageHandler` expressions logic based on the `requestMessage`

INT-3883 Code review fixes.

Further polishing

Polishing according PR comments

Rework the String socket address logic just to the expected `URI` style.
Accept `2016` for changed classes.
2016-01-04 14:31:40 -05:00
Artem Bilan
287173bc67 Fix TCP tests to use 0 port
https://build.spring.io/browse/INT-MJATS41-495
https://build.spring.io/browse/INT-AT42SIO-16

Can be backported to `4.2.x` on demand
2015-12-28 18:22:07 -05:00
Gary Russell
ed874ea84a TCP ConnectionFactoryTests Race Condition
Wait for events.
2015-12-21 11:38:55 -05:00
Gary Russell
0458220756 TCP ConnectionFactoryTests Diagnostics
https://build.spring.io/browse/INT-SONAR-1582/
2015-12-20 16:07:01 -05:00
Gary Russell
180ada63b0 INT-3912: TCP Server Listening Event
JIRA: https://jira.spring.io/browse/INT-3912

Polishing - PR Comments
2015-12-15 10:15:13 -05:00
Artem Bilan
471d08250d Add MulticastRule to Check the NIC for Tests
Add `skip` variable

Polishing

Tests failed after installing VirtualBox.

Further polishing to skip `vboxnet` NICs.

Also explicitly set the multicast socket `interface` (instead of `networkInterface`)
to address a specic IPAddress if a NIC has multiple bindings.

Add `@MulticastRule` to `DatagramPacketMulticastSendingHandlerTests` (separate into
new test file).

Fix tests to use the rule's NIC.
2015-12-14 18:17:27 -05:00
Artem Bilan
cf528c0b5d INT-3665: Remove Deprecations and Resolve Issues
https://jira.spring.io/browse/INT-3665

Fixes according Travis report

Introduce `...ExpressionString(String)` setter

Some further fixes and polishing

Address PR comments
2015-12-08 16:48:29 -05:00
Gary Russell
d16cd9748c INT-799: Remove Core Deps from s-i-test
JIRA: https://jira.spring.io/browse/INT-799

Some test classes (e.g. `TestUtils`) were duplicated in core to avoid cyclic
dependency.

Now that core messaging has been moved to spring-messaging, it is possible
to remove the dependencies on `spring-integration-core` from `spring-integration-test`.

A few minor test cases have been moved to `spring-integration-core`.

The simple polishing to the `build.gradle` and `ServiceActivatorOnMockitoMockTests`
2015-12-07 20:39:00 -05:00
Gary Russell
255247ca9a Code Polishing (Sonar)
- remove redundant modifiers
- overridable methods called from ctors

Polishing - PR Comments
2015-12-07 15:39:13 -05:00
Gary Russell
c0ca5a9b89 INT-3894: Polishing
Remove IPv4 from build.gradle.
Fix race for ackPort.
2015-11-24 11:35:43 -05:00
Gary Russell
b4218982da INT-3984: UDP: OS Selected Server Port
JIRA: https://jira.spring.io/browse/INT-3894

Allow UDP server port (and sender Ack port) to be selected by the operating system.

Also fix multicast tests to run on all platforms.

Change tests to use OS selected port.
2015-11-23 17:16:23 -05:00
Artem Bilan
b621417380 INT-3893: UnicastReceivingChannelAdapter: fix NPE
JIRA: https://jira.spring.io/browse/INT-3893

Polishing

Send on the calling thread if the executor is shut down.
2015-11-20 10:52:07 -05:00
Gary Russell
051b393ed0 Prepare Master for 4.3
Reference to 4.3

Refactor `what's new` for 4.3
2015-11-17 12:12:49 -05:00
Artem Bilan
9d8e2b61f6 Fixes for Sporadic Test Failures
* `ClientWebSocketContainer`: add some synchronization to avoid race conditions: https://build.spring.io/browse/INT-B41-492
* `TomcatWebSocketTestServer`: convert to `0` port to rely on the OS resolution for `localPort`
* Add `LogAdjustingTestSupport` for STOMP test
* `SftpServerTests`: use `0` port to rely on the OS resolution for `localPort`
* `ImapMailReceiver`, `OutboundGatewayFunctionTests` (JMS), `CachingClientConnectionFactoryTests`,
`AsyncGatewayTests`, `AsyncMessagingTemplateTests`, `GatewayParserTests`, `PriorityChannelTests`, `AggregatorIntegrationTests`: increase timeout
* `EnableIntegrationTests`: use `LogAdjustingTestSupport`
* `FileOutboundChannelAdapterParserTests`: rework `Thread.sleep()` with `CountDownLatch`
* `ConnectionToConnectionTests`: increase timeout and count iteration. Previously with `1sec` we may lose some events. And we can't just rely on the `10sec`,
because the last iteration will be so long
* `TcpOutboundGatewayTests`: `500ms` is so big timeout to wait for the `Exception` that in the high load environment we can yield to other Thread so long.
Like in our case to `server` Thread to send the reply for us. Therefore decrease the Exception timeout to the `50ms` and increase server delay to `2sec`
* `StompInboundChannelAdapterWebSocketIntegrationTests`: remove `@Qualifier("taskScheduler")` as a potential candidate to test against latest SF changes.
We're fine with `SF-4.2.2` and it is just a test-case. So, I don't see reason to wait for their fix here.

STOMP: `session = null` in adapters for any transportError

Polishing
2015-11-14 16:12:23 -05:00
Gary Russell
e5269bb265 INT-3886: TCP Fix Socket Timeout: Raw Deserializer
JIRA: https://jira.spring.io/browse/INT-3886

An SO user reported a short message delivery when an NIO connection was timed out.

See JIRA for link.

We could not produce the problem with his deserializer but it did identify a problem
with the standard `ByteArrayRawSerializer`.

With NIO, socket timeouts were reported to the deserializer as a normal EOF (-1). This
caused the raw serializer to emit a short message - it's signal for end of message is the
socket closure.

We can't treat a timeout as a normal EOF.

If the socket is forcibly timed out due to no recent data, throw a `SocketTimeoutException` to
the deserializer.

Just in case the old behavior is being relied upon, a boolean has been added to restore that
behavior. This is not recommended, as using timeout to delimit messages is not reliable.

* Fix typos
* Increase `MongoDbInboundChannelAdapterIntegrationTests` timeouts
* Some code polishing
2015-11-12 21:35:03 -05:00
Gary Russell
1849cda1c1 Extract LogAdjustingTestSupport
Also add test debugging to JmsOutboundGatewayTests.
2015-11-07 11:06:19 -05:00
Artem Bilan
bfebb78429 Adjust some sporadic tests
https://build.spring.io/browse/INT-B41-JOB1-470
https://build.spring.io/browse/INT-B41-JOB1-471
2015-11-04 17:28:20 -05:00
Gary Russell
fb766a951c TCP: Tests: Let OS Choose Test Port
https://build.spring.io/browse/INT-MJATS41-434

BindException.

Avoid using `findAvailableServerSocket()` where easily possible.

Some still remain, but they would require major rework of the tests.

Also fix a race in `TcpOutboundGatewayTests.testGoodNetGWTimeoutGuts()`. Although an
`AtomicBoolean` was used, both threads might still see the lower (500ms) timeout.

Polishing
2015-10-29 19:24:16 -04:00
Artem Bilan
095aeea703 @Ignore a couple nasty tests 2015-10-26 18:02:51 -04:00
Artem Bilan
4c331a26f0 SocketSupportTests: change server port to 0
Rely on the OS server port resolution and use the real port for the `client` from the `server`
2015-10-26 17:18:33 -04:00
Artem Bilan
1012e588e4 Increase remoteTimeout for TcpOutbound test
Looks like `5000` isn't enough to wait for reply from server in high-loaded environment:
https://build.spring.io/browse/INT-B41-JOB1-456
2015-10-22 18:30:12 -04:00
Artem Bilan
d0af90db62 Another fix for failing tests
* `JmsOutboundGatewayTests`: just increase timeouts. Looks like embedded ActiveMQ Broker takes more time to interact on high-loaded builds
* `TcpOutboundGatewayTests`: Rework the race condition fix to the atomic `remoteTimeout`  change using mocks
2015-10-21 19:04:01 -04:00
Artem Bilan
aa3e3c7098 Fix some failing tests
* Modify `ControlBusTests.testControlHeaderChannelReaper()` do not rely on the `timeout`.
Make artificial expiration for the entry in the `registry` to allow `reaper` to remove it according the test logic.
* Fix race condition around `gateway.setRemoteTimeout(5000);` in the `TcpOutboundGatewayTests`.
 The problem was that the gateway is called concurrently and `setRemoteTimeout` might be changed before the `handleMessage()` even for the first attempt.
2015-10-21 17:15:23 -04:00
Gary Russell
3118596427 INT-3860: TCP - Fix Port Conflicts
JIRA: https://jira.spring.io/browse/INT-3860

Similar to INT-3794, if some other process is bound to all adapters

    $ lsof -i tcp -nP | grep 9000
    java       6604 grussell  380u  IPv6 0x407e749ec47fa337      0t0  TCP *:9000 (LISTEN)

The socket utils reports that the localhost is available for binding; however, the test then
binds to all adapters.

1. Where (easily) possible, change tests to use port=0 and let the OS choose.
2. For other tests, use high-numbered ports.
3. Change tests to explicitly bind to localhost (like the utility did).
4. Fix `tcpOutboundGatewayInsideChain` test to use the correct port.

Polishing - Fix Travis

Bind SOLingerTests to localhost.

Since we're using port 0, we have to wait until listening before calling getPort().
2015-10-20 18:17:05 -04:00
Gary Russell
4ab2c158b3 INT-3837: TCP GW - Propagate Socket Timeout
JIRA: https://jira.spring.io/browse/INT-3837

INT-3103 introduced exception propagation to waiting gateway threads.

However, `SocketTimeoutException`s were not propagated (in all cases
since 4.2 and for single-use sockets since 3.0).
2015-09-28 10:11:23 -04:00
Artem Bilan
cb318f59ee INT-3821: Description for MessagingException ctor
JIRA: https://jira.spring.io/browse/INT-3821

The `MessagingException` provides an empty String for its `NestedRuntimeException`
for those ctors which are without `description` argument.

The `NestedRuntimeException` uses `NestedExceptionUtils.buildMessage` for `getMessage()` implementation
and the algorithm there is based on the `message != null` condition to build the first part of the nested
cascade. In the case of empty String we end up with useless ";" part in the StackTrace logs.

Fix Framework classes to use the `MessagingException` ctor with particular description.
2015-09-08 22:55:52 -04:00
Gary Russell
1043ffabcb TCP: Fix Event Tests Race Condition - take 2 2015-08-14 13:20:28 -04:00
Gary Russell
d5dcb419c3 TCP: Fix Event Tests Race Condition 2015-08-14 13:05:50 -04:00
Gary Russell
3133782cc5 INT-3801: TCP Server Fix NPE with Early Stop
JIRA: https://jira.spring.io/browse/INT-3801

NPE if the server is stopped before it fully started.

Also fix SOLinger tests.

Fix `ConnectionFactoryTests` for Java < 8 compatibility
2015-08-13 20:08:12 -04:00
Gary Russell
bcfc4d88c1 INT-3800: Expose Actual Port Chosen When Random
JIRA: https://jira.spring.io/browse/INT-3800

If the server port is 0, return the actual port after the factory is started.

Also add more TCP Test Diagnostics.
2015-08-13 11:28:37 -04:00
Gary Russell
4ab25121af INT-3799: Fix Tangles
Part 1 - eliminate references from support to other packages

Part 2 - handler to aggregator/router
- move BarrierMH to aggregator
- Fix ScatterGather references

Part 3 - move TrackableComponent
- to support.management

Part 4 - class tangles
- TcpConnectionServerExceptionEvent
- RecipientListRouterManagement

INT-3799: Polishing
2015-08-13 10:32:55 -04:00
Gary Russell
adb0f43aa8 INT-3779: CodecMessageConverter and Docs
JIRA: https://jira.spring.io/browse/INT-3779

Fix timeouts for the `EnableIntegrationTests`: https://build.spring.io/browse/INT-B41-385
2015-08-11 18:21:35 -04:00
Gary Russell
e2a10a8d79 TCP: Add Diagnostics 2015-08-11 15:56:23 -04:00
Gary Russell
a70bc06a18 Fix FailoverClientConnectionFactoryTests
Race condition in `ServerSocket`; the `accept` thread is exiting due to the
close, but it still accepted a new message.

All tests need to wait until the server has stopped listening (as well as
waiting for the close to be propagated to the client).
2015-08-11 10:49:26 -04:00
Gary Russell
0ce5f12342 INT-3795: TCP: Combo Failover and Cached CFs
JIRA: https://jira.spring.io/browse/INT-3795

Previously, a `CachingClientConnectionFactory` could wrap `FailoverClientConnectionFactory` instances.

It was not possible to wrap `CachingClientConnectionFactory` instances in a `FailoverClientConnectionFactory`.

The failover logic only failed over when an `IOException` occurred, whereas the CCCF wrapped the IOException
in a `MessagingException`.

- Catch all exceptions in the failover logic
- Add real TCP test cases for both scenarios
 - test failover when a connection is closed
 - test failover when the first factory cannot connect at all

INT-3795: Polishing - Fix Test Race

Revert `.travis.yml` changes
2015-08-05 20:33:05 -04:00
Artem Bilan
ec12b289c2 INT-3786: Fix Several Sporadic Test Failures
JIRA: https://jira.spring.io/browse/INT-3786

* Increase `receiveTimeout` for several `QueueChannel` and `CountDownLatch` based tests
* Fix `FileSplitterTests` for Windows compatibility - `UTF-8` for bytes conversion
* Make some STOMP tests as `LongRunning`

The next fixing phase
2015-07-30 15:28:02 -04:00
Gary Russell
448f9a52d2 Debugging for TCP FailOver Tests
Add LogLevelAdjuster; enable TRACE debugging for this test class.
2015-07-30 12:44:41 -04:00
Gary Russell
774e5868f0 INT-3567: JMS Shared Subscriptions
JIRA: https://jira.spring.io/browse/INT-3567

Namespace support for JMS 2.0 shared subscriptions.

INT-3567: AsciiDoc

* `What's New` polishing
* `TcpConnectionEventInboundChannelAdapterParser` deprecation warn fix
2015-07-16 13:41:30 -04:00
Gary Russell
f1fc0edbf3 INT-3425: Deprecate TCP Event Channel Adapter
JIRA: https://jira.spring.io/browse/INT-3425

Deprecate `TcpConnectionEventListeningMessageProducer` in favor
of using a generic event inbound channel adapter.

Polishing
2015-07-15 10:15:42 -04:00
Artem Bilan
9c96a14cd1 INT-3749: Revert setters for EC
JIRA: https://jira.spring.io/browse/INT-3749

Since some target application could inject there is `EvaluationContext` before, removal of
 `setIntegrationEvaluationContext()` is breaking change.

 This fix reverts all those setters.
2015-06-27 12:36:33 -04:00
Artem Bilan
3392d4e1ab INT-3749: Get rid of IECA logic
JIRA: https://jira.spring.io/browse/INT-3749

Since `IntegrationEvaluationContextAware` isn't so "context-free" resource like `BeanFactory`
 and `ApplicationContext`, but just a specific bean in the context, we can't follow with `BeanPostProcessor` logic - bad architecture by level of responsibility.
 Therefore we should follow with standard Dependency Injection mechanism to retrieve `evaluationContext` for the particular component.

 Since we can't rely on the `@Autowired` because SI can be used from the raw XML configuration,
 we use utility method instead. The pattern to get the proper `integrationEvaluationContext` is:
 ```
 @Override
 protected void onInit() throws Exception {
 		super.onInit();
 		this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
 }
 ```
2015-06-24 14:57:00 -04:00
Gary Russell
ec5230abc7 INT-3654: Rework TCP Connection Close
JIRA: https://jira.spring.io/browse/INT-3654

Previously, single-use `TcpConnections` self-closed when their use was complete.
This is unnatural and caused issues such as INT-3722.

Remove the self-closing behavior; connection close is now (properly) the responsibility
of the client using the connection:

- Client Side:
-- `TcpOutboundGateway` after the reply is received
-- `TcpSendingMessageHandler` after the send, when there is no collaborating inbound adapter
-- `TcpReceivingChannelAdapter` when it is collaborating (after receiving the reply)

- Server Side:
-- `TcpInboundGateway` after the reply is sent
-- `TcpReceivingChannelAdapter` after the receive, when there is no collaborating outbound adapter
-- `TcpSendingMessageHandler` when it is colllaborating (after sending the reply)

As before, the `CachingClientConnectionFactory` always sets single use on the target factory
to force it to create new connections on demand. It is always a single-use factory itself
so the clients return the connections to the pool (via `close()`).

__Needs a migration guide entry__

INT-3654: Fix Late Listener Registration

Timing failures in `TcpOutboundGatewayTests.testFailoverCached()` (null listener).

The `FailoverClientConnectionFactory` registers its listener with the actual
connections it retrieves from a delegate.

When nesting failover and cached connection factories, we need to propagate the
`enableManualListenerRegistration` to the delegate factories so the connection
will wait for its listener to be registered.
2015-06-23 15:35:10 -04:00
Gary Russell
f4104c199a INT-3745: More TCP Events (Failed Correlation)
JIRA: https://jira.spring.io/browse/INT-3745

Emit events whenever a message is received that can't be correlated to
a connection (or request in the case of an outbound gateway).

Also, when sending messages, wrap the exception in a `MessagingException` so that
the `TcpConnectionExceptionEvent` provides access to the failed message.

INT-3745: Polishing - PR Comments

Fix JavaDocs errors
2015-06-19 13:49:10 -04:00
Gary Russell
7ed79c864d INT-3730: TCP Expose SSLSession for Header Mapping
JIRA: https://jira.spring.io/browse/INT-3730

Expose the `SSLSession` on `TcpConnection` to support custom header
mapping of properties from the session.
2015-06-08 12:15:51 -04:00
Gary Russell
9e1119b434 INT-3728: TCP: Fix Early Receive with Caching CCF
JIRA: https://jira.spring.io/browse/INT-3728

The `CachingClientConnectionFactory` uses a temporary (rejecting) listener until
the connection is established and then replaces the listener in the connection.

There is a race condition in that if the server starts sending messages before the
listener is replaced, the message is rejected.

Add a mechanism to delay `onMessage` calls until the real listener has been
registered.

Also fix `onMessage` in the cached connection so an `ErrorMessage` is propagated correctly.

To reproduce: revert src/main; add `Thread.sleep(1000)` before `registerListener(tcpListener);`
in `CachedConnection` ctor and run the new test.

To introduce a similar timing hole with the new code, add the sleep before
`this.theConnection.registerListener(this);` in `TcpConnectionInterceptorSupport`.

Summary of changes:

`CachingClientConnectionFactory`
- register the underlying connection's listener in the ctor, utilizing the
    `TcpConnectionInterceptorSupport.registerListener()` method.
- fix `ErrorMessage` propagation.

`AbstractClientConnectionFactory`
- propagate the `enableManualListenerRegistration` to connections.

`TcpConnectionSuport`
- implement delay when manual listener registration is enabled.

Add test case.

Fix Failover Tests

`FailoverClientConnectionFactory`
- propagate enable manual listener registration to underlying factories

Polishing
2015-06-05 21:05:36 -04:00
Gary Russell
3339313ba7 INT-3722: Additional Fix: TCP OG with Caching CF
JIRA: https://jira.spring.io/browse/INT-3722

While the initial fix solved the reported problem, it caused a memory leak when
the gateway completed its work before the reader thread "closed" the connection,
releasing it to the pool. This left the connection in the deferred close state.

Handle the condition where the gateway signals it has completed its work
before the connection is released to the pool.
2015-05-27 12:30:05 -04:00
Gary Russell
d17785db12 Fix TCP Gateway Integration Test
Definitively wait for the connection to be returned instead of a simple sleep.
2015-05-27 10:19:38 -04:00
Gary Russell
22fb524515 INT-3722: Fix Timing Issue TCP OG and Cached CF
JIRA: https://jira.spring.io/browse/INT-3722

The TCP outbound gateway correlates replies based on the connection id.

When a `CachingClientConnectionFactory` is being used, the connection is
returned to the pool too early, and can be reused. It is possible that
the current thread then removes the "next" pending reply from the correlation map.

Add code to the `CachingClientConnectionFactory` so that the "self" close from the
connection (called after `onMessage`) is deferred and the actual close (return to cache)
is controlled by the gateway itself.

This mechanism will no longer be needed when INT-3654 is resolved (removal of the "self"
closing by connections). At that time, connection users (such as the gateway) will be
in complete control.
2015-05-26 17:46:14 -04:00
Artem Bilan
183941ec07 INT-3705: Improve Messaging Annotations handling
JIRA: https://jira.spring.io/browse/INT-3705

* Add validation for annotation attributes which must be populated directly on the `MessageHandler` `@Bean` using setters
* Add `sendTimeout()` annotation attribute for all Messaging Annotations
* Remove `DEFAULT_SEND_TIMEOUT = 1000L` from `AbstractCorrelatingMessageHandler` to make its component consistent with all other
`AbstractMessageProducingHandler` implementation.
* Fix XSD docs and Reference Manual to say that default `send-timeout` for `AbstractMessageProducingHandler` components is `-1`, not `one second`
* Make all Messaging Annotations attributes as `String` to allow to configure through the Property Placeholder options
* Fix a couple of typos

Polishing
2015-04-23 14:15:08 +01:00
Artem Bilan
2bde14b742 INT-3661: Fix the eager BF access from BPPs (P I)
JIRA: https://jira.spring.io/browse/INT-3661

Previously there were a lot of noise from the `PostProcessorRegistrationDelegate$BeanPostProcessorChecker` for early access for beans.
That may produce some side-effects when some of `BeanFactoryPostProcessor`s won't adjust those beans.

The issue is based on two facts:
1. Loading beans from `BPP`, e.g. `IntegrationEvaluationContextAwareBeanPostProcessor` (or `ChannelSecurityInterceptorBeanPostProcessor` - https://jira.spring.io/browse/INT-3663)
2. Loading beans from `setBeanFactory()/setApplicationContext()` container methods

* Move all code from `setBeanFactory()` with access to the `BeanFactory` (e.g. `this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(this.beanFactory);`)
to some other lazy-load methods like `getMessageBuilderFactory()`
* Fix parser tests to remove `messageBuilderFactory` tests since there is no activity for target components to lazy-load them
* Polish some test according the new lazy-load logic
* Rework `IntegrationEvaluationContextAwareBeanPostProcessor` to the `SmartInitializingSingleton` and make it `Ordered`
* Populate `beanFactory` for the internal instance of `connectionFactory` in the `TcpSyslogReceivingChannelAdapter`
* Populate `beanFactory` for the internal `UnicastReceivingChannelAdapter` in the `UdpSyslogReceivingChannelAdapter`
* Add `log.info` that `UdpSyslogReceivingChannelAdapter` overrides `outputChannel` for the provided `UnicastReceivingChannelAdapter`
* Change the internal `MessageChannel` in the `UdpSyslogReceivingChannelAdapter` to the `FixedSubscriberChannel` for better performance

* Fix `AbstractExpressionEvaluator`
* Add JavaDocs for the `IntegrationEvaluationContextAware`

Fix `MongoDbMessageStoreClaimCheckIntegrationTests`

Addressing PR comments
2015-03-02 18:23:44 -05:00