-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
In what version(s) of Spring Integration are you seeing this issue?
5.5.8
Describe the bug
In 5.2.8.RELEASE, the following code worked:
@Configuration
@IntegrationComponentScan
@EnableIntegration
public class MyServer {
@Bean
public AbstractServerConnectionFactory serverConnectionFactory() {
TcpNetServerConnectionFactory connectionFactory = new TcpNetServerConnectionFactory(listenPort);
TcpConnectionInterceptorFactoryChain interceptorFactoryChain = new TcpConnectionInterceptorFactoryChain();
interceptorFactoryChain.setInterceptor(new MyInterceptorFactory());
connectionFactory.setInterceptorFactoryChain(interceptorFactoryChain);
return connectionFactory;
}
@ServiceActivator(inputChannel = "myOutput")
@Bean
public TcpSendingMessageHandler outbound(AbstractServerConnectionFactory connectionFactory) {
TcpSendingMessageHandler tcpSendingMessageHandler = new TcpSendingMessageHandler();
tcpSendingMessageHandler.setConnectionFactory(connectionFactory);
return tcpSendingMessageHandler;
}
// ... etc ...
private class MyInterceptorFactory implements TcpConnectionInterceptorFactory {
@Override
public TcpConnectionInterceptorSupport getInterceptor() {
return new MyInterceptor();
}
}
private class MyInterceptor extends TcpConnectionInterceptorSupport {
@Override
public void addNewConnection(TcpConnection connection) {
super.addNewConnection(connection); // <=== I was called before but I'm not now!!!! ===
}
}
}
However, in 5.5.8 -- and I assume ever since this change -- the addNewConnection()
method above is no longer called.
This is because the old code called org.springframework.integration.ip.tcp.connection.TcpConnectionSupport.registerSender(TcpSender)
with a MyInterceptor
instance. This called this.theConnection.registerSender(this)
which eventually called addNewConnection()
on the interceptor.
But the new code calls org.springframework.integration.ip.tcp.connection.TcpConnectionSupport.registerSenders(List)
. It then walks through the list of senders and calls addNewConnection()
on them directly, and those senders are the TcpSendingMessageHandler
Bean(s) that were returned from the outbound
ServiceActivator(s) above.
Let me know if this is clear, or, if not, if I should make working and non-working samples.
Or, alternately, let me know if I'm misreading the documentation and am setting up interceptors wrong!
Thank you so much!
Dave