Commit Graph

172 Commits

Author SHA1 Message Date
Gary Russell
734eae72a7 INT-2839 Fix Test Race Condition
A secondary part of the new gateway test was to ensure we
reused the cached connection. However, there was a race condition
in that the connection may not yet have been returned to the pool
by the reader thread that received the response.
2012-11-29 21:30:52 -05:00
Gary Russell
32251bf6f2 INT-2839 Fix TCP Caching Connections with Gateways
Using the CachingClientConnectionFactory with a gateway
doesn't work. The Listener (gateway) was not being set up
properly by the wrapper. Instead, the actualListener in the
wrapped connection was set to null. This caused the connection
to "close" itself (return to the pool) immediately after the send.

In addition, even with the actualListener set up to properly
reference the gateway, it still wouldn't work because the
gateway can't correlate the reply (the cached connectionId is
prefixed with "cached:" so the gateway can't find the reply.

Further, when onMessage() returned, it caused the reader loop
to end.

Fixes:

1. Properly set up the cached connection with the real listener
so that ultimately the underlying connection sees there is an
actualListener and so doesn't close itself after the send.
2. Override getListener() on the cached connection to return the
real listener.
3. Override onMessage() in order to fix up the connection id in
the message, and return true (intercepted) so the connection doesn't
close itself (terminate the reader thread).
4. close() (return to the pool) after invoking the gateway's
onMessage().
5. Add test cases to verify proper operation including an assertion
that the pooled connection is reused.

This is made a little more complex by the tangle between
connections and connection interceptors; mainly because single-use
connections close themselves after use. This will be addressed in
3.0 (INT-2829) making connection interceptors simpler.
2012-11-29 15:17:24 -05:00
Gary Russell
c4a4b59848 INT-2828 Remove Package Tangle
* Remove Class Tangle in JPA
* tcp.connection
* tcp.connection.support
* Add Comment to MessageGroupCallback
  - Comment that it is moving into MGS in 3.0.
  - Convert DOS newlines to Unix.

For reference see: https://jira.springsource.org/browse/INT-2828
2012-11-21 17:44:02 -05:00
Gary Russell
403ad2edc5 INT-2776 Add Sender's UDP Port To Headers
User code can use the existing host and this new
header to send a reply over UDP.
2012-10-11 15:36:48 -04:00
Gary Russell
ed92b52039 INT-2763 - Fix Failing TCP Test
Uses the ExpressionEvaluatingMessageHandlerAdvice which
has had its constructor removed.
2012-09-21 19:33:24 +01:00
Gary Russell
e77811c59f INT-2742 Fix TCP Test Case Race Condition
Test data was sent before the error-channel was added to
the inbound adapter; the expected error could occur before
the error-channel was in place and the test failed
because the expected error message was absent.

Move the error-channel setup to before the test
data is sent.
2012-09-18 09:16:28 -04:00
Oleg Zhurakousky
950dc22343 Merge pull request #601 from garyrussell/INT-2599
* INT-2599:
  INT-2599 TCP Client Mode Corrections
2012-09-07 08:30:26 -04:00
Gary Russell
4be2e53d8f INT-2599 TCP Client Mode Corrections
1. Schema docs indicated client-mode is true by default, when
it is false.

2. Use IntegrationObjectSupport taskScheduler instead of
a field in the subclass.

INT-2599 polishing
2012-09-07 08:29:27 -04:00
Gary Russell
462493431e INT-2603 Fix TCP Shutdown Delay
A taskExecutor thread could deadlock in getTaskExector() if
stop() is attempting to shut down the task executor.

This could delay the stop by up to 20 seconds.

Move the if(isActive) test outside of the synchronized
block.
2012-09-05 11:48:44 -04:00
Gary Russell
273bba370b INT-2730 Move OrderlyShutDownAware Interface
Move from core to context.
2012-08-31 17:57:33 -04:00
Gunnar Hillert
dad4eac9ac INT-2710 - Remove hard-coded schema references
For reference see: https://jira.springsource.org/browse/INT-2710
2012-08-28 17:08:43 -04:00
Gary Russell
f8782f3dc9 INT-2711 syslog Transformer
Initial Implementation; UDP test.

syslog - Add TCP Test

Add single byte terminating deserializer and a
subclass that terminates on LF (syslog uses
LF terminator).

Move to Core

Allow for transport of undecoded packet over, say, AMQP.

INT-2711 Syslog Transformer

PR Comments; Polishing.

Remove List option; support to-map version only.
2012-08-14 14:15:21 -04:00
Gary Russell
89d2f3ad83 INT-2704 Exception Processing in TCP Adapter
When using an outbound adapter with a server connection factory
(an inbound adapter 'owns' the connections), the outbound adapter
simply logged exceptions.

There are use cases where flows need to know the exception occurs.

Change the adapter to throw a MessagingException.

Update the 2.1 to 2.2. Migration guide explaining that the
ExpressionEvaluatingRequestHandlerAdvice can be used to restore
2.1 behavior, and trap the exception.
2012-08-12 11:22:31 -04:00
Gary Russell
08cbab08c2 INT-2214, INT-343, INT-2250 MessageHandler Advice
Add general capability to advise just the handleRequestMessage
part of an AbstractReplyProducingMessageHandler.

This is to advise just the immediate operation, and not the
entire downstream flow.

Uses include:

* outbound gateway post processing
* adding retry behavior using spring-retry
* adding circuit breaker functionality

Initial commit for review.

Also need to advise simple message handlers (such as file
etc) to allow them to post-process file operations
with payload.delete(), payload.renameTo(...) etc.

INT-2250 Add Circuit Breaker Advice

INT-343 Add Retry Advice

Stateless and Stateful retry using spring-retry. Stateless
means the RetryTemplate performs the retries internally.
Stateful means the exception is thrown (e.g. to JMS container)
and the retry state is maintained by spring-retry.

INT-2215, INT-343, INT-2250 Refactoring

Factor out common abstract Advice class.

INT-2214 Catch Evaluation Expression Exceptions

If an onSuccess expression evaluation fails, add an
option so the user can decide whether such an exception is
caught, or propagated to the caller.

INT-2214 etc PR Review Polishing

INT-2214 etc Namespace Core, File, FTP

Add <request-handler-advice-chain/> to outbound endpoints.

INT-2214 etc. More Namespace Support

amqp, event, gemfire, groovy, http, ip, jdbc, jms, jmx, jpa, mail, rmi, sftp, twitter, ws, xmpp

INT-2214 etc Polishing

PR Review

INT-2214 etc Polishing

Don't catch Throwable.

Move Advice classes to handler.advice package.
2012-08-06 09:15:58 -04:00
Gunnar Hillert
57bc67b8fb INT-2689 - SI builds without warnings (Except Spring Integration HTTP)
* Ensure that no deprecation warnings occur
* Spring Integration builds with all tests successfully for Spring 3.1.2.RELEASE and 3.0.7.RELEASE (Except Spring Integration HTTP)

For reference see: https://jira.springsource.org/browse/INT-2689

INT-2694 - Fix Http Test Failures with Spring 3.0

As part of INT-2689, fix Http Test Failures in the Spring Integration Http Module when using Spring 3.0.7.RELEASE
For reference see: https://jira.springsource.org/browse/INT-2694
2012-08-01 13:09:51 -04:00
Gunnar Hillert
b07abcd30c INT-2262 - Add reply-timeout to Outbound Gateways
For reference see: https://jira.springsource.org/browse/INT-2262

Add reply-timeout attribute to:

* Amqp Outbound Gateway
* File Outbound Gateway
* Ftp Outbound Gateway
* Sftp Outbound Gateway
* Ws Outbound Gateway

Update Schema Documentation for reply-timeout attribute:

* spring-integration-jpa-2.2.xsd
* spring-integration-jms-2.2.xsd
* spring-integration-jdbc-2.2.xsd
* spring-integration-ip-2.2.xsd
* spring-integration-http-2.2.xsd

Update the *What's new in Spring Integration 2.2* section in the reference manual

INT-2262 - Code Review

* Update copyright year for affected files
* Update author tags for affected files
2012-07-16 14:37:16 -04:00
Gary Russell
09f3f7c342 INT-2660 NPE When Using SSL and NIO with Defaults
DefaultTcpNioSSLConnectionSupport and DefaultTcpNetSSLSocketFactorySupport need
an SSLContext which is set up in afterPropertiesSet(). However, when configuring
the connection factories with default strategies, afterPropertiesSet() is not
called. Result: NullPointerException.

Add call to afterPropertiesSet() where appropriate and tests to verify.
2012-07-10 16:40:21 -04:00
Gary Russell
eb9c25615b INT-2648 UDP - Don't Hold a Scheduler Thread
Previously, the UDP inbound adapter was incorrectly using
the default task scheduler (taskScheduler) to run its main
receive activity. Once a packet is read, it is handed off
to another thread for message processing, using a configured
(or default) task executor.

We should not hold on to a scheduler thread permanently; the
default scheduler has only 10 threads and one user's app
stopped working when using 10 inbound adapters.

The work around was to define an explicit 'taskScheduler'
bean with more threads.
2012-07-10 16:32:16 -04:00
Gary Russell
57755a07ed INT-2635 Set Buffer Size for Piped Streams
Improve performance.

For NIO sockets, a pair of PipedInput/OutputStreams are
used to transfer data from the reading thread to the
assembling thread.

The stream used the default buffer size (1024) which was
inefficient for large messages.

This change uses the underlying socket's receiveBufferSize
attribute to set the size of the piped stream, allowing
for more efficient data transfer.

Also adjusts the mocks in the deadlock detection test
to ensure the received data is larger than the pipe
buffer size.
2012-06-28 11:07:00 -04:00
Gary Russell
ae0abc4f6c INT-2515 More Orderly Shutdown
* Add beginShutdown() and endShutdown() to OrderlyShutdownCapable
* JMS/AMQP stop listener containers
* TCP (server side)
** after beginShutdown() disallow new connections, drop (log) new messages
** after endShutdown() close server socket
* HTTP (server side)
** after beginShutdown() disallow any new requests (503 Service Unavailable)

* Docbook updates
** What's new section
** Orderly Shutdown section.
2012-06-26 10:31:22 -04:00
Oleg Zhurakousky
2b49c66f64 INT-1141 Improve on how MessageHandlers are stored
INT-1141 polished code

INT-1141 added tests

INT-1141 improved how iterator is obtaind from OrderAwareLikedHashSet

INT-1141 polishing

INT-1141 stashed commit with List-based collection and performance tests

INT-1141 improved OrderedAwareLinkedHashSet

INT-1141 polishing

INT-1141, INT-2627 improved LoadBalancingStrategy and
RoundRobinLoadBalancingStrategy to obtain handler's iterator faster

INT-1141 improved getHandlerIterator method to ensure that it only executes reordering logic if there are more then one handler

INT-1141 simplified OrderedAwareLinkedHashSet to not to extend from LinkedHashSet

INT-1141
changed OrderedAwareLinkedHashSet to OrderedAwareCopyOnWriteArraySetTests, imporoved array creation in RoundRobinLoadBalancingStrategy

INT-1141 polished failing tests and RoundRobinLoadBalancingStrategy. Removed 'transient' from OrderedAwareCopyOnWriteArraySet
2012-06-21 13:03:50 -04:00
Gunnar Hillert
0269de0f98 INT-2564 Move Some SocketTestUtils to Test Module
Move SocketTestUtils.findAvailableServerSocket to Test Module

For reference see: https://jira.springsource.org/browse/INT-2564

* Move SocketTestUtils.findAvailableServerSocket to Spring Integration Test Module
* Fix tests
2012-06-21 12:35:22 -04:00
Artem Bilan
de73c39488 INT-2605: add SmartLifecycle support for 'chain'
* polishing TCP test to use SmartLifecycle from 'chain'
* polishing XSD to exclude using 'poller' element inside 'nested-chain'

INT-2605: eliminate breaking change in the XSD
2012-06-21 10:06:47 -04:00
Gary Russell
011953a5b6 INT-2590 Add TestingUtility
Added testing utility from samples to provide a tool for
users to wait for servers to start during tests.

Also refactored all tests that had similar code to use
this class.

Also corrected two failing tests that needed this wait.
2012-06-07 13:59:07 -04:00
Artem Bilan
5bc41bc60b INT-1029: Support for outbound-gateways in chain
XSD refactoring: remove use="required" from 'request-channel' attribute of all 'outbound-gateways'
Tests for all 'outbound-gateways' inside the <chain>
2012-06-07 13:20:56 -04:00
Gary Russell
48e972bf46 INT-2604 Remove Deprecated Header
The IPHeaders.CONNECTION_SEQ was replaced by the
standard sequenceNumber header (when applySequence is true)
in 2.1, in order to facilitate resequencing using the
standard resequencer.

This header was deprecated at that time. It is now
removed.

Users that were relying on this header should set
applySequence to true on the connection factory.
2012-06-07 13:00:18 -04:00
Gary Russell
7ede0eb4e6 INT-2459 Add Support for TCP Failover
Implemented a ConnectionFactory that wraps a list
of connection factories, used to fail over if
a connection fails.

INT-2459 Polishing

Rebase; fix test; move boolean resets to finally block
in server factories.

INT-2459 Polishing

PR Review

Fix a test that could block indefinitely when error
in code under test.
2012-06-07 12:25:42 -04:00
Gary Russell
9f3e8aab4a INT-2264, INT-2263 TCP GW Reconcile reply-timeout
reply-timeout had the wrong function, when compared to
other gateways.

Add remote-timeout to reflect the time we will wait
for a reply from the remote system

Make reply-timeout set the sendTimeout on the messaging template

Set remore-timeout to reply-timeout (if set) unless remote-timeout
is explicitly set.

Update reference doc, and migration guide on Wiki.
2012-06-05 10:05:48 -04:00
Gary Russell
90fe92ae29 INT-2419 Thread Starvation Detection
Previously, it was possible to run out of threads in
a fixed thread pool, and this could cause an indefinite
deadlock.

With this change, the deadlock is detected causing the
current message to fail, but freeing up the stuck
threads.

This was only seen with very small thread pools but
the potential was there for the condition to occur
under extreme conditions.

INT-2419 Deprecate poolSize Property

INT-2419 Polishing

Add note about OOM possibility now that an
unbounded task executor is used by default.
2012-06-01 12:08:43 -04:00
Gary Russell
fcd3771c17 INT-2588 Remove Deprecation
@ExpectedException is deprecated.

Also fixes a sporadic timing issue in the client mode test;
the default retry interval is 60 seconds and we only wait
10 seconds for the connection. If the initial connection
fails, we don't retry before the timeout.

INT-2527 Remove Event Deprecation

@Test @ExpectedException... -> @Test(expected...
2012-05-25 15:30:24 -04:00
Gary Russell
33c0da2341 INT-2581 Fix Failing Test (Timing)
When sending a message to the server, we checked that the
user hook for the socket creation was called. However,
it was possible (likely) that we tested the counter before
the socket actually opened.
2012-05-23 13:11:34 -04:00
Gary Russell
5c0c55409b INT-2153 SSL Support
Add strategy interfaces
 - obtaining ServerSocketFactory and SocketFactory
 - post processing ServerSockets and Sockets
 - obtaining initialized SSLContext

Provide SSL and non-SSL implementations of the strategies, to
serve up the appropriate socket factories, and do nothing in the
post processing methods.

The postprocessors allow the user to modify sockets after
configured attributes have been applied but before the sockets
are used.

This is particularly useful with SSL in case additional SSL
options need to be applied.

Docs

Polishing JavaDocs

Polishing

Javadocs, polishing

Polishing

Polishing

INT-2153 Polishing

PR Review

White Space

INT-2513 Polishing

Fixed method names.
2012-05-23 12:45:24 -04:00
Gary Russell
59d7432eef INT-2417 Alias Endpoints with Generated Names
Handlers for consumer endpoints get a generated name
derived from the endpoint class name.

It is useful (for example for autowiring in tests)
to give the handlers a well-known name.

If the endpoint has an ID attribute, the handler
now gets a bean name of "<ID>.handler".
2012-05-17 16:10:02 -04:00
Artem Bilan
45c429ee2b INT-2275: any outbound-channel-adapter in <chain>
Add re-init logic for nested chains
Add logic about nested element for AbstractChannelAdapterParser
Refactor of DefaultOutboundChannelAdapterParser
Test for non-last nested chain with some outbound-channel-adapter
Improve XSD for chain-type
Manual outbound-channel-adapter ability for chain
Integration tests for all outbound-channel-adapter within <chain>
Remove redundant 'return-value-required' attribute from <stored-proc-outbound-channel-adapter>
Add support 'expectReply' for FileWritingMessageHandler

INT-2275 polishing & refactor FileOutbound*Parser

HttpRequestExecutingMessageHandlerTests polishing

INT-2275: polishing JavaDoc
2012-05-14 12:41:39 -04:00
Gary Russell
0a12a496cc INT-2485 Orderly Shutdown
Initial commit - @ManagedOperation on IMBE

- can be invoked via JMX, <control-bus/>, or getting a reference to
the IMBE from the application context.

INT-2485 Updates After Review Comments (JIRA)

* Shutdown Schedulers first, and wait for them
* Add a force parameter, which overrides thread pool shutdown options
* Shutdown Sources/Channels after all thread pools have stopped
* Mark other components as OrderlyShutdownCapable (e.g. JMS/AMQP Listener containers) and shut them down first
* Wait for remaining time to allow for quiescence

Also
* remove TimeUnit parameter (not JMX-friendly); time limit is now always milliseconds
* If thread pools don't stop in time limit, force them down.

INT-2485 Handle Self-Destruction

Add shutdown-executor to IMBE.

When the shutdown was called on a Spring-Managed thread, the shutdown
was not clean because we timed out waiting for the current thread to
terminate. After that, we force terminated other components.

Now, by providing a dedicated Executor for the shutdown process, it
is used for the shutdown instead of the current thread. This Executor
is *not* shutdown.

It is not necessary to provide an Executor if the stopActiveComponents()
method is called on some other thread that is not involved in the
shutdown.

Also adds executor name to logs, when available.

INT-2485 Polishing

Fix MBean object name collision when running all tests.

INT-2485 Enable TCP Shutdown

Make TCP connection factories 'OrderlyShutdownCapable' so
they are stopped before schedulers/executors in order for
them to release any executor threads they are holding.

INT-2485 Polishing

Didn't need DirectFieldAccessor - scheduler and executor have
an accessor for the native ExecutorService.

Copyrights

INT-2485 Polishing

schemaLocation version.

INT-2485 PR Review Polishing
2012-05-10 08:10:00 -04:00
Gary Russell
b271a7c42c INT-2519 Fix Failing Test
Depending on timing, it was possible the event the test
case was waiting for would never happen. With no timeout
the selector will block until the next IO event occurs,
and there is none in this test.

Adding a call to factory.close() forces a wakeup of
the selector, which will force the harvest to occur.

This is a test-only problem.
2012-05-08 14:33:14 -04:00
Gary Russell
120b2a3893 INT-2519 Fix Memory Leak
When using NIO, a Map of connections is maintained (keyed
by the SocketChannel) and used to manage registrations
for NIO events, timeouts etc.

When a connection is closed, the corresponding entry
should be removed from the map. The code to do this
is in AbstractConnectionFactory.processNioSelections().
However, if no socket timeout (soTimeout) has been set,
or it was explicitly set to 0, connections are not
removed from the map. This was because the timeout
logic and map cleanup is done in the same iteration
loop.

Now, if soTimeout is not set, the clean up loop
operates every nioHarvestInterval milliseconds
(default 2000), we don't want to run it on
every selector event.

In addition, it runs if the selectionCount is
zero - this might occur when a socket
is closed, when the selector.wakeup() is called.

INT-2519 Polishing

Rename connections field in NIO connection factories. Name
collision caused TestUtils problem on some platforms.
2012-05-07 12:59:34 -04:00
Gary Russell
87f487007d INT-1871 Remove Schema Versions
Schemas update to 2.2 after the PR and the new
test config had 2.1 versioned schemas.

INT-1871 polishing, removed unused import
2012-05-07 09:23:11 -04:00
Gary Russell
411aa296a4 INT-1871 TCP CachingClientConnectionFactory
Pool based on algorithm used for spring-integration-file
CachingSessionFactory introduced by INT-2146. Refactored
that code to use the common SimplePool.

One difference to the previous implementation is the
ability to change the pool size dynamically.

If the size is reduced and more than the new size are
in use, items are closed as they are returned until
the pool size is as requested.

Initial commit.

Allow Pool Size Changes

Factor out Pool

Polishing

Pool Tests

Default forever

Javadocs, File

Polishing

INT-1871 PR Polishing

* Consistent/cleaner method names
* Track checkouts; reject release of 'foreign' objects.
* Add 'getAllocatedCount()'
2012-05-07 08:25:11 -04:00
Gary Russell
409cc95607 INT-2511 Change Default Socket Timeout
Previously, when a client connection factory was used by
both an inbound and outbound adapter, the socket timeout
defaulted to 10 seconds.

This was inappropriate because, often, collaborating
channel adapters are used for aysnchronous messaaging and,
even when used for request/response, it is generatlly not
appropriate to timeout the socket due to a lack of recent
send activity.
2012-05-04 10:32:17 -04:00
Gary Russell
95cd202be6 INT-2536 Create 2.2 Schemas
Add 2.2 versions of module schemas.

JMX is already covered by an existing pull request.

INT-2536 Schema Check

Bump version for schema check in
AbstractIntegrationNamespaceHandler.

INT-2536 Remove Schema Versions

Some test config files had 2.1 versioned schemas.
2012-05-04 10:04:01 -04:00
Gary Russell
292aa90599 INT-2404 Fix Auto-Created Channel; Event, TCP, UDP
The AbstractChannelAdapterParser creates an implicit DirectChannel
if the adapter has no 'channel' attribute.

The Event, TCP, and UDP channel adapter parsers did not bind
this channel to the adapter and AC initialization failed with
'outputChannel is required'.

Further, the event schema marked the channel as being 'required',
precluding this feature.

INT-2407 Remove Channel use="required"

Parsers automatically generate the channel when none is provided.

- JMX
- JDBC
- SFTP
- Redis
- Feed
- XMPP
- Mail
- FTP
- HTTP
2012-01-23 10:12:34 -05:00
Gary Russell
f76f63f23a NT-2400 Fix tool:expected-type Classes
* MessageChannel was moved from core to the base package.
* ChannelResolver moved from core to support.
* TcpConnectionInterceptorFactoryChain was incorrect.
2012-01-13 13:21:41 -05:00
Gary Russell
b59ee8e352 INT-2369 package-info IP
INT-2360 package-info Core

INT-2361 package-info AMQP

INT-2362 package-info Event

INT-2363 package-info Feed

INT-2364 package-info File

INT-2365 INT-2380 package-info (S)FTP

INT-2366 package-info GemFire

INT-2367 package-info Groovy

INT-2368 package-info Http

INT-2378 package-info Scripting

INT-2372 package-info JMS
2012-01-05 14:42:24 -05:00
Gary Russell
3c49cb3480 INT-2333 Mac OSX TCP Workaround on Server Side
Mac OSX problem was encountered only on the client; similar
code exists on the server side, so the workaround should
be implemented there too; just in case.
2011-12-22 16:26:50 -05:00
Gary Russell
49c52353cd INT-2333 Work Around for MAC OSX JVM Bug
Selector.select() throws CancelledKeyException when selecting
on a closed socket.

http://java.net/jira/browse/MACOSX_PORT-526

Work around is to catch the exception and continue.
2011-12-22 15:53:03 -05:00
Gary Russell
0f01ba20ea INT-2332 Remove Benign Exceptions From Maven Build
The IP module produced a significant number of benign exceptions
during a maven build. Due to auto-startup adapters with a
small retry-interval for client-mode adapters.
2011-12-21 23:34:47 -05:00
Gary Russell
0f46176c3d INT-2287 Timing Hole With Send-and-Forget TCP
If a tcp client connection factory was configured for single-use
connections (one socket per message), and it was used by an outbound
channel adapter (send and forget), the socket is closed immediately
after sending the message.

This could cause issues with the connection handling because certain
failures could occur. For example, the close could occur before we
ever registered the channel for read selection, resulting in a
ClosedChannelException. Secondly, there was a small timing hole
where a selection key could be invalidated between the isValid()
call and isReadable().

These problems have been corrected.
2011-11-30 16:23:33 -05:00
Gary Russell
3fff33c99b INT-2268 Fix Spurious Failing Test
Occasional test failures caused because test HelloWorldInterceptor
could prematurely close the connection, depending on timing.

Also added some minor cleanup to the tests themselves.
2011-11-29 11:50:32 -05:00
Mark Fisher
6c1454ae3d INT-2238 removing warnings in JavaDoc 2011-11-22 21:48:34 -05:00