I have an application in which I need to get a person's credit report by sending demographic information to a remote server and receiving the report from that server to a different port. For example, I'd send a message containing the demo info to port 9300 on the remote server and receive the credit report message to port 9305 of my local.
I tried this configuration :
My main:Code:<!-- CLIENT SIDE --> <bean id="rawSerializer" class="org.springframework.integration.ip.tcp.serializer.ByteArrayRawSerializer" /> <bean id="isRequestUtils" class="com.util.ISRequestUtils"/> <int:channel id="initialRequest" datatype="java.lang.String"/> <int:channel id="txAdded" datatype="java.lang.String"/> <int:channel id="finalRequest" datatype="java.lang.String"/> <int:channel id="creditReport" datatype="java.lang.String"/> <int:gateway id="requestHandler" service-interface="com.util.ISRequestHandler2" default-request-channel="initialRequest" default-reply-channel="creditReport"/> <int:transformer id="addTXcontrol" input-channel="initialRequest" output-channel="txAdded" ref="isRequestUtils" method="addTX"/> <int:transformer id="addPrefix" input-channel="txAdded" output-channel="finalRequest" ref="isRequestUtils" method="addPrefix"/> <int-ip:tcp-outbound-channel-adapter id="message" channel="finalRequest" connection-factory="requestCF"/> <int-ip:tcp-connection-factory id="requestCF" type="client" host="${infoserver.address}" port="${infoserver.request.port}" so-keep-alive="true" single-use="false" serializer="rawSerializer"/> <!-- SERVER SIDE --> <bean id="byteArrayStxEtxSerializer" class="org.springframework.integration.ip.tcp.serializer.ByteArrayStxEtxSerializer"> <property name="maxMessageSize" value="102400"/> </bean> <bean id="isResponseUtils" class="com.util.ISResponseUtils"/> <int:channel id="byteResponse"/> <int:channel id="stringResponse" datatype="java.lang.String"/> <int:channel id="finalResponse" datatype="java.lang.String"/> <int-ip:tcp-connection-factory id="isListener" type="server" host="localhost" port="${infoserver.response.port}" so-keep-alive="true" single-use="false" deserializer="byteArrayStxEtxSerializer"/> <int-ip:tcp-inbound-channel-adapter id="inboundResponse" channel="byteResponse" connection-factory="isListener"/> <int:transformer id="bytes2String" input-channel="byteResponse" output-channel="stringResponse" expression="new String(payload)"/> <int:service-activator input-channel="stringResponse" output-channel="creditReport" ref="isResponseUtils" method="showResponse"/>
Code:ApplicationContext context = new ClassPathXmlApplicationContext("/spring-config/si-config.xml"); final ISRequestHandler2 requestHandler = context.getBean(ISRequestHandler2.class); //final AbstractServerConnectionFactory isListener = context.getBean(AbstractServerConnectionFactory.class); String response = requestHandler.send("DEMOGRAPHIC_INFO"); System.out.println(response);


Reply With Quote
