24 Ekim 2017 Salı

TcpNetClientConnectionFactory Sınıfı

setTcpSocketFactorySupport metodu
Şöyle yaparız.
private static final int SERIALIZER_HEADER_SIZE = 2;

@Bean
public ByteArrayLengthHeaderSerializer byteArrayLengthHeaderSerializer() {
  return new ByteArrayLengthHeaderSerializer(SERIALIZER_HEADER_SIZE);
}

@Bean
public AbstractClientConnectionFactory tcpClientConnectionFactory() {
  TcpNetClientConnectionFactory connFactory =
    new TcpNetClientConnectionFactory(props.getUrl(), props.getPort());
  connFactory.setSerializer(byteArrayLengthHeaderSerializer());
  connFactory.setDeserializer(byteArrayLengthHeaderSerializer());
  connFactory.setSoTimeout(props.getSoTimeout());

  if (props.isUseSSL()) {
    connFactory.setTcpSocketFactorySupport(new DefaultTcpNetSSLSocketFactorySupport(()-> {
      return SSLContext.getDefault();
    }));
  }

  return connFactory;
}

Hiç yorum yok:

Yorum Gönder