Main Content


Execute event stream processing function on specific number of event windows

Since R2022b

    This function requires Streaming Data Framework for MATLAB® Production Server™.



    execute(esp,n) runs the streaming processing function specified in the Name property of processing object esp synchronously on n event windows.

    The execute function starts processing event windows at the current read position of the stream. Each event window is adjacent to the previous window, with no gaps between windows. To change the starting position of the entire sequence, call seek before calling execute.

    The first call to execute reads events from the position in the data stream where the read position was when esp was constructed. On subsequent calls to execute, the read position is set to Current. To change this behavior, call seek before execute.


    collapse all

    Assume that you have a Kafka® server running at the network address that has a topic RecamanSequence.

    Create an object connected to the RecamanSequence topic.

    ks = kafkaStream("", 9092, "RecamanSequence");

    Assume that you have a streaming analytic function recamanSum and a function to initialize persistent state called initRecamanSum.

    Create an EventStreamProcessor object that runs the recamanSum function and initializes persistent state with the initRecamanSum function.

    esp = eventStreamProcessor(ks,@recamanSum, @initRecamanSum);
    esp = 
      EventStreamProcessor with properties:
          StreamFunction: @recamanSum
             InputStream: [1×1]
            OutputStream: [1×1]
            InitialState: @initRecamanSum
           GroupVariable: [0×0 string]
            ReadPosition: Beginning
             ArchiveName: "recamanSum"
        ResetStateOnSeek: 1

    Iterate over the streaming analytic function ten times.


    Move the read position indicator to the beginning of the default output data stream.


    Examine the results.

    result = readtimetable(esp.OutputStream)

    Input Arguments

    collapse all

    Object to process event streams, specified as an EventStreamProcessor object.

    Number of event windows, specified as a positive integer.

    Version History

    Introduced in R2022b