Skip to content

Implementation of smpp client using NIO and reactive streams

License

Notifications You must be signed in to change notification settings

indaos/ReactiveSmppStreams

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ReactiveSmppStreams

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.

connecting to SMSC

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)

processing of PDUs received from all SMSCs.

 client.processing();
 BasePDU pdu;
 while (pdu!= null )  {
    pdu=client.getNextPdu(DEFAUL_READ_TIMEOUT));
 }

sending PDU

 client.send(channelNumber,pdu=new Submit()
                .message("Hello!")
                .setseqId());
 client.close(channelNumber)

SMSC simulator

 server = new TestServer()
          .withPort(port)
          .setPackerParser(new Function() {
              @Override
              public BasePDU apply(ByteBuffer buffer) {
                  return BasePDU.newPDU(buffer);
              }
          }).start();

processing PDUs received from clients

server.setHandler((pdu)->{
              BasePDU resp=switch(pdu.getCommandId()){
                  case BaseOps.BIND_TRANSCEIVER -> new BindResp().of(pdu);
                  default->null;
              };
              return null;
        });

About

Implementation of smpp client using NIO and reactive streams

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages