use of org.apache.flink.connector.pulsar.source.reader.deserializer.PulsarDeserializationSchemaInitializationContext in project flink by apache.
the class PulsarSource method createReader.
@Internal
@Override
public SourceReader<OUT, PulsarPartitionSplit> createReader(SourceReaderContext readerContext) throws Exception {
// Initialize the deserialization schema before creating the pulsar reader.
PulsarDeserializationSchemaInitializationContext initializationContext = new PulsarDeserializationSchemaInitializationContext(readerContext);
deserializationSchema.open(initializationContext, sourceConfiguration);
return PulsarSourceReaderFactory.create(readerContext, deserializationSchema, sourceConfiguration);
}
use of org.apache.flink.connector.pulsar.source.reader.deserializer.PulsarDeserializationSchemaInitializationContext in project flink by apache.
the class PulsarSourceReaderTestBase method sourceReader.
private PulsarSourceReaderBase<Integer> sourceReader(boolean autoAcknowledgementEnabled, SubscriptionType subscriptionType) {
Configuration configuration = operator().config();
configuration.set(PULSAR_MAX_FETCH_RECORDS, 1);
configuration.set(PULSAR_MAX_FETCH_TIME, 1000L);
configuration.set(PULSAR_SUBSCRIPTION_NAME, randomAlphabetic(10));
configuration.set(PULSAR_SUBSCRIPTION_TYPE, subscriptionType);
if (autoAcknowledgementEnabled || configuration.get(PULSAR_SUBSCRIPTION_TYPE) == SubscriptionType.Shared) {
configuration.set(PULSAR_ENABLE_AUTO_ACKNOWLEDGE_MESSAGE, true);
}
PulsarDeserializationSchema<Integer> deserializationSchema = pulsarSchema(Schema.INT32);
SourceReaderContext context = new TestingReaderContext();
try {
deserializationSchema.open(new PulsarDeserializationSchemaInitializationContext(context), mock(SourceConfiguration.class));
} catch (Exception e) {
fail("Error while opening deserializationSchema");
}
SourceConfiguration sourceConfiguration = new SourceConfiguration(configuration);
return (PulsarSourceReaderBase<Integer>) PulsarSourceReaderFactory.create(context, deserializationSchema, sourceConfiguration);
}
Aggregations