2014-07-04 146 views
0

我有一個生產者(寫在CPP)發送到「春季集成服務器」的二進制數據。 它的工作原理如下: spring integration time out clients春季集成發送使用網關

現在我必須發送一個回覆(如ACK)給製作人。

我已閱讀關於網關,但實際上我很困惑。 我的配置是:

<int-ip:tcp-connection-factory id="serverTcpConFact" 
    type="server" 
    port="5566" 
    using-nio="true" 
    single-use="false" 

    task-executor="myTaskExecutor" 
    deserializer="serializer" 
    serializer="serializer"/> 

<int-ip:tcp-inbound-channel-adapter id="tcpInboundAdapter" 
    channel="tcpInbound" 
    connection-factory="serverTcpConFact" /> 

<int:channel id="tcpInbound" /> 


<int:service-activator 
    output-channel="tcpOutbound" 
    input-channel="tcpInbound" 
    ref="importService" 
    method="handler" /> 

<bean id="importService" class="my.ImportService" /> 

<int:channel id="tcpOutbound" /> 

<int:gateway id="mygateway" 
    service-interface="my.IpMyGatway" 
    default-request-channel="tcpInbound" 
    default-reply-channel="tcpOutbound" 
    default-reply-timeout="6000"/> 

我也有一個自定義的serializator,問題是,我的春天集成服務器不發送答覆。

我需要回復執行:

@Override 
    public void serialize(MyMessage arg0, OutputStream outputStream) throws IOException { 
     // TODO Auto-generated method stub 
     logger.info("serialize messages"); 
// here I have to write my ACK ! (.. or not?) 
    } 

然後將消息發送到生產者對每封郵件。

謝謝。

回答

1

我不知道爲什麼<int-ip:tcp-inbound-gateway>是不夠的,你...

只是有足夠的產生從service和網關回復消息將發送加時賽客戶端的響應。

的簡單示例:

<ip:tcp-inbound-gateway id="gatewaySerializedNio" 
     connection-factory="connectionFactory" 
     request-channel="serviceChannel" /> 

<channel id="serviceChannel" /> 

<service-activator input-channel="serviceChannel" 
     ref="service" method="process"/> 

<beans:bean id="service" class="com.my.proj.MyService" /> 

MyService#process方法的返回值將被序列化到TCP套接字。

+0

謝謝@Artem Bilan,但我不明白'reply message'是什麼意思。你可以更好地離開嗎? –

+0

向答案添加了示例 –

+0

好的,我不知道,謝謝我解決了。 –