Package io.toro.martini
Class KafkaClientsMethods
- java.lang.Object
-
- io.toro.martini.KafkaClientsMethods
-
public final class KafkaClientsMethods extends Object
Contains one-liners for Kafka-related operations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
KafkaClientsMethods.SerializerClass
-
Constructor Summary
Constructors Constructor Description KafkaClientsMethods(io.toro.martini.KafkaProducerFactory producerFactory)
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static KafkaProducer
createProducer(String bootstrapServers, KafkaClientsMethods.SerializerClass keySerializer, KafkaClientsMethods.SerializerClass valueSerializer)
Deprecated, for removal: This API element is subject to removal in a future version.please use the overloaded method that has GloopExecutionContext parameter as it will do autoclose when gloop service finishstatic KafkaProducer
createProducer(String bootstrapServers, KafkaClientsMethods.SerializerClass keySerializer, KafkaClientsMethods.SerializerClass valueSerializer, GloopExecutionContext context)
Creates aproducer
for publishing messages.static KafkaProducer
createProducer(String bootstrapServers, KafkaClientsMethods.SerializerClass keySerializer, KafkaClientsMethods.SerializerClass valueSerializer, Properties producerConfigs)
Deprecated, for removal: This API element is subject to removal in a future version.please use the overloaded method that has GloopExecutionContext parameter as it will do autoclose when gloop service finishstatic KafkaProducer
createProducer(String bootstrapServers, KafkaClientsMethods.SerializerClass keySerializer, KafkaClientsMethods.SerializerClass valueSerializer, Properties producerConfigs, GloopExecutionContext context)
Create aproducer
using the providedconfiguration
, for publishing messages.static KafkaProducer
createProducer(String bootstrapServers, Class<? extends Serializer> keySerializer, Class<? extends Serializer> valueSerializer)
Deprecated, for removal: This API element is subject to removal in a future version.please use the overloaded method that has GloopExecutionContext parameter as it will do autoclose when gloop service finishstatic KafkaProducer
createProducer(String bootstrapServers, Class<? extends Serializer> keySerializer, Class<? extends Serializer> valueSerializer, GloopExecutionContext context)
Creates aproducer
for publishing messages.static KafkaProducer
createProducer(String bootstrapServers, Properties producerConfigs)
Deprecated, for removal: This API element is subject to removal in a future version.please use the overloaded method that has GloopExecutionContext parameter as it will do autoclose when gloop service finishstatic KafkaProducer
createProducer(String bootstrapServers, Properties producerConfigs, GloopExecutionContext context)
Creates aproducer
using the providedconfiguration
, 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.
-
-
-
Method Detail
-
createProducer
@GloopObjectParameter("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, GloopExecutionContext context)
Create aproducer
using the providedconfiguration
, for publishing messages.- Parameters:
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 pairs- Returns:
KafkaProducer
the producer- See Also:
- valid producer configurations
-
createProducer
@Deprecated(since="2.0", forRemoval=true) @GloopObjectParameter("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)
Deprecated, for removal: This API element is subject to removal in a future version.please use the overloaded method that has GloopExecutionContext parameter as it will do autoclose when gloop service finishCreate aproducer
using the providedconfiguration
, for publishing messages.- Parameters:
bootstrapServers
- comma-separated values of host/port pairs to use for establishing initial connection to the Kafka clusterkeySerializer
-serializer
for keyvalueSerializer
-serializer
for value Kafka @param producerConfigs configuration for the producer in key-value pairs- Returns:
KafkaProducer
the producer- See Also:
- valid producer configurations
-
createProducer
public static KafkaProducer createProducer(@GloopParameter(defaultValue="localhost:9092") String bootstrapServers, @GloopParameter(defaultValue="STRING") KafkaClientsMethods.SerializerClass keySerializer, @GloopParameter(defaultValue="STRING") KafkaClientsMethods.SerializerClass valueSerializer, GloopExecutionContext context)
Creates aproducer
for publishing messages.- Parameters:
bootstrapServers
- comma-separated values of host/port pairs to use for establishing initial connection to the Kafka clusterkeySerializer
-serializer
for keyvalueSerializer
-serializer
for value- Returns:
KafkaProducer
the producer
-
createProducer
@Deprecated(since="2.0", forRemoval=true) public static KafkaProducer createProducer(@GloopParameter(defaultValue="localhost:9092") String bootstrapServers, @GloopParameter(defaultValue="STRING") KafkaClientsMethods.SerializerClass keySerializer, @GloopParameter(defaultValue="STRING") KafkaClientsMethods.SerializerClass valueSerializer)
Deprecated, for removal: This API element is subject to removal in a future version.please use the overloaded method that has GloopExecutionContext parameter as it will do autoclose when gloop service finishCreates aproducer
for publishing messages.- Parameters:
bootstrapServers
- comma-separated values of host/port pairs to use for establishing initial connection to the Kafka clusterkeySerializer
-serializer
for keyvalueSerializer
-serializer
for value- Returns:
KafkaProducer
the producer
-
createProducer
public static KafkaProducer createProducer(@GloopParameter(defaultValue="localhost:9092") String bootstrapServers, Class<? extends Serializer> keySerializer, Class<? extends Serializer> valueSerializer, GloopExecutionContext context)
Creates aproducer
for publishing messages.- Parameters:
bootstrapServers
- comma-separated values of host/port pairs to use for establishing initial connection to the Kafka clusterkeySerializer
- serializer class for key that implementsSerializer
valueSerializer
- serializer class for value that implementsSerializer
- Returns:
KafkaProducer
the producer
-
createProducer
@Deprecated(since="2.0", forRemoval=true) public static KafkaProducer createProducer(@GloopParameter(defaultValue="localhost:9092") String bootstrapServers, Class<? extends Serializer> keySerializer, Class<? extends Serializer> valueSerializer)
Deprecated, for removal: This API element is subject to removal in a future version.please use the overloaded method that has GloopExecutionContext parameter as it will do autoclose when gloop service finishCreates aproducer
for publishing messages.- Parameters:
bootstrapServers
- comma-separated values of host/port pairs to use for establishing initial connection to the Kafka clusterkeySerializer
- serializer class for key that implementsSerializer
valueSerializer
- serializer class for value that implementsSerializer
- Returns:
KafkaProducer
the producer
-
createProducer
public static KafkaProducer createProducer(@GloopParameter(defaultValue="localhost:9092") String bootstrapServers, Properties producerConfigs, GloopExecutionContext context)
Creates aproducer
using the providedconfiguration
, for publishing messages.- Parameters:
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 pairs- Returns:
KafkaProducer
the producer- See Also:
- valid producer configurations
-
createProducer
@Deprecated(since="2.0", forRemoval=true) public static KafkaProducer createProducer(@GloopParameter(defaultValue="localhost:9092") String bootstrapServers, Properties producerConfigs)
Deprecated, for removal: This API element is subject to removal in a future version.please use the overloaded method that has GloopExecutionContext parameter as it will do autoclose when gloop service finishCreates aproducer
using the providedconfiguration
, for publishing messages.- Parameters:
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 pairs- Returns:
KafkaProducer
the producer- See Also:
- valid producer configurations
-
send
public static void send(KafkaProducer<Object,Object> producer, String topic, Object key, Object value)
Asynchronously send a record to a topic.- Parameters:
producer
- theproducer
objecttopic
- the topic the message will be appended tokey
- the key that will be included in the messagevalue
- the record contents
-
send
public static void send(KafkaProducer<Object,Object> producer, String topic, int partition, Object key, Object value)
Asynchronously send a record to a topic.- Parameters:
producer
- theproducer
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 contents
-
-