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 classKafkaClientsMethods.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 KafkaProducercreateProducer(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 KafkaProducercreateProducer(String bootstrapServers, KafkaClientsMethods.SerializerClass keySerializer, KafkaClientsMethods.SerializerClass valueSerializer, GloopExecutionContext context)Creates aproducerfor publishing messages.static KafkaProducercreateProducer(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 KafkaProducercreateProducer(String bootstrapServers, KafkaClientsMethods.SerializerClass keySerializer, KafkaClientsMethods.SerializerClass valueSerializer, Properties producerConfigs, GloopExecutionContext context)Create aproducerusing the providedconfiguration, for publishing messages.static KafkaProducercreateProducer(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 KafkaProducercreateProducer(String bootstrapServers, Class<? extends Serializer> keySerializer, Class<? extends Serializer> valueSerializer, GloopExecutionContext context)Creates aproducerfor publishing messages.static KafkaProducercreateProducer(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 KafkaProducercreateProducer(String bootstrapServers, Properties producerConfigs, GloopExecutionContext context)Creates aproducerusing the providedconfiguration, for publishing messages.static voidsend(KafkaProducer<Object,Object> producer, String topic, int partition, Object key, Object value)Asynchronously send a record to a topic.static voidsend(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 aproducerusing the providedconfiguration, for publishing messages.- Parameters:
bootstrapServers- comma-separated values of host/port pairs to use for establishing initial connection to the Kafka clusterkeySerializer-serializerfor keyvalueSerializer-serializerfor valueproducerConfigs- configuration for the producer in key-value pairs- Returns:
KafkaProducerthe 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 aproducerusing the providedconfiguration, for publishing messages.- Parameters:
bootstrapServers- comma-separated values of host/port pairs to use for establishing initial connection to the Kafka clusterkeySerializer-serializerfor keyvalueSerializer-serializerfor value Kafka @param producerConfigs configuration for the producer in key-value pairs- Returns:
KafkaProducerthe 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 aproducerfor publishing messages.- Parameters:
bootstrapServers- comma-separated values of host/port pairs to use for establishing initial connection to the Kafka clusterkeySerializer-serializerfor keyvalueSerializer-serializerfor value- Returns:
KafkaProducerthe 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 aproducerfor publishing messages.- Parameters:
bootstrapServers- comma-separated values of host/port pairs to use for establishing initial connection to the Kafka clusterkeySerializer-serializerfor keyvalueSerializer-serializerfor value- Returns:
KafkaProducerthe producer
-
createProducer
public static KafkaProducer createProducer(@GloopParameter(defaultValue="localhost:9092") String bootstrapServers, Class<? extends Serializer> keySerializer, Class<? extends Serializer> valueSerializer, GloopExecutionContext context)
Creates aproducerfor 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 implementsSerializervalueSerializer- serializer class for value that implementsSerializer- Returns:
KafkaProducerthe 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 aproducerfor 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 implementsSerializervalueSerializer- serializer class for value that implementsSerializer- Returns:
KafkaProducerthe producer
-
createProducer
public static KafkaProducer createProducer(@GloopParameter(defaultValue="localhost:9092") String bootstrapServers, Properties producerConfigs, GloopExecutionContext context)
Creates aproducerusing 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:
KafkaProducerthe 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 aproducerusing 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:
KafkaProducerthe 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- theproducerobjecttopic- 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- theproducerobjecttopic- 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
-
-