Set position in event stream to begin processing events
This function requires Streaming Data Framework for MATLAB® Production Server™.
Process Events from Beginning of Stream
Assume that you have a Kafka® server running at the network address
that has a topic
KafkaStream object connected to the
ks = kafkaStream("kafka.host.com",9092,"RecamanSequence");
Assume that you have a stateful streaming analytic function
recamanSum and a function to initialize the per-iteration state
initRecamanSum. Create an
EventStreamProcessor object that runs the
recamanSum function and initializes the state data for the first
iteration with the
esp = eventStreamProcessor(ks,@recamanSum,@initRecamanSum);
esp = EventStreamProcessor with properties: StreamFunction: @recamanSum InputStream: [1×1 matlab.io.stream.event.KafkaStream] OutputStream: [1×1 matlab.io.stream.event.InMemoryStream] InitialState: @initRecamanSum GroupVariable: [0×0 string] ReadPosition: Beginning ArchiveName: "recamanSum" ResetStateOnSeek: 1
Iterate the streaming analytic function over ten event windows.
Check the result of the
result = readtimetable(esp.OutputStream)
esp — Object to process event streams
Object to process event streams, specified as an
position — Position in event stream
Position in an event stream, specified as one of the following values.
"Beginning"— First event available in the event stream
"End"— End of the event stream, which is one event past the latest event in the stream
"Current"— Just past the current event in the stream
seek(esp,"Beginning") moves the event stream position to
the first event in the event stream.
Specify optional pairs of arguments as
the argument name and
Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
seek(esp,"Beginning",ClearState=true) moves the read position
to the first event in the stream and clears the persistent data state.
ClearState — Flag to clear persistent state of data after calling
true | false
Flag to clear persistent state of data after calling the
function, specified as a logical scalar. The default value is the value of the
PersistState — Per-iteration state value of stream processing function
any valid MATLAB data type
Per-iteration state value of the stream processing function after calling the
seek function, specified as any valid MATLAB data type.
If the streaming analytic function is stateful, then
PersistState must be a MATLAB value of the same type as the value returned by the state initialization
function set in
esp. If the streaming analytic function is
stateless, you cannot specify
Introduced in R2022b