Creating an Incoming Communication Channel

EC Communication Channel can be configured to receive incoming messages. You can do this by creating a channel class and implement different methods in the class.

Creating an Incoming Communication Channel

  1. Write an incoming communication channel class. The class must extend another class called com.intentia.ec.shared.IncommingChannel.
  2. Implement the following abstract methods in the super class:
    • initiateChannel

    • getDelayTime

    • cleanUpChannel

  3. Implement the runChannel method by creating the Selector and the ServerSocketChannel objects.
    • If the select call to the Selector returns an integer strict greater than zero we will iterate over the SelectionKey objects available to the Selector.

    • If a key is in the acceptable state we accept the incoming connection and register the connection as readable to the Selector. Otherwise, check if the key is in a readable state.

    • If the key is in readable state, then create a worker and submit that worker to the thread framework.

  4. If the channel deals with sockets, then handle the incoming sockets in separate threads. The channel framework supports this through the com.intentia.ec.shared.IThreadWorker interface.
  5. Instead of having the runChannel method receive the message, you can put that logic into the runWork method of the IThreadWorker. The runWork method will be called by a separate thread and the runChannel method will accept the incoming connection and create an IThreadWorker object.