IN- The record type needs to be written to Pulsar.
@PublicEvolving public interface TopicRouter<IN> extends Serializable
This topic router is stateless and doesn't have any initialize logic. Make sure you don't require some dynamic state.
|Modifier and Type||Method and Description|
Implement this method if you have some non-serializable field.
Choose the topic by given record & available partition list.
String route(IN in, String key, List<String> partitions, PulsarSinkContext context)
in- The record instance which need to be written to Pulsar.
key- The key of the message from
PulsarMessageBuilder.key(String). It could be null, if message doesn't have a key.
partitions- The available partition list. This could be empty if you don't provide any topics in
PulsarSinkBuilder.setTopics(String...). You can return a custom topic, but make sure it should contain a partition index in naming. Using
TopicNameUtils.topicNameWithPartition(String, int)can easily create a topic name with partition index.
context- The context contains useful information for determining the topic.
default void open(SinkConfiguration sinkConfiguration)
Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.