Serving the data with WebSocket
We have just finished the aggregation of real-time ride data, and now we have the dollar amount for each zip code with sliding data in real time. We have to make use of this data in real time as well. Let's do that!
NycTaxiDataServer
is an operator that listens to the triggers from the aforementioned WindowedOperator
. It also listens for incoming query messages via WebSocket, processes the queries according to the real-time state, and sends back the results, again via WebSocket.
In order to do that, NycTaxiDataServer
extends from the AbstractAppDataServer
class, which provides the embedded query listening capability. This allows an input operator to be embedded in the operator so that message from the input operator can be sent immediately to the operator. If the input operator is part of the pipeline, the messages from the input operator could be delayed due to lag of the rest of the pipeline.
Note that the triggers from the upstream WindowedOperator
are sent...