Package org.apache.pulsar.io.core
Class PushSource<T>
java.lang.Object
org.apache.pulsar.io.core.PushSource<T>
- All Implemented Interfaces:
AutoCloseable,Source<T>
Pulsar's Push Source interface. PushSource read data from
external sources (database changes, twitter firehose, etc)
and publish to a Pulsar topic. The reason its called Push is
because PushSources get passed a consumer that they
invoke whenever they have data to be published to Pulsar.
The lifecycle of a PushSource is to open it passing any config needed
by it to initialize(like open network connection, authenticate, etc).
A consumer is then to it which is invoked by the source whenever
there is data to be published. Once all data has been read, one can use close
at the end of the session to do any cleanup
-
Constructor Details
-
PushSource
public PushSource()
-
-
Method Details
-
read
Description copied from interface:SourceReads the next message from source. If source does not have any new messages, this call should block. -
open
Open connector with configuration. -
consume
Attach a consumer function to this Source. This is invoked by the implementation to pass messages whenever there is data to be pushed to Pulsar.- Parameters:
record- next message from source which should be sent to a Pulsar topic
-
getQueueLength
public int getQueueLength()Get length of the queue that records are push onto. Users can override this method to customize the queue length- Returns:
- queue length
-