Class Source<S extends State>

  • Type Parameters:
    S - current state of the Source
    Direct Known Subclasses:
    InMemorySource

    public abstract class Source<S extends State>
    extends Object
    Abstract class to represent Event Sources. Events Sources are the object entry point to Siddhi from external transports. Each source represent a transport type. Whenever Siddhi need to support a new transport, a new Event source should be implemented.
    • Constructor Detail

      • Source

        public Source()
    • Method Detail

      • exposeServiceDeploymentInfo

        protected abstract ServiceDeploymentInfo exposeServiceDeploymentInfo()
        Give information to the deployment about the service exposed by the sink.
        Returns:
        ServiceDeploymentInfo Service related information to the deployment
      • init

        public abstract StateFactory<S> init​(SourceEventListener sourceEventListener,
                                             OptionHolder optionHolder,
                                             String[] requestedTransportPropertyNames,
                                             ConfigReader configReader,
                                             SiddhiAppContext siddhiAppContext)
        To initialize the source. (This will be called only once, no connection to external systems should be made at this point).
        Parameters:
        sourceEventListener - The listener to pass the events for processing which are consumed by the source
        optionHolder - Contains static options of the source
        requestedTransportPropertyNames - Requested transport properties that should be passed to SourceEventListener
        configReader - System configuration reader for source
        siddhiAppContext - Siddhi application context
      • getOutputEventClasses

        public abstract Class[] getOutputEventClasses()
        Get produced event class types
        Returns:
        Array of classes that will be produced by the source, null or empty array if it can produce any type of class.
      • connect

        public abstract void connect​(Source.ConnectionCallback connectionCallback,
                                     S state)
                              throws ConnectionUnavailableException
        Called to connect to the source backend for receiving events
        Parameters:
        connectionCallback - Callback to pass the ConnectionUnavailableException for connection failure after initial successful connection
        state - current state of the source
        Throws:
        ConnectionUnavailableException - if it cannot connect to the source backend
      • disconnect

        public abstract void disconnect()
        Called to disconnect from the source backend, or when ConnectionUnavailableException is thrown
      • destroy

        public abstract void destroy()
        Called at the end to clean all the resources consumed
      • pause

        public abstract void pause()
        Called to pause event consumption
      • resume

        public abstract void resume()
        Called to resume event consumption
      • connectWithRetry

        public void connectWithRetry()
      • shutdown

        public void shutdown()
      • getType

        public String getType()
      • getStreamDefinition

        public io.siddhi.query.api.definition.StreamDefinition getStreamDefinition()
      • isStateful

        public boolean isStateful()