java - Mix tcp-connection-factory + tcp-inbound-gateway + router -


can send distinct messages (distinct serialize/deserialize) same tcp server (same host , port) , differentiate tcp-inbound-gateway value of header or payload router???

(...)

i want add router select correct tcp-inbound-gateway depends on field in header or payload (for example named typedata). in order enter request (or message) between router, tcp-inbound-gateway, tcp-connection-factory, serialize/deserialize? have problems serialization/deserialization chose tcp-inbound-gateway? correct way this?

thanks in advance.


edit

in server:

<!-- common --> <int:channel id="channelconnectionfactoryrequest" /> <int:channel id="channelconnectionfactoryresponse" />  <router method="getdestinationchannel"     input-channel="channelsconnectionfactoryrequest">         <beans:bean class="org.mbracero.integration.customrouter" /> </router>  <beans:bean id="customserializerdeserializer"     class="org.mbracero.integration.serialization.customserializerdeserializer" />  <int-ip:tcp-connection-factory id="customconnectionfactory"     type="server" port="${payment.port}" single-use="true"     serializer="customserializerdeserializer"     deserializer="customserializerdeserializer" />  <int-ip:tcp-inbound-gateway id="custominboundgateway"     connection-factory="customconnectionfactory"     request-channel="channelcustomconnectionfactoryrequest"     reply-channel="channelcustomconnectionfactoryresponse"     error-channel="errorchannel" />  <!-- custom -->  <beans:bean id="operations"     class="org.mbracero.integration.applepay.impl.operationsimpl" />  <!-- operation 1 --> <int:channel id="operationonerequest" />  <int:service-activator input-channel="operationonerequest"     output-channel="operationoneresponse" ref="operations" method="getoperationone" />  <!-- operation 2 --> <int:channel id="operationtworequest" />  <int:service-activator input-channel="operationtworequest"     output-channel="operationtworesponse" ref="operations" method="getoperationtwo" /> 

operationsimpl:

resultone getoperationone(requestone request);  resulttwo getoperationone(requesttwo request); 

resultone & resulttwo implements resultbase. , in serialize of customserializerdeserializer have:

@override public void serialize(resultbase arg0, outputstream arg1) throws ioexception {      byte[] xxx = xxx.getbytes();     arg1.write(xxx);      byte[] yyy = yyy.getbytes();     arg1.write(sendername);      // **each custom object have method serialize own data**     arg0.transformdatatobyte(arg1);      arg1.flush(); } 

in client:

<gateway id="tmgateway"     service-interface="org.mbracero.integration.customgateway" />  <beans:bean id="operationoneserializerdeserializer"     class="org.mbracero.integration.serialization.operationoneserializerdeserializer" />  <int-ip:tcp-connection-factory id="operationonefactory"     type="client" host="127.0.0.1" port="7878" single-use="true"     serializer="operationoneserializerdeserializer" deserializer="operationoneserializerdeserializer" />  <int-ip:tcp-outbound-gateway id="operationoneoutgateway"     request-channel="operationonechannel" connection-factory="operationonefactory"     request-timeout="5000" reply-timeout="5000" remote-timeout="5000" />   <beans:bean id="operationtwoserializerdeserializer"     class="org.mbracero.integration.operationtworequestserializerdeserializer"/>  <int-ip:tcp-connection-factory id="operationtwofactory"     type="client" host="127.0.0.1" port="7878" single-use="true"     serializer="operationtwoserializerdeserializer"     deserializer="operationtwoserializerdeserializer" />  <int-ip:tcp-outbound-gateway id="operationtwooutgateway"     request-channel="operationtwochannel" connection-factory="operationtwofactory"     request-timeout="50000" reply-timeout="50000" remote-timeout="50000" /> 

customgateway:

@gateway(requestchannel="operationonechannel") operationoneresponse sendoperationone(operationonerequest request);  @gateway(requestchannel="operationtwochannel") operationtworesponse sendoperationtwo(operationtwo request); 

you cannot have 2 server connection factories listening on same port. tcp doesn't allow - network stack wouldn't know server socket route request to.

there's no problem on client side but, single socket, server have understand how deserialize both data types.

it's easier combine serializers/deserializers 1 on both sides (add header message deserializer knows type of payload decode).


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -