org.apache.kafka.clients.producer.Partitioner Java Examples

The following examples show how to use org.apache.kafka.clients.producer.Partitioner. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KafkaProcessor.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@BuildStep
public void build(CombinedIndexBuildItem indexBuildItem, BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
        Capabilities capabilities) {
    final Set<DotName> toRegister = new HashSet<>();

    collectImplementors(toRegister, indexBuildItem, Serializer.class);
    collectImplementors(toRegister, indexBuildItem, Deserializer.class);
    collectImplementors(toRegister, indexBuildItem, Partitioner.class);
    // PartitionAssignor is now deprecated, replaced by ConsumerPartitionAssignor
    collectImplementors(toRegister, indexBuildItem, PartitionAssignor.class);
    collectImplementors(toRegister, indexBuildItem, ConsumerPartitionAssignor.class);

    for (Class<?> i : BUILT_INS) {
        reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, i.getName()));
        collectSubclasses(toRegister, indexBuildItem, i);
    }
    if (capabilities.isCapabilityPresent(Capabilities.JSONB)) {
        reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, JsonbSerializer.class, JsonbDeserializer.class));
        collectSubclasses(toRegister, indexBuildItem, JsonbSerializer.class);
        collectSubclasses(toRegister, indexBuildItem, JsonbDeserializer.class);
    }
    if (capabilities.isCapabilityPresent(Capabilities.JACKSON)) {
        reflectiveClass.produce(
                new ReflectiveClassBuildItem(false, false, ObjectMapperSerializer.class, ObjectMapperDeserializer.class));
        collectSubclasses(toRegister, indexBuildItem, ObjectMapperSerializer.class);
        collectSubclasses(toRegister, indexBuildItem, ObjectMapperDeserializer.class);
    }

    for (DotName s : toRegister) {
        reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, s.toString()));
    }

    // built in partitioner and partition assignors
    reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, DefaultPartitioner.class.getName()));
    reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, RangeAssignor.class.getName()));
    reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, RoundRobinAssignor.class.getName()));
    reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, StickyAssignor.class.getName()));

    // classes needed to perform reflection on DirectByteBuffer - only really needed for Java 8
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, "java.nio.DirectByteBuffer"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, "sun.misc.Cleaner"));
}