【问题标题】:TCP messages over ISO TCP/RFC 1006基于 ISO TCP/RFC 1006 的 TCP 消息
【发布时间】:2017-02-07 15:35:23
【问题描述】:

我有一个 Spring Integration 项目,通过注解配置了以下与 TCP 相关的配置:

@Bean
public TcpReceivingChannelAdapter tcpIn(AbstractClientConnectionFactory connectionFactory) {
    TcpReceivingChannelAdapter receiver = new TcpReceivingChannelAdapter();
    receiver.setOutputChannel(fromTcpReceiver());
    receiver.setConnectionFactory(connectionFactory);
    return receiver;
}

@Bean
public AbstractClientConnectionFactory clientFactory() {
    TcpNetClientConnectionFactory factory = new TcpNetClientConnectionFactory(host, port);
    factory.setSoKeepAlive(keepAlive);
    factory.setSoTimeout(timeout);
    return factory;
}

@Bean
public TcpSendingMessageHandler tcpOut(AbstractClientConnectionFactory connectionFactory) {     
    TcpSendingMessageHandler sender = new TcpSendingMessageHandler();
    sender.setConnectionFactory(connectionFactory);
    return sender;
}

在 Spring Integration 中,通过 ISO TCP/RFC 1006 封装 TCP 消息的最佳方式是什么?

基本上,TCP ISO 会在初始连接中添加一个步骤,但还会为每个发送/接收的 TCP 消息添加一个附加标头。

我正在阅读文档,但我不知道这种消息丰富和协商的最佳方式是什么。这可以通过 Spring Integration 实现吗?

我有 3 个想法:

  • messageBuilderFactory
  • 串行器/解串器
  • TcpConnectionInterceptorFactoryChain

欢迎任何帮助/示例

【问题讨论】:

    标签: spring sockets tcp spring-integration rfc


    【解决方案1】:

    我没有查看 RFC,但您可能需要自定义序列化器/反序列化器的组合,以及自定义 TcpMessageMapper 将标头映射到 Spring Integration 消息标头/从 Spring Integration 消息标头映射。

    MessageConvertingTcpMessageMapper 为例。

    【讨论】:

    • 最后,我使用了一个自定义的@Transformer。这是因为启动过程
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-28
    • 2011-12-09
    • 2015-05-12
    • 1970-01-01
    • 2011-11-07
    • 2016-11-09
    • 2017-01-25
    相关资源
    最近更新 更多