Skip to content

Commit

Permalink
AlarmCategory support
Browse files Browse the repository at this point in the history
  • Loading branch information
slominskir committed Jul 8, 2024
1 parent fe297a8 commit 1491170
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/main/java/org/jlab/jaws/clients/CategoryConsumer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jlab.jaws.clients;

import org.jlab.jaws.entity.AlarmCategory;
import org.jlab.kafka.eventsource.EventSourceConfig;

import java.time.Instant;
Expand All @@ -8,7 +9,7 @@
/**
* A Consumer provides default properties values for GROUP, TOPIC, KEY_DESERIALIZER, and VALUE_DESERIALIZER.
*/
public class CategoryConsumer extends JAWSConsumer<String, String> {
public class CategoryConsumer extends JAWSConsumer<String, AlarmCategory> {
/**
* Create a new Consumer with the provided property overrides.
*
Expand All @@ -28,7 +29,7 @@ private static Properties setDefaults(Properties overrides) {
defaults.put(EventSourceConfig.GROUP_ID_CONFIG, "category-consumer" + Instant.now().toString() + "-" + Math.random());
defaults.put(EventSourceConfig.TOPIC_CONFIG, CategoryProducer.TOPIC);
defaults.put(EventSourceConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
defaults.put(EventSourceConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
defaults.put(EventSourceConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "io.confluent.kafka.serializers.KafkaAvroDeserializer");

defaults.putAll(overrides);

Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/jlab/jaws/clients/CategoryProducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.apache.kafka.common.header.Header;
import org.jlab.jaws.entity.AlarmCategory;

import java.time.Instant;
import java.util.Properties;
Expand All @@ -13,7 +14,7 @@
* A Producer provides default properties values for CLIENT_ID, TOPIC, KEY_DESERIALIZER, and VALUE_DESERIALIZER.
* A default send method is also provided.
*/
public class CategoryProducer extends JAWSProducer<String, String> {
public class CategoryProducer extends JAWSProducer<String, AlarmCategory> {
/**
* The topic name
*/
Expand All @@ -37,7 +38,7 @@ private static Properties setDefaults(Properties overrides) {

defaults.put(ProducerConfig.CLIENT_ID_CONFIG, "category-producer" + Instant.now().toString() + "-" + Math.random());
defaults.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
defaults.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
defaults.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "io.confluent.kafka.serializers.KafkaAvroSerializer");

defaults.putAll(overrides);

Expand All @@ -51,7 +52,7 @@ private static Properties setDefaults(Properties overrides) {
* @param value The message value
* @return An asynchronous call Future reference
*/
public Future<RecordMetadata> send(String key, String value) {
public Future<RecordMetadata> send(String key, AlarmCategory value) {

Iterable<Header> headers = getDefaultHeaders();

Expand Down

0 comments on commit 1491170

Please sign in to comment.