Main Content

stop

Stop processing event streams from Kafka topic

Since R2022b

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

    Syntax

    Description

    stop(ks) stops processing event stream data from a Kafka® topic and shuts down any external processes interacting with the stream.

    example

    Examples

    collapse all

    Assume that you have a Kafka server running at the network address kafka.host.com:9092. This server has a topic RecamanSequence that contains numbers in Recamán's sequence.

    Create a KafkaStream object for reading event stream data from the RecamanSequence topic.

    ks = kafkaStream("kafka.host.com",9092,"RecamanSequence");
    

    Read the first 50 rows from the stream.

    tt = readtimetable(ks)
    tt =
    
      50×2 timetable
    
             timestamp          R     key 
        ____________________    __    ____
    
        27-Jun-2022 18:37:52     0    "0" 
        27-Jun-2022 18:37:53     1    "1" 
        27-Jun-2022 18:37:54     3    "2" 
        27-Jun-2022 18:37:55     6    "3" 
        27-Jun-2022 18:37:56     2    "4" 
        27-Jun-2022 18:37:57     7    "5" 
        27-Jun-2022 18:37:58    13    "6" 
        27-Jun-2022 18:37:59    20    "7" 
    
                 :              :      :  
    
        27-Jun-2022 18:38:34    37    "42"
        27-Jun-2022 18:38:35    80    "43"
        27-Jun-2022 18:38:36    36    "44"
        27-Jun-2022 18:38:37    81    "45"
        27-Jun-2022 18:38:38    35    "46"
        27-Jun-2022 18:38:39    82    "47"
        27-Jun-2022 18:38:40    34    "48"
        27-Jun-2022 18:38:41    83    "49"

    Preview the next 8 rows in the stream. The read position is set immediately after the last row read from the stream.

    preview(ks)
    ans =
    
      8×2 timetable
    
             timestamp          R     key 
        ____________________    __    ____
    
        27-Jun-2022 18:38:42    33    "50"
        27-Jun-2022 18:38:43    84    "51"
        27-Jun-2022 18:38:44    32    "52"
        27-Jun-2022 18:38:45    85    "53"
        27-Jun-2022 18:38:46    31    "54"
        27-Jun-2022 18:38:47    86    "55"
        27-Jun-2022 18:38:48    30    "56"
        27-Jun-2022 18:38:49    87    "57"
    

    Stop processing the stream.

    stop(ks)

    Input Arguments

    collapse all

    Object connected to a Kafka stream topic, specified as a KafkaStream object.

    Version History

    Introduced in R2022b