public final class KafkaClientsMethods extends Object
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 . |
static KafkaProducer |
createProducer(String bootstrapServers,
io.toro.martini.KafkaClientsMethods.SerializerClass keySerializer,
io.toro.martini.KafkaClientsMethods.SerializerClass valueSerializer)
Creates a
producer . |
static KafkaProducer |
createProducer(String bootstrapServers,
io.toro.martini.KafkaClientsMethods.SerializerClass keySerializer,
io.toro.martini.KafkaClientsMethods.SerializerClass valueSerializer,
Properties producerConfigs)
Creates a
producer using the provided configuration . |
static KafkaProducer |
createProducer(String bootstrapServers,
Properties producerConfigs)
Creates a
producer using the provided configuration . |
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") io.toro.martini.KafkaClientsMethods.SerializerClass keySerializer, @GloopParameter(defaultValue="STRING") io.toro.martini.KafkaClientsMethods.SerializerClass valueSerializer, Properties producerConfigs)
producer
using the provided configuration
. It is used for
publishing messages.bootstrapServers
- comma-separated values of host/port pairs to use for establishing initial connection to
the Kafka clusterkeySerializer
- serializer
for key;valueSerializer
- serializer
for value;producerConfigs
- key-value pairs producer configs; valid configurations are documented hereKafkaProducer
the producerpublic static KafkaProducer createProducer(@GloopParameter(defaultValue="localhost:9092") String bootstrapServers, @GloopParameter(defaultValue="STRING") io.toro.martini.KafkaClientsMethods.SerializerClass keySerializer, @GloopParameter(defaultValue="STRING") io.toro.martini.KafkaClientsMethods.SerializerClass valueSerializer)
producer
. It is used for publishing messages.bootstrapServers
- comma-separated values of host/port pairs to use for establishing initial connection to
the Kafka clusterkeySerializer
- serializer
for key;valueSerializer
- serializer
for value;KafkaProducer
the producerpublic static KafkaProducer createProducer(@GloopParameter(defaultValue="localhost:9092") String bootstrapServers, Class<? extends Serializer> keySerializer, Class<? extends Serializer> valueSerializer)
producer
. It is used 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
. It is used for
publishing messages.bootstrapServers
- comma-separated values of host/port pairs to use for establishing initial connection to
the Kafka clusterproducerConfigs
- key-value pairs producer configs; valid configurations are documented hereKafkaProducer
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 © 2019. All rights reserved.