public final class KafkaClientsMethods extends Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
KafkaClientsMethods.SerializerClass |
Constructor and Description |
---|
KafkaClientsMethods() |
Modifier and Type | Method and Description |
---|---|
static KafkaProducer |
createProducer(String bootstrapServers,
Class<? extends Serializer> keySerializer,
Class<? extends Serializer> valueSerializer)
Creates a
producer for publishing messages. |
static KafkaProducer |
createProducer(String bootstrapServers,
KafkaClientsMethods.SerializerClass keySerializer,
KafkaClientsMethods.SerializerClass valueSerializer)
Creates a
producer for publishing messages. |
static KafkaProducer |
createProducer(String bootstrapServers,
KafkaClientsMethods.SerializerClass keySerializer,
KafkaClientsMethods.SerializerClass valueSerializer,
Properties producerConfigs)
Create a
producer using the provided configuration ,
for publishing messages. |
static KafkaProducer |
createProducer(String bootstrapServers,
Properties producerConfigs)
Creates a
producer using the provided configuration ,
for publishing messages. |
static void |
send(KafkaProducer<Object,Object> producer,
String topic,
int partition,
Object key,
Object value)
Asynchronously send a record to a topic.
|
static void |
send(KafkaProducer<Object,Object> producer,
String topic,
Object key,
Object value)
Asynchronously send a record to a topic.
|
@GloopObjectParameter(value="producer{\nproducer:object:KafkaProducer object\n}") public static KafkaProducer createProducer(@GloopParameter(defaultValue="localhost:9092") String bootstrapServers, @GloopParameter(defaultValue="STRING") KafkaClientsMethods.SerializerClass keySerializer, @GloopParameter(defaultValue="STRING") KafkaClientsMethods.SerializerClass valueSerializer, Properties producerConfigs)
producer
using the provided configuration
,
for publishing messages.bootstrapServers
- comma-separated values of host/port pairs to use for establishing initial connection to
the Kafka clusterkeySerializer
- serializer
for keyvalueSerializer
- serializer
for valueproducerConfigs
- configuration for the producer in key-value pairsKafkaProducer
the producerpublic static KafkaProducer createProducer(@GloopParameter(defaultValue="localhost:9092") String bootstrapServers, @GloopParameter(defaultValue="STRING") KafkaClientsMethods.SerializerClass keySerializer, @GloopParameter(defaultValue="STRING") KafkaClientsMethods.SerializerClass valueSerializer)
producer
for publishing messages.bootstrapServers
- comma-separated values of host/port pairs to use for establishing initial connection to
the Kafka clusterkeySerializer
- serializer
for keyvalueSerializer
- serializer
for valueKafkaProducer
the producerpublic static KafkaProducer createProducer(@GloopParameter(defaultValue="localhost:9092") String bootstrapServers, Class<? extends Serializer> keySerializer, Class<? extends Serializer> valueSerializer)
producer
for publishing messages.bootstrapServers
- comma-separated values of host/port pairs to use for establishing initial connection to
the Kafka clusterkeySerializer
- serializer class for key that
implements Serializer
valueSerializer
- serializer class for value that
implements Serializer
KafkaProducer
the producerpublic static KafkaProducer createProducer(@GloopParameter(defaultValue="localhost:9092") String bootstrapServers, Properties producerConfigs)
producer
using the provided configuration
,
for publishing messages.bootstrapServers
- comma-separated values of host/port pairs to use for establishing initial connection to
the Kafka clusterproducerConfigs
- configuration for the produces in key-value pairsKafkaProducer
the producerpublic static void send(KafkaProducer<Object,Object> producer, String topic, Object key, Object value)
producer
- the producer
objecttopic
- the topic the message will be appended tokey
- the key that will be included in the messagevalue
- the record contentspublic static void send(KafkaProducer<Object,Object> producer, String topic, int partition, Object key, Object value)
producer
- the producer
objecttopic
- the topic the message will be appended topartition
- the partition to which the record should be sentkey
- the key that will be included in the messagevalue
- the record contentsCopyright © 2023. All rights reserved.