Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay propagating socket close when using NIO [INT-4465] #8405

Closed
spring-operator opened this issue May 9, 2018 · 0 comments
Closed

Delay propagating socket close when using NIO [INT-4465] #8405

spring-operator opened this issue May 9, 2018 · 0 comments

Comments

@spring-operator
Copy link
Contributor

Gary Russell opened INT-4465 and commented

There is a 1 second delay propagating a socket close to the deserializer when using NIO.

@SpringBootApplication
public class So50251193Application implements ApplicationRunner {

	private static final Log logger = LogFactory.getLog(So50251193Application.class);

	public static void main(String[] args) {
		SpringApplication.run(So50251193Application.class, args);
	}

	@Bean
	public IntegrationFlow netFlow() {
		return IntegrationFlows.from(Tcp.inboundAdapter(Tcp.netServer(1234)
					.deserializer(new ByteArrayElasticRawDeserializer())))
				.transform(Transformers.objectToString())
				.log()
				.get();
	}

	@Bean
	public IntegrationFlow nioFlow() {
		return IntegrationFlows.from(Tcp.inboundAdapter(Tcp.nioServer(1235)
					.deserializer(new ByteArrayElasticRawDeserializer())))
				.transform(Transformers.objectToString())
				.log()
				.get();
	}

	@Override
	public void run(ApplicationArguments args) throws Exception {
		Socket socket = SocketFactory.getDefault().createSocket("localhost", 1234);
		socket.getOutputStream().write("foo".getBytes());
		logger.info("sent foo");
		socket.close();
		socket = SocketFactory.getDefault().createSocket("localhost", 1235);
		socket.getOutputStream().write("bar".getBytes());
		logger.info("sent bar");
		socket.close();
	}

}
2018-05-09 08:58:41.720  INFO 70727 --- [           main] com.example.So50251193Application        : sent foo
2018-05-09 08:58:41.722  INFO 70727 --- [           main] com.example.So50251193Application        : sent bar
2018-05-09 08:58:41.728  INFO 70727 --- [pool-1-thread-2] o.s.integration.handler.LoggingHandler   : GenericMessage [payload=foo, headers={ip_tcp_remotePort=53405, ip_connectionId=localhost:53405:1234:21e15552-b68b-4f63-af57-ce4555d8d84c, ip_localInetAddress=/127.0.0.1, ip_address=127.0.0.1, id=a3e1f6ed-0a96-5384-1bc8-ca845c89806e, ip_hostname=localhost, timestamp=1525870721728}]
2018-05-09 08:58:42.735  INFO 70727 --- [pool-2-thread-3] o.s.integration.handler.LoggingHandler   : GenericMessage [payload=bar, headers={ip_tcp_remotePort=53406, ip_connectionId=localhost:53406:1235:abd275db-53af-4061-9b8c-9dc38b991480, ip_localInetAddress=0.0.0.0/0.0.0.0, ip_address=127.0.0.1, id=c17362ed-ec2d-5bb6-53ca-07125c9bda90, ip_hostname=localhost, timestamp=1525870722735}]

Affects: 5.0.5

Reference URL: https://stackoverflow.com/questions/50251193/socket-message-reading-delay-in-spring-integration

Referenced from: pull request #2439

Backported to: 4.3.17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants