diff --git a/basic/tcp-client-server/readme.txt b/basic/tcp-client-server/readme.txt index d14179d1..3296d5f5 100644 --- a/basic/tcp-client-server/readme.txt +++ b/basic/tcp-client-server/readme.txt @@ -5,4 +5,24 @@ Gateway -> Channel -> TcpOutboundGateway -> <===Socket===> -> TcpInboundGateway The service returns a response which the inbound gateway sends back over the socket to the outbound gateway and the result is returned to the client that invoked the original SimpleGateway method. -To run sample simply execute a test case in org.springframework.integration.samples.tcpclientservice package \ No newline at end of file +To run sample simply execute a test case in org.springframework.integration.samples.tcpclientservice package. + + +In addition, a simple telnet server is provided; see TelnetServer in src/main/java. Run this class as a +java application and then use telnet to connect to the service ('telnet localhost 11111'). + +Messages sent will be returned, preceded by 'echo:'. + + +$ telnet localhost 11111 +Trying 127.0.0.1... +Connected to localhost. +Escape character is '^]'. +Hello world! +echo:Hello world! +Test +echo:Test +^] + +telnet> quit +Connection closed. diff --git a/basic/tcp-client-server/src/main/java/org/springframework/integration/samples/tcpclientserver/TelnetServer.java b/basic/tcp-client-server/src/main/java/org/springframework/integration/samples/tcpclientserver/TelnetServer.java new file mode 100644 index 00000000..721d352c --- /dev/null +++ b/basic/tcp-client-server/src/main/java/org/springframework/integration/samples/tcpclientserver/TelnetServer.java @@ -0,0 +1,39 @@ +/* + * Copyright 2002-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.integration.samples.tcpclientserver; + +import org.springframework.context.support.AbstractApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * The configured inbound gateway uses CRLF delimited messages which means + * it works fine as a very simple Telnet server - connect using + * telnet localhost 11111 - each time you hit enter you should see your input + * echoed back, preceded by 'echo:'. + * + * @author Gary Russell + * + */ +public class TelnetServer { + + public static void main(String[] args) throws Exception { + new ClassPathXmlApplicationContext("/META-INF/spring/integration/tcpClientServerDemo-context.xml"); + System.out.println("Press Enter/Return in the console to exit"); + System.in.read(); + System.exit(0); + } + +} diff --git a/basic/tcp-client-server/src/main/resources/log4j.xml b/basic/tcp-client-server/src/main/resources/log4j.xml new file mode 100644 index 00000000..f391e2ed --- /dev/null +++ b/basic/tcp-client-server/src/main/resources/log4j.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file