IN - The input type of the sink.@PublicEvolving public class PulsarSinkBuilder<IN> extends Object
PulsarSink to make it easier for the users to construct a PulsarSink.
The following example shows the minimum setup to create a PulsarSink that reads the String values from a Pulsar topic.
PulsarSink<String> sink = PulsarSink.builder()
.setServiceUrl(operator().serviceUrl())
.setAdminUrl(operator().adminUrl())
.setTopics(topic)
.setSerializationSchema(PulsarSerializationSchema.pulsarSchema(Schema.STRING))
.build();
The service url, admin url, and the record serializer are required fields that must be set. If
you don't set the topics, make sure you have provided a custom TopicRouter. Otherwise,
you must provide the topics to produce.
To specify the delivery guarantees of PulsarSink, one can call setDeliveryGuarantee(DeliveryGuarantee). The default value of the delivery guarantee is DeliveryGuarantee.NONE, and it wouldn't promise the consistence when write the message into
Pulsar.
PulsarSink<String> sink = PulsarSink.builder()
.setServiceUrl(operator().serviceUrl())
.setAdminUrl(operator().adminUrl())
.setTopics(topic)
.setSerializationSchema(PulsarSerializationSchema.pulsarSchema(Schema.STRING))
.setDeliveryGuarantee(deliveryGuarantee)
.build();
| Modifier and Type | Method and Description |
|---|---|
PulsarSink<IN> |
build()
Build the
PulsarSink. |
PulsarSinkBuilder<IN> |
delaySendingMessage(MessageDelayer<IN> messageDelayer)
Set a message delayer for enable Pulsar message delay delivery.
|
PulsarSinkBuilder<IN> |
enableSchemaEvolution()
If you enable this option, we would consume and deserialize the message by using Pulsar
Schema. |
PulsarSinkBuilder<IN> |
setAdminUrl(String adminUrl)
Sets the admin endpoint for the PulsarAdmin of the PulsarSink.
|
<T> PulsarSinkBuilder<IN> |
setConfig(org.apache.flink.configuration.ConfigOption<T> key,
T value)
Set an arbitrary property for the PulsarSink and Pulsar Producer.
|
PulsarSinkBuilder<IN> |
setConfig(org.apache.flink.configuration.Configuration config)
Set arbitrary properties for the PulsarSink and Pulsar Producer.
|
PulsarSinkBuilder<IN> |
setDeliveryGuarantee(org.apache.flink.connector.base.DeliveryGuarantee deliveryGuarantee)
Sets the wanted the
DeliveryGuarantee. |
PulsarSinkBuilder<IN> |
setProducerName(String producerName)
The producer name is informative, and it can be used to identify a particular producer
instance from the topic stats.
|
PulsarSinkBuilder<IN> |
setProperties(Properties properties)
Set arbitrary properties for the PulsarSink and Pulsar Producer.
|
<T extends IN> |
setSerializationSchema(PulsarSerializationSchema<T> serializationSchema)
Sets the
PulsarSerializationSchema that transforms incoming records to bytes. |
PulsarSinkBuilder<IN> |
setServiceUrl(String serviceUrl)
Sets the server's link for the PulsarProducer of the PulsarSink.
|
PulsarSinkBuilder<IN> |
setTopicRouter(TopicRouter<IN> topicRouter)
Use a custom topic router instead predefine topic routing.
|
PulsarSinkBuilder<IN> |
setTopicRoutingMode(TopicRoutingMode topicRoutingMode)
Set a routing mode for choosing right topic partition to send messages.
|
PulsarSinkBuilder<IN> |
setTopics(List<String> topics)
Set a pulsar topic list for flink sink.
|
PulsarSinkBuilder<IN> |
setTopics(String... topics)
Set a pulsar topic list for flink sink.
|
public PulsarSinkBuilder<IN> setAdminUrl(String adminUrl)
adminUrl - The url for the PulsarAdmin.public PulsarSinkBuilder<IN> setServiceUrl(String serviceUrl)
serviceUrl - The server url of the Pulsar cluster.public PulsarSinkBuilder<IN> setProducerName(String producerName)
producerName - The name of the producer used in Pulsar sink.public PulsarSinkBuilder<IN> setTopics(String... topics)
topics - The topic list you would like to consume message.public PulsarSinkBuilder<IN> setTopics(List<String> topics)
topics - The topic list you would like to consume message.public PulsarSinkBuilder<IN> setDeliveryGuarantee(org.apache.flink.connector.base.DeliveryGuarantee deliveryGuarantee)
DeliveryGuarantee. The default delivery guarantee is DeliveryGuarantee.NONE.deliveryGuarantee - Deliver guarantees.public PulsarSinkBuilder<IN> setTopicRoutingMode(TopicRoutingMode topicRoutingMode)
topicRoutingMode - Routing policy for choosing the desired topic.public PulsarSinkBuilder<IN> setTopicRouter(TopicRouter<IN> topicRouter)
topicRouter - The router for choosing topic to send message.public <T extends IN> PulsarSinkBuilder<T> setSerializationSchema(PulsarSerializationSchema<T> serializationSchema)
PulsarSerializationSchema that transforms incoming records to bytes.serializationSchema - Pulsar specified serialize logic.public PulsarSinkBuilder<IN> enableSchemaEvolution()
Schema.public PulsarSinkBuilder<IN> delaySendingMessage(MessageDelayer<IN> messageDelayer)
messageDelayer - The delayer which would defined when to send the message to consumer.public <T> PulsarSinkBuilder<IN> setConfig(org.apache.flink.configuration.ConfigOption<T> key, T value)
PulsarSinkOptions and PulsarOptions.
Make sure the option could be set only once or with same value.
key - The key of the property.value - The value of the property.public PulsarSinkBuilder<IN> setConfig(org.apache.flink.configuration.Configuration config)
PulsarSinkOptions and PulsarOptions.config - The config to set for the PulsarSink.public PulsarSinkBuilder<IN> setProperties(Properties properties)
PulsarSinkOptions and PulsarOptions.
This method is mainly used for future flink SQL binding.
properties - The config properties to set for the PulsarSink.public PulsarSink<IN> build()
PulsarSink.Copyright © 2014–2022 The Apache Software Foundation. All rights reserved.