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
-
Write an incoming communication channel class. The
class must extend another class called
com.intentia.ec.shared.IncommingChannel. -
Implement the following abstract methods in the super
class:
-
initiateChannel -
getDelayTime -
cleanUpChannel
-
-
Implement the
runChannelmethod by creating theSelectorand theServerSocketChannelobjects.-
If the select call to the Selector returns an integer strict greater than zero we will iterate over the
SelectionKeyobjects available to theSelector. -
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.
-
-
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.IThreadWorkerinterface. -
Instead of having the
runChannelmethod receive the message, you can put that logic into therunWorkmethod of theIThreadWorker. TherunWorkmethod will be called by a separate thread and therunChannelmethod will accept the incoming connection and create anIThreadWorkerobject.