Class SocketProductReceiver

All Implemented Interfaces:
NotificationIndexCleanup.Listener, NotificationReceiver, Configurable, SocketListenerInterface

public class SocketProductReceiver extends DefaultNotificationReceiver implements SocketListenerInterface
Receive Products directly via a Socket. The received products are sent using a SocketProductSender. A SocketProductReceiver receives products directly and notifies listeners of received notifications. These are typically used on hubs with an EIDSNotificationSender or RelayProductReceiver. The DefaultNotificationReceiver implements the Configurable interface and uses the following configuration parameters: Each listener has a separate queue of notifications. Each listener is allocated one thread to process notifications from this queue.
  • Constructor Details

    • SocketProductReceiver

      public SocketProductReceiver() throws Exception
      Default constructor setting port, threads, and sizeLimit to default
      Throws:
      Exception - if error occurs
    • SocketProductReceiver

      public SocketProductReceiver(Config config) throws Exception
      Constructor based on config file
      Parameters:
      config - Configuration file
      Throws:
      Exception - if error occurs
  • Method Details

    • configure

      public void configure(Config config) throws Exception
      Description copied from class: DefaultConfigurable
      Process configuration settings. Called before startup().
      Specified by:
      configure in interface Configurable
      Overrides:
      configure in class DefaultNotificationReceiver
      Parameters:
      config - the Config object with settings.
      Throws:
      Exception - if configuration exceptions occur.
    • startup

      public void startup() throws Exception
      Description copied from class: DefaultConfigurable
      Start any processing/background threads.
      Specified by:
      startup in interface Configurable
      Overrides:
      startup in class DefaultNotificationReceiver
      Throws:
      Exception - if exceptions occur while starting.
    • shutdown

      public void shutdown() throws Exception
      Description copied from class: DefaultConfigurable
      Stop any processing/background threads.
      Specified by:
      shutdown in interface Configurable
      Overrides:
      shutdown in class DefaultNotificationReceiver
      Throws:
      Exception - if exceptions occur while starting.
    • onSocket

      public void onSocket(Socket socket)
      Description copied from interface: SocketListenerInterface
      Called with any sockets to be read.
      Specified by:
      onSocket in interface SocketListenerInterface
      Parameters:
      socket - socket to be processed.
    • storeAndNotify

      protected String storeAndNotify(ProductSource source) throws Exception
      Stores ProductSource as a notification, and notifies Listeners
      Parameters:
      source - ProductSource
      Returns:
      String note for log file
      Throws:
      Exception - if error occurs
    • getPort

      public int getPort()
      Returns:
      port
    • setPort

      public void setPort(int port)
      Parameters:
      port - int to set
    • getSizeLimit

      public long getSizeLimit()
      Returns:
      sizeLimit
    • setSizeLimit

      public void setSizeLimit(long sizeLimit)
      Parameters:
      sizeLimit - long to set
    • getThreads

      public int getThreads()
      Returns:
      threads
    • setThreads

      public void setThreads(int threads)
      Parameters:
      threads - int to set