A simple Java TCP message processing built on top of Apache Mina Framework (https://mina.apache.org/).
$ git clone https://github.com/bernardocoferre/java-tcp.git
$ cd java-tcp
$ mvn install
$ mvn spring-boot:run- On first run, Spring will setup our TCP server using the
ServerStartupRunnerclass - The TCP server will be ready to receive connections at port
8090 - A bunch of clients will be created, sending dummy data for our server using
ClientStartupRunnerclass - The Messages Monitor front-end will be available at
http://localhost:8080/where we can view all received messages, or inspect a single message - H2 console is enabled on
http://localhost:8080/h2where we can directly interact with the database
public class ServerStartupRunner implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
...
acceptor.bind(new InetSocketAddress(Parameters.PORT));
}
}public class ClientStartupRunner implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
LOGGER.info(new Str.Builder("Starting [{}] clients..").build(Parameters.CLIENTS_AMOUNT));
this.client.start(Parameters.CLIENTS_AMOUNT);
}
}- Java TCP server for handle incoming messages
- A simple TCP client to send dummy messages to server
- Front-end Messages Monitor available at
http://localhost:8080/- View and inspect all received messages
- Follow messages statistics
- Clean-up all the stored messages on server
- A simple REST API to view all messages or inspect a specific message
- Available at
/api/messagesand/api/messages/{id}
- Available at

