Class PubSubSplitReaders
java.lang.Object
io.github.flink.gcp.connector.testutils.pubsub.PubSubSplitReaders
Fetch-loop helpers for driving a Pub/Sub
SplitReader directly in tests, typed against the
flink-connector-base interface so the connector's reader class never crosses the module
boundary.-
Method Summary
Modifier and TypeMethodDescriptionstatic List<com.google.pubsub.v1.PubsubMessage>fetchUntil(org.apache.flink.connector.base.source.reader.splitreader.SplitReader<com.google.pubsub.v1.PubsubMessage, ?> reader, int expected, Duration timeout) Fetches untilexpecteddistinct messages have been collected or the timeout elapses, returning them in arrival order.Returns the messages' UTF-8 payloads, in order.
-
Method Details
-
fetchUntil
public static List<com.google.pubsub.v1.PubsubMessage> fetchUntil(org.apache.flink.connector.base.source.reader.splitreader.SplitReader<com.google.pubsub.v1.PubsubMessage, ?> reader, int expected, Duration timeout) throws ExceptionFetches untilexpecteddistinct messages have been collected or the timeout elapses, returning them in arrival order. Distinct by split and message id — message ids are only unique within a topic — because delivery is at-least-once: a wait long enough to span the acknowledgement deadline can legitimately see the same message twice, and a duplicate must dedupe rather than crowd out a message still to arrive. A fetch blocks until data arrives, so a waker nudges the reader once the deadline passes; an emptiness check (expected = Integer.MAX_VALUE) holds its full window.- Throws:
Exception
-
payloads
Returns the messages' UTF-8 payloads, in order.
-