This is an example of a server-to-server chain implementation where a SMPP (Short Message Peer-to-Peer) client using NIO in a single thread can provide many TCP sessions .
The other asynchronous client using reactive streams (java.util.concurrent.Flow) to communicate with the SMPP client sends messages to the application server.
Thus, communication between many SMSC (Short Message Service Center) and many application servers (or micro services) can be served by only two threads.
ProtocolClient client = SmppClient.builder() .bindIp("localhost").host("localhost").port(server.getPort()) .username("guest").password("secret") .systype("ReSmpp").timeout(30 * 1000) .maxmps(2) .newSession(); client.connect(channelNumber)
client.processing(); BasePDU pdu; while (pdu!= null ) { pdu=client.getNextPdu(DEFAUL_READ_TIMEOUT)); }
client.send(channelNumber,pdu=new Submit() .message("Hello!") .setseqId()); client.close(channelNumber)
server = new TestServer() .withPort(port) .setPackerParser(new Function() { @Override public BasePDU apply(ByteBuffer buffer) { return BasePDU.newPDU(buffer); } }).start();
server.setHandler((pdu)->{ BasePDU resp=switch(pdu.getCommandId()){ case BaseOps.BIND_TRANSCEIVER -> new BindResp().of(pdu); default->null; }; return null; });