Non blocking TCP connect in Spring Integration -
i attempting use spring integration connect large number of devices (500-1000) on volatile network , i'm having issues default pool of 10 task schedulers blocking trying connect devices not available.
my implementation based on dynamic ftp example, new child application context created each of remote devices client tcp connection factory , tcp inbound adapter messages routed flow of root context.
the problem having is important these devices connected quickly, large number of them may offline @ time.
all connections seem sent out single 10 member task scheduler pool , end blocking on connect call, causing large delays connecting devices online further down list.
so question is, there way implement non blocking connect call using spring integration?
non-blocking connect won't because connections established on demand , sending thread needs block until connection enabled, if it's request/reply scenario. if using channel adapters one-way or arbitrary two-way communication (not using outbound gateway). can put requests in queue channel.
the poller resources limited , it's best not run long-running tasks on pollers directly, hand off task-executor instead.
you have several options:
- use task-executor don't hold poller thread.
- increase scheduler pool size - either define own
taskscheduler
bean, or add properties file classpath/meta-inf/spring.integration.properties
containingspring.integraton.taskscheduler.poolsize=50
(or whatever). - reduce connect timeout default on os.
the last bit more involved , depends on whether using nio or not. if not, provide custom tcpsocketfactorysupport
returns factory createsocket(host, port)
createsocket()
, connect(socketadddress, timeout)
. if you're using nio, messages should buffered , not block until buffer full.
edit: see using inbound adapters; assumed outbound. presume have client-mode
set. there no task executor option there; option configure custom task scheduler inbound adapter don't use main pool.
Comments
Post a Comment